3 # testsuite for Data::Dumper
9 require Config; import Config;
10 if ($Config{'extensions'} !~ /\bData\/Dumper\b/) {
11 print "1..0 # Skip: Data::Dumper was not built\n";
16 # Since Perl 5.8.1 because otherwise hash ordering is really random.
17 local $Data::Dumper::Sortkeys = 1;
21 my $Is_ebcdic = defined($Config{'ebcdic'}) && $Config{'ebcdic'} eq 'define';
23 $Data::Dumper::Pad = "#";
34 $t =~ s/([A-Z]+)\(0x[0-9a-f]+\)/$1(0xdeadbeef)/g
35 if ($WANT =~ /deadbeef/);
37 # these data need massaging with non ascii character sets
38 # because of hashing order differences
39 $WANT = join("\n",sort(split(/\n/,$WANT)));
41 $t = join("\n",sort(split(/\n/,$t)));
44 $name = $name ? " - $name" : '';
45 print( ($t eq $WANT and not $@) ? "ok $TNUM$name\n"
46 : "not ok $TNUM$name\n--Expected--\n$WANT\n--Got--\n$@$t\n");
50 print $@ ? "not ok $TNUM\n# \$@ says: $@\n" : "ok $TNUM\n";
54 $t =~ s/([A-Z]+)\(0x[0-9a-f]+\)/$1(0xdeadbeef)/g
55 if ($WANT =~ /deadbeef/);
57 # here too there are hashing order differences
58 $WANT = join("\n",sort(split(/\n/,$WANT)));
60 $t = join("\n",sort(split(/\n/,$t)));
63 print( ($t eq $WANT and not $@) ? "ok $TNUM\n"
64 : "not ok $TNUM\n--Expected--\n$WANT\n--Got--\n$@$t\n");
67 # Force Data::Dumper::Dump to use perl. We test Dumpxs explicitly by calling
68 # it direct. Out here it lets us knobble the next if to test that the perl
69 # only tests do work (and count correctly)
70 $Data::Dumper::Useperl = 1;
71 if (defined &Data::Dumper::Dumpxs) {
72 print "### XS extension loaded, will run XS tests\n";
76 print "### XS extensions not loaded, will NOT run XS tests\n";
112 TEST q(Data::Dumper->Dump([$a,$b,$c], [qw(a b c)]));
113 TEST q(Data::Dumper->Dumpxs([$a,$b,$c], [qw(a b c)])) if $XS;
136 $Data::Dumper::Purity = 1; # fill in the holes for eval
137 TEST q(Data::Dumper->Dump([$a, $b], [qw(*a b)])); # print as @a
138 TEST q(Data::Dumper->Dumpxs([$a, $b], [qw(*a b)])) if $XS;
156 #$b{'c'} = $b{'a'}[2];
160 TEST q(Data::Dumper->Dump([$b, $a], [qw(*b a)])); # print as %b
161 TEST q(Data::Dumper->Dumpxs([$b, $a], [qw(*b a)])) if $XS;
176 #$a->[1]{'b'} = $a->[1];
182 $Data::Dumper::Indent = 1;
184 $d = Data::Dumper->new([$a,$b], [qw(a b)]);
185 $d->Seen({'*c' => $c});
190 $d = Data::Dumper->new([$a,$b], [qw(a b)]);
191 $d->Seen({'*c' => $c});
219 $d->Purity(0)->Quotekeys(0);
220 TEST q( $d->Reset; $d->Dump );
222 TEST q( $d->Reset; $d->Dumpxs ) if $XS;
238 #$VAR1->[1]{'a'} = $VAR1;
239 #$VAR1->[1]{'b'} = $VAR1->[1];
240 #$VAR1->[2] = $VAR1->[1]{'c'};
244 TEST q(Data::Dumper::DumperX($a)) if $XS;
263 local $Data::Dumper::Purity = 0;
264 local $Data::Dumper::Quotekeys = 0;
265 local $Data::Dumper::Terse = 1;
267 TEST q(Data::Dumper::DumperX($a)) if $XS;
275 # "abc\0'\efg" => "mno\0",
280 $foo = { "abc\000\'\efg" => "mno\000",
284 local $Data::Dumper::Useqq = 1;
285 TEST q(Dumper($foo));
290 # 'abc\0\\'\efg' => 'mno\0',
296 local $Data::Dumper::Useqq = 1;
297 TEST q(Data::Dumper::DumperX($foo)) if $XS; # cheat
310 %foo = (a=>1,b=>\$foo,c=>\@foo);
332 #*::foo{ARRAY}->[1] = $foo;
333 #*::foo{ARRAY}->[2]{'b'} = *::foo{SCALAR};
334 #*::foo{ARRAY}->[2]{'c'} = *::foo{ARRAY};
335 #*::foo{ARRAY}->[2]{'d'} = *::foo{ARRAY}->[2];
336 #*::foo = *::foo{ARRAY}->[2];
337 #@bar = @{*::foo{ARRAY}};
338 #%baz = %{*::foo{ARRAY}->[2]};
341 $Data::Dumper::Purity = 1;
342 $Data::Dumper::Indent = 3;
343 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz']));
344 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz'])) if $XS;
361 #*::foo{ARRAY}->[1] = $foo;
362 #*::foo{ARRAY}->[2]{'b'} = *::foo{SCALAR};
363 #*::foo{ARRAY}->[2]{'c'} = *::foo{ARRAY};
364 #*::foo{ARRAY}->[2]{'d'} = *::foo{ARRAY}->[2];
365 #*::foo = *::foo{ARRAY}->[2];
366 #$bar = *::foo{ARRAY};
367 #$baz = *::foo{ARRAY}->[2];
370 $Data::Dumper::Indent = 1;
371 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz']));
372 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz'])) if $XS;
390 #*::foo{HASH}->{'b'} = *::foo{SCALAR};
391 #*::foo{HASH}->{'c'} = \@bar;
392 #*::foo{HASH}->{'d'} = *::foo{HASH};
393 #$bar[2] = *::foo{HASH};
394 #%baz = %{*::foo{HASH}};
398 TEST q(Data::Dumper->Dump([\\@foo, \\%foo, \\*foo], ['*bar', '*baz', '*foo']));
399 TEST q(Data::Dumper->Dumpxs([\\@foo, \\%foo, \\*foo], ['*bar', '*baz', '*foo'])) if $XS;
417 #*::foo{HASH}->{'b'} = *::foo{SCALAR};
418 #*::foo{HASH}->{'c'} = $bar;
419 #*::foo{HASH}->{'d'} = *::foo{HASH};
420 #$bar->[2] = *::foo{HASH};
421 #$baz = *::foo{HASH};
425 TEST q(Data::Dumper->Dump([\\@foo, \\%foo, \\*foo], ['bar', 'baz', 'foo']));
426 TEST q(Data::Dumper->Dumpxs([\\@foo, \\%foo, \\*foo], ['bar', 'baz', 'foo'])) if $XS;
445 $Data::Dumper::Purity = 0;
446 $Data::Dumper::Quotekeys = 0;
447 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz']));
448 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['*foo', '*bar', '*baz'])) if $XS;
467 TEST q(Data::Dumper->Dump([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz']));
468 TEST q(Data::Dumper->Dumpxs([\\*foo, \\@foo, \\%foo], ['foo', 'bar', 'baz'])) if $XS;
476 @dogs = ( 'Fido', 'Wags' );
483 $mutts = $mutts; # avoid warning
493 # ${$kennels{First}},
494 # ${$kennels{Second}},
501 $d = Data::Dumper->new([\\%kennel, \\@dogs, $mutts],
502 [qw(*kennels *dogs *mutts)] );
507 $d = Data::Dumper->new([\\%kennel, \\@dogs, $mutts],
508 [qw(*kennels *dogs *mutts)] );
516 #%kennels = %kennels;
522 TEST q($d->Dumpxs) if $XS;
532 # ${$kennels{First}},
533 # ${$kennels{Second}},
540 TEST q($d->Reset; $d->Dump);
542 TEST q($d->Reset; $d->Dumpxs);
552 # First => \$dogs[0],
553 # Second => \$dogs[1]
556 #%kennels = %{$dogs[2]};
557 #%mutts = %{$dogs[2]};
561 $d = Data::Dumper->new([\\@dogs, \\%kennel, $mutts],
562 [qw(*dogs *kennels *mutts)] );
567 $d = Data::Dumper->new([\\@dogs, \\%kennel, $mutts],
568 [qw(*dogs *kennels *mutts)] );
575 TEST q($d->Reset->Dump);
577 TEST q($d->Reset->Dumpxs);
598 $d = Data::Dumper->new( [\@dogs, \%kennel], [qw(*dogs *kennels)] );
599 $d->Deepcopy(1)->Dump;
602 TEST q($d->Reset->Dumpxs);
609 sub z { print "foo\n" }
621 TEST q(Data::Dumper->new([\&z,$c],['a','c'])->Seen({'b' => \&z})->Dump;);
622 TEST q(Data::Dumper->new([\&z,$c],['a','c'])->Seen({'b' => \&z})->Dumpxs;)
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;)
667 TEST q(Data::Dumper->new([$a],['*a'])->Purity(1)->Dump;);
668 TEST q(Data::Dumper->new([$a],['*a'])->Purity(1)->Dumpxs;)
683 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dump;);
684 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dumpxs;)
689 $a = [{ a => \$b }, { b => undef }];
690 $b = [{ c => \$b }, { d => \$a }];
710 #${$a->[0]{a}}->[0]->{c} = $a->[0]{a};
711 #${${$a->[0]{a}}->[1]->{d}} = $a;
715 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dump;);
716 TEST q(Data::Dumper->new([$a,$b],['a','b'])->Purity(1)->Dumpxs;)
721 $a = [[[[\\\\\'foo']]]];
738 #$c = ${${$a->[0][0][0][0]}};
741 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Purity(1)->Dump;);
742 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Purity(1)->Dumpxs;)
761 # e => 'ARRAY(0xdeadbeef)'
770 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(4)->Dump;);
771 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(4)->Dumpxs;)
778 # b => 'HASH(0xdeadbeef)'
786 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(1)->Dump;);
787 TEST q(Data::Dumper->new([$a,$b,$c],['a','b','c'])->Maxdepth(1)->Dumpxs;)
803 TEST q(Data::Dumper->new([$b],['b'])->Purity(0)->Dump;);
804 TEST q(Data::Dumper->new([$b],['b'])->Purity(0)->Dumpxs;)
813 #${$b->[0]} = $b->[0];
817 TEST q(Data::Dumper->new([$b],['b'])->Purity(1)->Dump;);
818 TEST q(Data::Dumper->new([$b],['b'])->Purity(1)->Dumpxs;)
825 ## XS code was adding an extra \0
830 TEST q(Data::Dumper->Dump([$a], ['a'])), "\\x{9c10}";
831 TEST q(Data::Dumper->Dumpxs([$a], ['a'])), "XS \\x{9c10}"
838 $a = { map { ("$_$_$_", ++$i) } 'I'..'Q' };
856 TEST q(Data::Dumper->new([$a])->Dump;);
857 TEST q(Data::Dumper->new([$a])->Dumpxs;)
863 $c = { map { (++$i, "$_$_$_") } 'I'..'Q' };
864 local $Data::Dumper::Sortkeys = \&sort199;
867 return [ sort { $b <=> $a } keys %$hash ];
886 # perl code does keys and values as numbers if possible
887 TEST q(Data::Dumper->new([$c])->Dump;);
888 # XS code always does them as strings
889 $WANT =~ s/ (\d+)/ '$1'/gs;
890 TEST q(Data::Dumper->new([$c])->Dumpxs;)
896 $c = { map { (++$i, "$_$_$_") } 'I'..'Q' };
897 $d = { reverse %$c };
898 local $Data::Dumper::Sortkeys = \&sort205;
902 $hash eq $c ? (sort { $a <=> $b } keys %$hash)
903 : (reverse sort keys %$hash)
936 TEST q(Data::Dumper->new([[$c, $d]])->Dump;);
937 $WANT =~ s/ (\d+)/ '$1'/gs;
938 TEST q(Data::Dumper->new([[$c, $d]])->Dumpxs;)
943 local $Data::Dumper::Deparse = 1;
944 local $Data::Dumper::Indent = 2;
956 TEST q(Data::Dumper->new([{ foo => sub { print "foo"; } }])->Dump);
963 # The controls (bare numbers) are stored either as integers or floating point.
964 # [depending on whether the tokeniser sees things like ".".
965 # The peephole optimiser only runs for constant folding, not single constants,
966 # so I already have some NVs, some IVs
967 # The string versions are not. They are all PV
969 # This is arguably all far too chummy with the implementation, but I really
970 # want to ensure that we don't go wrong when flags on scalars get as side
971 # effects of reading them.
973 # These tests are actually testing the precise output of the current
974 # implementation, so will most likely fail if the implementation changes,
975 # even if the new implementation produces different but correct results.
976 # It would be nice to test for wrong answers, but I can't see how to do that,
977 # so instead I'm checking for unexpected answers. (ie -2 becoming "-2" is not
978 # wrong, but I can't see an easy, reliable way to code that knowledge)
980 # Numbers (seen by the tokeniser as numbers, stored as numbers.
983 0, +1, -2, 3.0, +4.0, -5.0, 6.5, +7.5, -8.5,
984 9, +10, -11, 12.0, +13.0, -14.0, 15.5, +16.25, -17.75,
989 "0", "+1", "-2", "3.0", "+4.0", "-5.0", "6.5", "+7.5", "-8.5", " 9",
990 " +10", " -11", " 12.0", " +13.0", " -14.0", " 15.5", " +16.25", " -17.75",
993 # The perl code always does things the same way for numbers.
994 $WANT_PL_N = <<'EOT';
1014 # The perl code knows that 0 and -2 stringify exactly back to the strings,
1015 # so it dumps them as numbers, not strings.
1016 $WANT_PL_S = <<'EOT';
1033 #$VAR17 = ' +16.25';
1034 #$VAR18 = ' -17.75';
1037 # The XS code differs.
1038 # These are the numbers as seen by the tokeniser. Constants aren't folded
1039 # (which makes IVs where possible) so values the tokeniser thought were
1040 # floating point are stored as NVs. The XS code outputs these as strings,
1041 # but as it has converted them from NVs, leading + signs will not be there.
1042 $WANT_XS_N = <<'EOT';
1063 # These are the strings as seen by the tokeniser. The XS code will output
1064 # these for all cases except where the scalar has been used in integer context
1065 $WANT_XS_S = <<'EOT';
1082 #$VAR17 = ' +16.25';
1083 #$VAR18 = ' -17.75';
1086 # These are the numbers as IV-ized by &
1087 # These will differ from WANT_XS_N because now IV flags will be set on all
1088 # values that were actually integer, and the XS code will then output these
1089 # as numbers not strings.
1090 $WANT_XS_I = <<'EOT';
1111 # Some of these tests will be redundant.
1112 @numbers_s = @numbers_i = @numbers_is = @numbers_n = @numbers_ns = @numbers_ni
1113 = @numbers_nis = @numbers;
1114 @strings_s = @strings_i = @strings_is = @strings_n = @strings_ns = @strings_ni
1115 = @strings_nis = @strings;
1116 # Use them in an integer context
1117 foreach (@numbers_i, @numbers_ni, @numbers_nis, @numbers_is,
1118 @strings_i, @strings_ni, @strings_nis, @strings_is) {
1119 my $b = sprintf "%d", $_;
1121 # Use them in a floating point context
1122 foreach (@numbers_n, @numbers_ni, @numbers_nis, @numbers_ns,
1123 @strings_n, @strings_ni, @strings_nis, @strings_ns) {
1124 my $b = sprintf "%e", $_;
1126 # Use them in a string context
1127 foreach (@numbers_s, @numbers_is, @numbers_nis, @numbers_ns,
1128 @strings_s, @strings_is, @strings_nis, @strings_ns) {
1129 my $b = sprintf "%s", $_;
1132 # use Devel::Peek; Dump ($_) foreach @vanilla_c;
1135 TEST q(Data::Dumper->new(\@numbers)->Dump), 'Numbers';
1136 TEST q(Data::Dumper->new(\@numbers_s)->Dump), 'Numbers PV';
1137 TEST q(Data::Dumper->new(\@numbers_i)->Dump), 'Numbers IV';
1138 TEST q(Data::Dumper->new(\@numbers_is)->Dump), 'Numbers IV,PV';
1139 TEST q(Data::Dumper->new(\@numbers_n)->Dump), 'Numbers NV';
1140 TEST q(Data::Dumper->new(\@numbers_ns)->Dump), 'Numbers NV,PV';
1141 TEST q(Data::Dumper->new(\@numbers_ni)->Dump), 'Numbers NV,IV';
1142 TEST q(Data::Dumper->new(\@numbers_nis)->Dump), 'Numbers NV,IV,PV';
1144 TEST q(Data::Dumper->new(\@strings)->Dump), 'Strings';
1145 TEST q(Data::Dumper->new(\@strings_s)->Dump), 'Strings PV';
1146 TEST q(Data::Dumper->new(\@strings_i)->Dump), 'Strings IV';
1147 TEST q(Data::Dumper->new(\@strings_is)->Dump), 'Strings IV,PV';
1148 TEST q(Data::Dumper->new(\@strings_n)->Dump), 'Strings NV';
1149 TEST q(Data::Dumper->new(\@strings_ns)->Dump), 'Strings NV,PV';
1150 TEST q(Data::Dumper->new(\@strings_ni)->Dump), 'Strings NV,IV';
1151 TEST q(Data::Dumper->new(\@strings_nis)->Dump), 'Strings NV,IV,PV';
1154 TEST q(Data::Dumper->new(\@numbers)->Dumpxs), 'XS Numbers';
1155 TEST q(Data::Dumper->new(\@numbers_s)->Dumpxs), 'XS Numbers PV';
1157 TEST q(Data::Dumper->new(\@numbers_i)->Dumpxs), 'XS Numbers IV';
1158 TEST q(Data::Dumper->new(\@numbers_is)->Dumpxs), 'XS Numbers IV,PV';
1160 TEST q(Data::Dumper->new(\@numbers_n)->Dumpxs), 'XS Numbers NV';
1161 TEST q(Data::Dumper->new(\@numbers_ns)->Dumpxs), 'XS Numbers NV,PV';
1163 TEST q(Data::Dumper->new(\@numbers_ni)->Dumpxs), 'XS Numbers NV,IV';
1164 TEST q(Data::Dumper->new(\@numbers_nis)->Dumpxs), 'XS Numbers NV,IV,PV';
1167 TEST q(Data::Dumper->new(\@strings)->Dumpxs), 'XS Strings';
1168 TEST q(Data::Dumper->new(\@strings_s)->Dumpxs), 'XS Strings PV';
1169 # This one used to really mess up. New code actually emulates the .pm code
1171 TEST q(Data::Dumper->new(\@strings_i)->Dumpxs), 'XS Strings IV';
1172 TEST q(Data::Dumper->new(\@strings_is)->Dumpxs), 'XS Strings IV,PV';
1174 TEST q(Data::Dumper->new(\@strings_n)->Dumpxs), 'XS Strings NV';
1175 TEST q(Data::Dumper->new(\@strings_ns)->Dumpxs), 'XS Strings NV,PV';
1176 # This one used to really mess up. New code actually emulates the .pm code
1178 TEST q(Data::Dumper->new(\@strings_ni)->Dumpxs), 'XS Strings NV,IV';
1179 TEST q(Data::Dumper->new(\@strings_nis)->Dumpxs), 'XS Strings NV,IV,PV';
1185 ## Perl code was using /...$/ and hence missing the \n.
1191 # Can't pad with # as the output has an embedded newline.
1192 local $Data::Dumper::Pad = "my ";
1193 TEST q(Data::Dumper->Dump(["42\n"])), "number with trailing newline";
1194 TEST q(Data::Dumper->Dumpxs(["42\n"])), "XS number with trailing newline"
1214 ## Perl code flips over at 10 digits.
1217 #$VAR2 = '1000000000';
1218 #$VAR3 = '9999999999';
1219 #$VAR4 = '10000000000';
1220 #$VAR5 = -999999999;
1221 #$VAR6 = '-1000000000';
1222 #$VAR7 = '-9999999999';
1223 #$VAR8 = '-10000000000';
1224 #$VAR9 = '4294967295';
1225 #$VAR10 = '4294967296';
1226 #$VAR11 = '-2147483648';
1227 #$VAR12 = '-2147483649';
1230 TEST q(Data::Dumper->Dump(\@a)), "long integers";
1233 ## XS code flips over at 11 characters ("-" is a char) or larger than int.
1234 if (~0 == 0xFFFFFFFF) {
1238 #$VAR2 = 1000000000;
1239 #$VAR3 = '9999999999';
1240 #$VAR4 = '10000000000';
1241 #$VAR5 = -999999999;
1242 #$VAR6 = '-1000000000';
1243 #$VAR7 = '-9999999999';
1244 #$VAR8 = '-10000000000';
1245 #$VAR9 = 4294967295;
1246 #$VAR10 = '4294967296';
1247 #$VAR11 = '-2147483648';
1248 #$VAR12 = '-2147483649';
1253 #$VAR2 = 1000000000;
1254 #$VAR3 = 9999999999;
1255 #$VAR4 = '10000000000';
1256 #$VAR5 = -999999999;
1257 #$VAR6 = '-1000000000';
1258 #$VAR7 = '-9999999999';
1259 #$VAR8 = '-10000000000';
1260 #$VAR9 = 4294967295;
1261 #$VAR10 = 4294967296;
1262 #$VAR11 = '-2147483648';
1263 #$VAR12 = '-2147483649';
1266 TEST q(Data::Dumper->Dumpxs(\@a)), "XS long integers";
1272 $b = "Bad. XS didn't escape dollar sign";
1274 $WANT = <<"EOT"; # Careful. This is '' string written inside '' here doc
1275 #\$VAR1 = '\$b\"\@\\\\\xA3';
1278 $a = "\$b\"\@\\\xA3\x{100}";
1280 TEST q(Data::Dumper->Dump([$a])), "utf8 flag with \" and \$";
1282 $WANT = <<'EOT'; # While this is "" string written inside "" here doc
1283 #$VAR1 = "\$b\"\@\\\x{a3}";
1285 TEST q(Data::Dumper->Dumpxs([$a])), "XS utf8 flag with \" and \$";
1287 # XS used to produce "$b\"' which is 4 chars, not 3. [ie wrongly qq(\$b\\\")]
1293 $a = "\$b\"\x{100}";
1295 TEST q(Data::Dumper->Dump([$a])), "utf8 flag with \" and \$";
1297 TEST q(Data::Dumper->Dumpxs([$a])), "XS utf8 flag with \" and \$";
1301 # XS used to produce 'D'oh!' which is well, D'oh!
1302 # Andreas found this one, which in turn discovered the previous two.
1308 $a = "D'oh!\x{100}";
1310 TEST q(Data::Dumper->Dump([$a])), "utf8 flag with '";
1312 TEST q(Data::Dumper->Dumpxs([$a])), "XS utf8 flag with '";
1316 # Jarkko found that -Mutf8 caused some tests to fail. Turns out that there
1317 # was an otherwise untested code path in the XS for utf8 hash keys with purity
1325 # "\x{decaf}\x{decaf}\x{decaf}\x{decaf}" => do{my $o}
1327 #*::ping{HASH}->{"\x{decaf}\x{decaf}\x{decaf}\x{decaf}"} = *::ping{SCALAR};
1328 #%pong = %{*::ping{HASH}};
1330 local $Data::Dumper::Purity = 1;
1331 local $Data::Dumper::Sortkeys;
1333 %ping = (chr (0xDECAF) x 4 =>\$ping);
1334 for $Data::Dumper::Sortkeys (0, 1) {
1335 TEST q(Data::Dumper->Dump([\\*ping, \\%ping], ['*ping', '*pong']));
1336 TEST q(Data::Dumper->Dumpxs([\\*ping, \\%ping], ['*ping', '*pong'])) if $XS;
1340 # XS for quotekeys==0 was not being defensive enough against utf8 flagged
1349 local $Data::Dumper::Quotekeys = 0;
1350 my $k = 'perl' . chr 256;
1352 %foo = ($k => 'rocks');
1354 TEST q(Data::Dumper->Dump([\\%foo])), "quotekeys == 0 for utf8 flagged ASCII";
1355 TEST q(Data::Dumper->Dumpxs([\\%foo])),
1356 "XS quotekeys == 0 for utf8 flagged ASCII" if $XS;
1369 TEST q(Data::Dumper->Dump([\@foo])), 'Richard Clamp, Message-Id: <20030104005247.GA27685@mirth.demon.co.uk>';
1370 TEST q(Data::Dumper->Dumpxs([\@foo])) if $XS;