3 # testsuite for Data::Dumper
7 require Config; import Config;
8 if ($Config{'extensions'} !~ /\bData\/Dumper\b/) {
9 print "1..0 # Skip: Data::Dumper was not built\n";
14 # Since Perl 5.8.1 because otherwise hash ordering is really random.
15 local $Data::Dumper::Sortkeys = 1;
19 my $Is_ebcdic = defined($Config{'ebcdic'}) && $Config{'ebcdic'} eq 'define';
21 $Data::Dumper::Pad = "#";
32 $t =~ s/([A-Z]+)\(0x[0-9a-f]+\)/$1(0xdeadbeef)/g
33 if ($WANT =~ /deadbeef/);
35 # these data need massaging with non ascii character sets
36 # because of hashing order differences
37 $WANT = join("\n",sort(split(/\n/,$WANT)));
39 $t = join("\n",sort(split(/\n/,$t)));
42 $name = $name ? " - $name" : '';
43 print( ($t eq $WANT and not $@) ? "ok $TNUM$name\n"
44 : "not ok $TNUM$name\n--Expected--\n$WANT\n--Got--\n$@$t\n");
47 if ($Is_ebcdic) { # EBCDIC.
48 if ($TNUM == 311 || $TNUM == 314) {
56 print $@ ? "not ok $TNUM\n# \$@ says: $@\n" : "ok $TNUM\n";
60 $t =~ s/([A-Z]+)\(0x[0-9a-f]+\)/$1(0xdeadbeef)/g
61 if ($WANT =~ /deadbeef/);
63 # here too there are hashing order differences
64 $WANT = join("\n",sort(split(/\n/,$WANT)));
66 $t = join("\n",sort(split(/\n/,$t)));
69 print( ($t eq $WANT and not $@) ? "ok $TNUM\n"
70 : "not ok $TNUM\n--Expected--\n$WANT\n--Got--\n$@$t\n");
75 ++$TNUM; print "ok $TNUM # skip $reason\n";
76 ++$TNUM; print "ok $TNUM # skip $reason\n";
77 ++$TNUM; print "ok $TNUM # skip $reason\n";
80 # Force Data::Dumper::Dump to use perl. We test Dumpxs explicitly by calling
81 # it direct. Out here it lets us knobble the next if to test that the perl
82 # only tests do work (and count correctly)
83 $Data::Dumper::Useperl = 1;
84 if (defined &Data::Dumper::Dumpxs) {
85 print "### XS extension loaded, will run XS tests\n";
89 print "### XS extensions not loaded, will NOT run XS tests\n";
125 TEST q(Data::Dumper->Dump([$a,$b,$c], [qw(a b), 6]));
126 TEST q(Data::Dumper->Dumpxs([$a,$b,$c], [qw(a b), 6])) if $XS;
129 local $Data::Dumper::Sparseseen = 1;
130 TEST q(Data::Dumper->Dump([$a,$b,$c], [qw(a b), 6]));
131 TEST q(Data::Dumper->Dumpxs([$a,$b,$c], [qw(a b), 6])) if $XS;
154 $Data::Dumper::Purity = 1; # fill in the holes for eval
155 TEST q(Data::Dumper->Dump([$a, $b], [qw(*a b)])); # print as @a
156 TEST q(Data::Dumper->Dumpxs([$a, $b], [qw(*a b)])) if $XS;
159 local $Data::Dumper::Sparseseen = 1;
160 TEST q(Data::Dumper->Dump([$a, $b], [qw(*a b)])); # print as @a
161 TEST q(Data::Dumper->Dumpxs([$a, $b], [qw(*a b)])) if $XS;
180 #$b{'c'} = $b{'a'}[2];
184 TEST q(Data::Dumper->Dump([$b, $a], [qw(*b a)])); # print as %b
185 TEST q(Data::Dumper->Dumpxs([$b, $a], [qw(*b a)])) if $XS;
200 #$a->[1]{'b'} = $a->[1];
206 $Data::Dumper::Indent = 1;
208 $d = Data::Dumper->new([$a,$b], [qw(a b)]);
209 $d->Seen({'*c' => $c});
214 $d = Data::Dumper->new([$a,$b], [qw(a b)]);
215 $d->Seen({'*c' => $c});
243 $d->Purity(0)->Quotekeys(0);
244 TEST q( $d->Reset; $d->Dump );
246 TEST q( $d->Reset; $d->Dumpxs ) if $XS;
262 #$VAR1->[1]{'a'} = $VAR1;
263 #$VAR1->[1]{'b'} = $VAR1->[1];
264 #$VAR1->[2] = $VAR1->[1]{'c'};
268 TEST q(Data::Dumper::DumperX($a)) if $XS;
287 local $Data::Dumper::Purity = 0;
288 local $Data::Dumper::Quotekeys = 0;
289 local $Data::Dumper::Terse = 1;
291 TEST q(Data::Dumper::DumperX($a)) if $XS;
299 # "abc\0'\efg" => "mno\0",
304 $foo = { "abc\000\'\efg" => "mno\000",
308 local $Data::Dumper::Useqq = 1;
309 TEST q(Dumper($foo));
310 TEST q(Data::Dumper::DumperX($foo)) if $XS;
323 %foo = (a=>1,b=>\$foo,c=>\@foo);
345 #*::foo{ARRAY}->[1] = $foo;
346 #*::foo{ARRAY}->[2]{'b'} = *::foo{SCALAR};
347 #*::foo{ARRAY}->[2]{'c'} = *::foo{ARRAY};
348 #*::foo{ARRAY}->[2]{'d'} = *::foo{ARRAY}->[2];
349 #*::foo = *::foo{ARRAY}->[2];
350 #@bar = @{*::foo{ARRAY}};
351 #%baz = %{*::foo{ARRAY}->[2]};
354 $Data::Dumper::Purity = 1;
355 $Data::Dumper::Indent = 3;
356 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz']));
357 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz'])) if $XS;
374 #*::foo{ARRAY}->[1] = $foo;
375 #*::foo{ARRAY}->[2]{'b'} = *::foo{SCALAR};
376 #*::foo{ARRAY}->[2]{'c'} = *::foo{ARRAY};
377 #*::foo{ARRAY}->[2]{'d'} = *::foo{ARRAY}->[2];
378 #*::foo = *::foo{ARRAY}->[2];
379 #$bar = *::foo{ARRAY};
380 #$baz = *::foo{ARRAY}->[2];
383 $Data::Dumper::Indent = 1;
384 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz']));
385 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz'])) if $XS;
403 #*::foo{HASH}->{'b'} = *::foo{SCALAR};
404 #*::foo{HASH}->{'c'} = \@bar;
405 #*::foo{HASH}->{'d'} = *::foo{HASH};
406 #$bar[2] = *::foo{HASH};
407 #%baz = %{*::foo{HASH}};
411 TEST q(Data::Dumper->Dump([\\@foo, \\%foo, \\*foo], ['*bar', '*baz', '*foo']));
412 TEST q(Data::Dumper->Dumpxs([\\@foo, \\%foo, \\*foo], ['*bar', '*baz', '*foo'])) if $XS;
430 #*::foo{HASH}->{'b'} = *::foo{SCALAR};
431 #*::foo{HASH}->{'c'} = $bar;
432 #*::foo{HASH}->{'d'} = *::foo{HASH};
433 #$bar->[2] = *::foo{HASH};
434 #$baz = *::foo{HASH};
438 TEST q(Data::Dumper->Dump([\\@foo, \\%foo, \\*foo], ['bar', 'baz', 'foo']));
439 TEST q(Data::Dumper->Dumpxs([\\@foo, \\%foo, \\*foo], ['bar', 'baz', 'foo'])) if $XS;
458 $Data::Dumper::Purity = 0;
459 $Data::Dumper::Quotekeys = 0;
460 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz']));
461 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz'])) if $XS;
480 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz']));
481 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz'])) if $XS;
489 @dogs = ( 'Fido', 'Wags' );
496 $mutts = $mutts; # avoid warning
506 # ${$kennels{First}},
507 # ${$kennels{Second}},
514 $d = Data::Dumper->new([\\%kennel, \\@dogs, $mutts],
515 [qw(*kennels *dogs *mutts)] );
520 $d = Data::Dumper->new([\\%kennel, \\@dogs, $mutts],
521 [qw(*kennels *dogs *mutts)] );
529 #%kennels = %kennels;
535 TEST q($d->Dumpxs) if $XS;
545 # ${$kennels{First}},
546 # ${$kennels{Second}},
553 TEST q($d->Reset; $d->Dump);
555 TEST q($d->Reset; $d->Dumpxs);
565 # First => \$dogs[0],
566 # Second => \$dogs[1]
569 #%kennels = %{$dogs[2]};
570 #%mutts = %{$dogs[2]};
574 $d = Data::Dumper->new([\\@dogs, \\%kennel, $mutts],
575 [qw(*dogs *kennels *mutts)] );
580 $d = Data::Dumper->new([\\@dogs, \\%kennel, $mutts],
581 [qw(*dogs *kennels *mutts)] );
588 TEST q($d->Reset->Dump);
590 TEST q($d->Reset->Dumpxs);
611 $d = Data::Dumper->new( [\@dogs, \%kennel], [qw(*dogs *kennels)] );
612 $d->Deepcopy(1)->Dump;
615 TEST q($d->Reset->Dumpxs);
622 sub z { print "foo\n" }
634 TEST q(Data::Dumper->new([\&z,$c],['a','c'])->Seen({'b' => \&z})->Dump;);
635 TEST q(Data::Dumper->new([\&z,$c],['a','c'])->Seen({'b' => \&z})->Dumpxs;)
647 TEST q(Data::Dumper->new([\&z,$c],['a','c'])->Seen({'*b' => \&z})->Dump;);
648 TEST q(Data::Dumper->new([\&z,$c],['a','c'])->Seen({'*b' => \&z})->Dumpxs;)
660 TEST q(Data::Dumper->new([\&z,$c],['*a','*c'])->Seen({'*b' => \&z})->Dump;);
661 TEST q(Data::Dumper->new([\&z,$c],['*a','*c'])->Seen({'*b' => \&z})->Dumpxs;)
680 TEST q(Data::Dumper->new([$a],['*a'])->Purity(1)->Dump;);
681 TEST q(Data::Dumper->new([$a],['*a'])->Purity(1)->Dumpxs;)
696 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dump;);
697 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dumpxs;)
702 $a = [{ a => \$b }, { b => undef }];
703 $b = [{ c => \$b }, { d => \$a }];
723 #${$a->[0]{a}}->[0]->{c} = $a->[0]{a};
724 #${${$a->[0]{a}}->[1]->{d}} = $a;
728 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dump;);
729 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dumpxs;)
734 $a = [[[[\\\\\'foo']]]];
751 #$c = ${${$a->[0][0][0][0]}};
754 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Purity(1)->Dump;);
755 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Purity(1)->Dumpxs;)
774 # e => 'ARRAY(0xdeadbeef)'
783 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(4)->Dump;);
784 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(4)->Dumpxs;)
791 # b => 'HASH(0xdeadbeef)'
799 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(1)->Dump;);
800 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(1)->Dumpxs;)
816 TEST q(Data::Dumper->new([$b],['b'])->Purity(0)->Dump;);
817 TEST q(Data::Dumper->new([$b],['b'])->Purity(0)->Dumpxs;)
826 #${$b->[0]} = $b->[0];
830 TEST q(Data::Dumper->new([$b],['b'])->Purity(1)->Dump;);
831 TEST q(Data::Dumper->new([$b],['b'])->Purity(1)->Dumpxs;)
838 ## XS code was adding an extra \0
844 TEST q(Data::Dumper->Dump([$a], ['a'])), "\\x{9c10}";
846 SKIP_TEST "Incomplete support for UTF-8 in old perls";
848 TEST q(Data::Dumper->Dumpxs([$a], ['a'])), "XS \\x{9c10}"
854 $a = { map { ("$_$_$_", ++$i) } 'I'..'Q' };
872 TEST q(Data::Dumper->new([$a])->Dump;);
873 TEST q(Data::Dumper->new([$a])->Dumpxs;)
879 $c = { map { (++$i, "$_$_$_") } 'I'..'Q' };
880 local $Data::Dumper::Sortkeys = \&sort199;
883 return [ sort { $b <=> $a } keys %$hash ];
902 TEST q(Data::Dumper->new([$c])->Dump;), "sortkeys sub";
903 TEST q(Data::Dumper->new([$c])->Dumpxs;), "sort keys sub (XS)"
909 $c = { map { (++$i, "$_$_$_") } 'I'..'Q' };
910 $d = { reverse %$c };
911 local $Data::Dumper::Sortkeys = \&sort205;
915 $hash eq $c ? (sort { $a <=> $b } keys %$hash)
916 : (reverse sort keys %$hash)
949 TEST q(Data::Dumper->new([[$c, $d]])->Dump;), "more sortkeys sub";
950 # the XS code does number values as strings
951 $WANT =~ s/ (\d+)(,?)$/ '$1'$2/gm;
952 TEST q(Data::Dumper->new([[$c, $d]])->Dumpxs;), "more sortkeys sub (XS)"
957 local $Data::Dumper::Deparse = 1;
958 local $Data::Dumper::Indent = 2;
970 if(" $Config{'extensions'} " !~ m[ B ]) {
971 SKIP_TEST "Perl configured without B module";
973 TEST q(Data::Dumper->new([{ foo => sub { print "foo"; } }])->Dump);
981 # The controls (bare numbers) are stored either as integers or floating point.
982 # [depending on whether the tokeniser sees things like ".".
983 # The peephole optimiser only runs for constant folding, not single constants,
984 # so I already have some NVs, some IVs
985 # The string versions are not. They are all PV
987 # This is arguably all far too chummy with the implementation, but I really
988 # want to ensure that we don't go wrong when flags on scalars get as side
989 # effects of reading them.
991 # These tests are actually testing the precise output of the current
992 # implementation, so will most likely fail if the implementation changes,
993 # even if the new implementation produces different but correct results.
994 # It would be nice to test for wrong answers, but I can't see how to do that,
995 # so instead I'm checking for unexpected answers. (ie -2 becoming "-2" is not
996 # wrong, but I can't see an easy, reliable way to code that knowledge)
998 # Numbers (seen by the tokeniser as numbers, stored as numbers.
1001 0, +1, -2, 3.0, +4.0, -5.0, 6.5, +7.5, -8.5,
1002 9, +10, -11, 12.0, +13.0, -14.0, 15.5, +16.25, -17.75,
1007 "0", "+1", "-2", "3.0", "+4.0", "-5.0", "6.5", "+7.5", "-8.5", " 9",
1008 " +10", " -11", " 12.0", " +13.0", " -14.0", " 15.5", " +16.25", " -17.75",
1011 # The perl code always does things the same way for numbers.
1012 $WANT_PL_N = <<'EOT';
1032 # The perl code knows that 0 and -2 stringify exactly back to the strings,
1033 # so it dumps them as numbers, not strings.
1034 $WANT_PL_S = <<'EOT';
1051 #$VAR17 = ' +16.25';
1052 #$VAR18 = ' -17.75';
1055 # The XS code differs.
1056 # These are the numbers as seen by the tokeniser. Constants aren't folded
1057 # (which makes IVs where possible) so values the tokeniser thought were
1058 # floating point are stored as NVs. The XS code outputs these as strings,
1059 # but as it has converted them from NVs, leading + signs will not be there.
1060 $WANT_XS_N = <<'EOT';
1081 # These are the strings as seen by the tokeniser. The XS code will output
1082 # these for all cases except where the scalar has been used in integer context
1083 $WANT_XS_S = <<'EOT';
1100 #$VAR17 = ' +16.25';
1101 #$VAR18 = ' -17.75';
1104 # These are the numbers as IV-ized by &
1105 # These will differ from WANT_XS_N because now IV flags will be set on all
1106 # values that were actually integer, and the XS code will then output these
1107 # as numbers not strings.
1108 $WANT_XS_I = <<'EOT';
1129 # Some of these tests will be redundant.
1130 @numbers_s = @numbers_i = @numbers_is = @numbers_n = @numbers_ns = @numbers_ni
1131 = @numbers_nis = @numbers;
1132 @strings_s = @strings_i = @strings_is = @strings_n = @strings_ns = @strings_ni
1133 = @strings_nis = @strings;
1134 # Use them in an integer context
1135 foreach (@numbers_i, @numbers_ni, @numbers_nis, @numbers_is,
1136 @strings_i, @strings_ni, @strings_nis, @strings_is) {
1137 my $b = sprintf "%d", $_;
1139 # Use them in a floating point context
1140 foreach (@numbers_n, @numbers_ni, @numbers_nis, @numbers_ns,
1141 @strings_n, @strings_ni, @strings_nis, @strings_ns) {
1142 my $b = sprintf "%e", $_;
1144 # Use them in a string context
1145 foreach (@numbers_s, @numbers_is, @numbers_nis, @numbers_ns,
1146 @strings_s, @strings_is, @strings_nis, @strings_ns) {
1147 my $b = sprintf "%s", $_;
1150 # use Devel::Peek; Dump ($_) foreach @vanilla_c;
1153 TEST q(Data::Dumper->new(\@numbers)->Dump), 'Numbers';
1154 TEST q(Data::Dumper->new(\@numbers_s)->Dump), 'Numbers PV';
1155 TEST q(Data::Dumper->new(\@numbers_i)->Dump), 'Numbers IV';
1156 TEST q(Data::Dumper->new(\@numbers_is)->Dump), 'Numbers IV,PV';
1157 TEST q(Data::Dumper->new(\@numbers_n)->Dump), 'Numbers NV';
1158 TEST q(Data::Dumper->new(\@numbers_ns)->Dump), 'Numbers NV,PV';
1159 TEST q(Data::Dumper->new(\@numbers_ni)->Dump), 'Numbers NV,IV';
1160 TEST q(Data::Dumper->new(\@numbers_nis)->Dump), 'Numbers NV,IV,PV';
1162 TEST q(Data::Dumper->new(\@strings)->Dump), 'Strings';
1163 TEST q(Data::Dumper->new(\@strings_s)->Dump), 'Strings PV';
1164 TEST q(Data::Dumper->new(\@strings_i)->Dump), 'Strings IV';
1165 TEST q(Data::Dumper->new(\@strings_is)->Dump), 'Strings IV,PV';
1166 TEST q(Data::Dumper->new(\@strings_n)->Dump), 'Strings NV';
1167 TEST q(Data::Dumper->new(\@strings_ns)->Dump), 'Strings NV,PV';
1168 TEST q(Data::Dumper->new(\@strings_ni)->Dump), 'Strings NV,IV';
1169 TEST q(Data::Dumper->new(\@strings_nis)->Dump), 'Strings NV,IV,PV';
1171 my $nv_preserves_uv = defined $Config{d_nv_preserves_uv};
1172 my $nv_preserves_uv_4bits = exists($Config{nv_preserves_uv_bits}) && $Config{nv_preserves_uv_bits} >= 4;
1174 TEST q(Data::Dumper->new(\@numbers)->Dumpxs), 'XS Numbers';
1175 TEST q(Data::Dumper->new(\@numbers_s)->Dumpxs), 'XS Numbers PV';
1176 if ($nv_preserves_uv || $nv_preserves_uv_4bits) {
1178 TEST q(Data::Dumper->new(\@numbers_i)->Dumpxs), 'XS Numbers IV';
1179 TEST q(Data::Dumper->new(\@numbers_is)->Dumpxs), 'XS Numbers IV,PV';
1181 SKIP_TEST "NV does not preserve 4bits";
1182 SKIP_TEST "NV does not preserve 4bits";
1185 TEST q(Data::Dumper->new(\@numbers_n)->Dumpxs), 'XS Numbers NV';
1186 TEST q(Data::Dumper->new(\@numbers_ns)->Dumpxs), 'XS Numbers NV,PV';
1187 if ($nv_preserves_uv || $nv_preserves_uv_4bits) {
1189 TEST q(Data::Dumper->new(\@numbers_ni)->Dumpxs), 'XS Numbers NV,IV';
1190 TEST q(Data::Dumper->new(\@numbers_nis)->Dumpxs), 'XS Numbers NV,IV,PV';
1192 SKIP_TEST "NV does not preserve 4bits";
1193 SKIP_TEST "NV does not preserve 4bits";
1197 TEST q(Data::Dumper->new(\@strings)->Dumpxs), 'XS Strings';
1198 TEST q(Data::Dumper->new(\@strings_s)->Dumpxs), 'XS Strings PV';
1199 # This one used to really mess up. New code actually emulates the .pm code
1201 TEST q(Data::Dumper->new(\@strings_i)->Dumpxs), 'XS Strings IV';
1202 TEST q(Data::Dumper->new(\@strings_is)->Dumpxs), 'XS Strings IV,PV';
1203 if ($nv_preserves_uv || $nv_preserves_uv_4bits) {
1205 TEST q(Data::Dumper->new(\@strings_n)->Dumpxs), 'XS Strings NV';
1206 TEST q(Data::Dumper->new(\@strings_ns)->Dumpxs), 'XS Strings NV,PV';
1208 SKIP_TEST "NV does not preserve 4bits";
1209 SKIP_TEST "NV does not preserve 4bits";
1211 # This one used to really mess up. New code actually emulates the .pm code
1213 TEST q(Data::Dumper->new(\@strings_ni)->Dumpxs), 'XS Strings NV,IV';
1214 TEST q(Data::Dumper->new(\@strings_nis)->Dumpxs), 'XS Strings NV,IV,PV';
1220 ## Perl code was using /...$/ and hence missing the \n.
1226 # Can't pad with # as the output has an embedded newline.
1227 local $Data::Dumper::Pad = "my ";
1228 TEST q(Data::Dumper->Dump(["42\n"])), "number with trailing newline";
1229 TEST q(Data::Dumper->Dumpxs(["42\n"])), "XS number with trailing newline"
1249 ## Perl code flips over at 10 digits.
1252 #$VAR2 = '1000000000';
1253 #$VAR3 = '9999999999';
1254 #$VAR4 = '10000000000';
1255 #$VAR5 = -999999999;
1256 #$VAR6 = '-1000000000';
1257 #$VAR7 = '-9999999999';
1258 #$VAR8 = '-10000000000';
1259 #$VAR9 = '4294967295';
1260 #$VAR10 = '4294967296';
1261 #$VAR11 = '-2147483648';
1262 #$VAR12 = '-2147483649';
1265 TEST q(Data::Dumper->Dump(\@a)), "long integers";
1268 ## XS code flips over at 11 characters ("-" is a char) or larger than int.
1269 if (~0 == 0xFFFFFFFF) {
1273 #$VAR2 = 1000000000;
1274 #$VAR3 = '9999999999';
1275 #$VAR4 = '10000000000';
1276 #$VAR5 = -999999999;
1277 #$VAR6 = '-1000000000';
1278 #$VAR7 = '-9999999999';
1279 #$VAR8 = '-10000000000';
1280 #$VAR9 = 4294967295;
1281 #$VAR10 = '4294967296';
1282 #$VAR11 = '-2147483648';
1283 #$VAR12 = '-2147483649';
1288 #$VAR2 = 1000000000;
1289 #$VAR3 = 9999999999;
1290 #$VAR4 = '10000000000';
1291 #$VAR5 = -999999999;
1292 #$VAR6 = '-1000000000';
1293 #$VAR7 = '-9999999999';
1294 #$VAR8 = '-10000000000';
1295 #$VAR9 = 4294967295;
1296 #$VAR10 = 4294967296;
1297 #$VAR11 = '-2147483648';
1298 #$VAR12 = '-2147483649';
1301 TEST q(Data::Dumper->Dumpxs(\@a)), "XS long integers";
1308 $b = "Bad. XS didn't escape dollar sign";
1310 $WANT = <<"EOT"; # Careful. This is '' string written inside '' here doc
1311 #\$VAR1 = '\$b\"\@\\\\\xB1';
1313 $a = "\$b\"\@\\\xB1\x{100}";
1315 TEST q(Data::Dumper->Dump([$a])), "utf8 flag with \" and \$";
1317 $WANT = <<'EOT'; # While this is "" string written inside "" here doc
1318 #$VAR1 = "\$b\"\@\\\x{b1}";
1320 TEST q(Data::Dumper->Dumpxs([$a])), "XS utf8 flag with \" and \$";
1323 $b = "Bad. XS didn't escape dollar sign";
1325 $WANT = <<"EOT"; # Careful. This is '' string written inside '' here doc
1326 #\$VAR1 = '\$b\"\@\\\\\xA3';
1329 $a = "\$b\"\@\\\xA3\x{100}";
1331 TEST q(Data::Dumper->Dump([$a])), "utf8 flag with \" and \$";
1333 $WANT = <<'EOT'; # While this is "" string written inside "" here doc
1334 #$VAR1 = "\$b\"\@\\\x{a3}";
1336 TEST q(Data::Dumper->Dumpxs([$a])), "XS utf8 flag with \" and \$";
1339 # XS used to produce "$b\"' which is 4 chars, not 3. [ie wrongly qq(\$b\\\")]
1345 $a = "\$b\"\x{100}";
1347 TEST q(Data::Dumper->Dump([$a])), "utf8 flag with \" and \$";
1349 TEST q(Data::Dumper->Dumpxs([$a])), "XS utf8 flag with \" and \$";
1353 # XS used to produce 'D'oh!' which is well, D'oh!
1354 # Andreas found this one, which in turn discovered the previous two.
1360 $a = "D'oh!\x{100}";
1362 TEST q(Data::Dumper->Dump([$a])), "utf8 flag with '";
1364 TEST q(Data::Dumper->Dumpxs([$a])), "XS utf8 flag with '";
1368 # Jarkko found that -Mutf8 caused some tests to fail. Turns out that there
1369 # was an otherwise untested code path in the XS for utf8 hash keys with purity
1377 # "\x{decaf}\x{decaf}\x{decaf}\x{decaf}" => do{my $o}
1379 #*::ping{HASH}->{"\x{decaf}\x{decaf}\x{decaf}\x{decaf}"} = *::ping{SCALAR};
1380 #%pong = %{*::ping{HASH}};
1382 local $Data::Dumper::Purity = 1;
1383 local $Data::Dumper::Sortkeys;
1385 %ping = (chr (0xDECAF) x 4 =>\$ping);
1386 for $Data::Dumper::Sortkeys (0, 1) {
1388 TEST q(Data::Dumper->Dump([\\*ping, \\%ping], ['*ping', '*pong']));
1389 TEST q(Data::Dumper->Dumpxs([\\*ping, \\%ping], ['*ping', '*pong'])) if $XS;
1391 SKIP_TEST "Incomplete support for UTF-8 in old perls";
1392 SKIP_TEST "Incomplete support for UTF-8 in old perls";
1397 # XS for quotekeys==0 was not being defensive enough against utf8 flagged
1406 local $Data::Dumper::Quotekeys = 0;
1407 my $k = 'perl' . chr 256;
1409 %foo = ($k => 'rocks');
1411 TEST q(Data::Dumper->Dump([\\%foo])), "quotekeys == 0 for utf8 flagged ASCII";
1412 TEST q(Data::Dumper->Dumpxs([\\%foo])),
1413 "XS quotekeys == 0 for utf8 flagged ASCII" if $XS;
1426 TEST q(Data::Dumper->Dump([\@foo])), 'Richard Clamp, Message-Id: <20030104005247.GA27685@mirth.demon.co.uk>';
1427 TEST q(Data::Dumper->Dumpxs([\@foo])) if $XS;
1431 # Make sure $obj->Dumpxs returns the right thing in list context. This was
1432 # broken by the initial attempt to fix [perl #74170].
1436 TEST q(join " ", new Data::Dumper [[]],[] =>->Dumpxs),
1437 '$obj->Dumpxs in list context'
1444 # "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37 !\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"
1448 $foo = [ join "", map chr, 0..255 ];
1449 local $Data::Dumper::Useqq = 1;
1450 TEST q(Dumper($foo)), 'All latin1 characters';
1451 TEST q(Data::Dumper::DumperX($foo)) if $XS;
1458 # "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37 !\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\x{80}\x{81}\x{82}\x{83}\x{84}\x{85}\x{86}\x{87}\x{88}\x{89}\x{8a}\x{8b}\x{8c}\x{8d}\x{8e}\x{8f}\x{90}\x{91}\x{92}\x{93}\x{94}\x{95}\x{96}\x{97}\x{98}\x{99}\x{9a}\x{9b}\x{9c}\x{9d}\x{9e}\x{9f}\x{a0}\x{a1}\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}\x{a7}\x{a8}\x{a9}\x{aa}\x{ab}\x{ac}\x{ad}\x{ae}\x{af}\x{b0}\x{b1}\x{b2}\x{b3}\x{b4}\x{b5}\x{b6}\x{b7}\x{b8}\x{b9}\x{ba}\x{bb}\x{bc}\x{bd}\x{be}\x{bf}\x{c0}\x{c1}\x{c2}\x{c3}\x{c4}\x{c5}\x{c6}\x{c7}\x{c8}\x{c9}\x{ca}\x{cb}\x{cc}\x{cd}\x{ce}\x{cf}\x{d0}\x{d1}\x{d2}\x{d3}\x{d4}\x{d5}\x{d6}\x{d7}\x{d8}\x{d9}\x{da}\x{db}\x{dc}\x{dd}\x{de}\x{df}\x{e0}\x{e1}\x{e2}\x{e3}\x{e4}\x{e5}\x{e6}\x{e7}\x{e8}\x{e9}\x{ea}\x{eb}\x{ec}\x{ed}\x{ee}\x{ef}\x{f0}\x{f1}\x{f2}\x{f3}\x{f4}\x{f5}\x{f6}\x{f7}\x{f8}\x{f9}\x{fa}\x{fb}\x{fc}\x{fd}\x{fe}\x{ff}\x{20ac}"
1462 $foo = [ join "", map chr, 0..255, 0x20ac ];
1463 local $Data::Dumper::Useqq = 1;
1465 print "not ok " . (++$TNUM) . " # TODO - fails under 5.6\n" for 1..3;
1468 TEST q(Dumper($foo)),
1469 'All latin1 characters with utf8 flag including a wide character';
1471 TEST q(Data::Dumper::DumperX($foo)) if $XS;
1476 # If XS cannot load, the pure-Perl version cannot deparse vstrings with
1477 # underscores properly. In 5.8.0, vstrings are just strings.
1478 my $no_vstrings = <<'NOVSTRINGS';
1484 my $vstrings_corr = <<'VSTRINGS_CORRECT';
1490 $WANT = $] <= 5.0080001
1496 \($] < 5.007 ? v65.66.67 : eval 'v65.66.067'),
1501 TEST q(Data::Dumper->Dump(\@::_v, [qw(a b c d)])), 'vstrings';
1502 TEST q(Data::Dumper->Dumpxs(\@::_v, [qw(a b c d)])), 'xs vstrings'
1505 else { # Skip tests before 5.10. vstrings considered funny before
1506 SKIP_TEST "vstrings considered funny before 5.10.0";
1507 SKIP_TEST "vstrings considered funny before 5.10.0 (XS)"
1514 # [perl #107372] blessed overloaded globs
1516 #$VAR1 = bless( \*::finkle, 'overtest' );
1520 use overload fallback=>1, q\""\=>sub{"oaoaa"};
1522 TEST q(Data::Dumper->Dump([bless \*finkle, "overtest"])),
1523 'blessed overloaded globs';
1524 TEST q(Data::Dumper->Dumpxs([\*finkle])), 'blessed overloaded globs (xs)'
1529 # [perl #74798] uncovered behaviour
1533 local $Data::Dumper::Useqq = 1;
1534 TEST q(Data::Dumper->Dump(["\x000"])),
1535 "\\ octal followed by digit";
1536 TEST q(Data::Dumper->Dumpxs(["\x000"])), '\\ octal followed by digit (xs)'
1540 #$VAR1 = "\x{100}\0000";
1542 local $Data::Dumper::Useqq = 1;
1543 TEST q(Data::Dumper->Dump(["\x{100}\x000"])),
1544 "\\ octal followed by digit unicode";
1545 TEST q(Data::Dumper->Dumpxs(["\x{100}\x000"])), '\\ octal followed by digit unicode (xs)'
1550 #$VAR1 = "\0\x{660}";
1552 TEST q(Data::Dumper->Dump(["\\x00\\x{0660}"])),
1553 "\\ octal followed by unicode digit";
1554 TEST q(Data::Dumper->Dumpxs(["\\x00\\x{0660}"])), '\\ octal followed by unicode digit (xs)'
1557 # [perl #118933 - handling of digits
1565 #$VAR7 = "1234567890";
1567 TEST q(Data::Dumper->Dump([0, 1, 90, -10, "010", "112345678", "1234567890" ])),
1568 "numbers and number-like scalars";
1570 TEST q(Data::Dumper->Dumpxs([0, 1, 90, -10, "010", "112345678", "1234567890" ])),
1571 "numbers and number-like scalars"
1577 # re::regexp_pattern was moved to universal.c in v5.10.0-252-g192c1e2
1578 # and apparently backported to maint-5.10
1579 $WANT = $] > 5.010 ? <<'NEW' : <<'OLD';
1583 #$VAR1 = qr/(?-xism:abc)/;
1584 #$VAR2 = qr/(?i-xsm:abc)/;
1586 TEST q(Data::Dumper->Dump([ qr/abc/, qr/abc/i ])), "qr//";
1587 TEST q(Data::Dumper->Dumpxs([ qr/abc/, qr/abc/i ])), "qr// xs"