$! and $1 are not constant accross OS's
[Data-Peek.git] / t / 30_DDump-s.t
blobfc8c02555e89e7389ad5fb5e56c55e6aad24eb7b
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 # I would like more tests, but contents change over every perl version
7 use Test::More tests => 6;
9 use DDumper;
11 $DDumper::has_perlio = $DDumper::has_perlio = 0;
13 ok (1, "DDump () NOT using PerlIO");
15 my @tests;
16 { local $/ = "==\n";
17 chomp (@tests = <DATA>);
20 # Determine what newlines this perl generates in sv_peek
21 my @nl = ("\\n", "\\n");
22 { if ($] >= 5.008) {
23 my $nl = "\n\x{20ac}";
24 chop $nl;
25 $nl = DPeek ($nl);
26 @nl = ($nl =~ m/"([^"]+)".*"([^"]+)"/);
28 ok (1, "This perl dumps \\n as (@nl)");
31 my $var = "";
33 foreach my $test (@tests) {
34 my ($in, $out) = split m/\n--\n/ => $test;
35 $in eq "" and next;
36 SKIP: {
37 $in =~ m/20ac/ and $] < 5.008 and skip "No UTF8 in ancient perl", 1;
39 eval "\$var = $in;";
40 my $dump = DDump ($var);
41 $dump =~ s/\b0x[0-9a-f]+\b/0x****/g;
42 $dump =~ s/\b(REFCNT =) [0-9]{4,}/$1 -1/g;
43 # Catch differences in \n
44 $dump =~ s/"ab\Q$nl[0]\E(.*?)"ab\Q$nl[1]\E/"ab\\n$1"ab\\n/;
46 $dump =~ s/\bLEN = [1-3]\b/LEN = 4/;
48 $dump =~ s/\bPADBUSY\b,?//g if $] < 5.010;
50 $dump =~ s/\bUV = /IV = /g if $] < 5.008;
51 $dump =~ s/,?\bIsUV\b//g if $] < 5.008;
53 $in =~ s/[\s\n]+/ /g;
54 is ($dump, $out, "DDump ($in)");
60 __END__
61 undef
63 SV = PV(0x****) at 0x****
64 REFCNT = 1
65 FLAGS = (PADMY)
66 PV = 0
70 SV = PVIV(0x****) at 0x****
71 REFCNT = 1
72 FLAGS = (PADMY,IOK,pIOK)
73 IV = 0
74 PV = 0
78 SV = PVIV(0x****) at 0x****
79 REFCNT = 1
80 FLAGS = (PADMY,IOK,pIOK)
81 IV = 1
82 PV = 0
86 SV = PVIV(0x****) at 0x****
87 REFCNT = 1
88 FLAGS = (PADMY,POK,pPOK)
89 IV = 1
90 PV = 0x**** ""\0
91 CUR = 0
92 LEN = 4