Backslashed { in regex in test to satisfy perl-5.17
[Data-Peek.git] / t / 30_DDump-s.t
blob2844740824facb4f7a25c8d4740108a88d4757b5
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;
8 use Test::NoWarnings;
10 use Data::Peek;
12 $Data::Peek::has_perlio = $Data::Peek::has_perlio = 0;
14 ok (1, "DDump () NOT using PerlIO");
16 my @tests;
17 { local $/ = "==\n";
18 chomp (@tests = <DATA>);
21 # Determine what newlines this perl generates in sv_peek
22 my @nl = ("\\n") x 2;
24 my $var = "";
26 foreach my $test (@tests) {
27 my ($in, $out) = split m/\n--\n/ => $test;
28 $in eq "" and next;
29 SKIP: {
30 eval "\$var = $in;";
31 my $dump = DDump ($var);
33 if ($in =~ m/20ac/) {
34 if ($] < 5.008) {
35 skip "No UTF8 in ancient perl", 1;
37 else {
38 @nl = ($dump =~ m/PV = 0x\w+ "([^"]+)".*"([^"]+)"/);
39 diag "# This perl dumps \\n as (@nl)";
40 # Catch differences in \n
41 $dump =~ s/"ab\Q$nl[0]\E(.*?)"ab\Q$nl[1]\E/"ab\\n$1"ab\\n/;
45 $dump =~ s/\b0x[0-9a-f]+\b/0x****/g;
46 $dump =~ s/\b(REFCNT =) [0-9]{4,}/$1 -1/g;
48 $dump =~ s/\bLEN = (?:[1-9]|1[0-6])\b/LEN = 8/; # aligned at long long?
50 $dump =~ s/\bPADBUSY\b,?//g if $] < 5.010;
52 $dump =~ s/\bUV = /IV = /g if $] < 5.008;
53 $dump =~ s/,?\bIsUV\b//g if $] < 5.008;
55 $in =~ s/[\s\n]+/ /g;
57 is ($dump, $out, "DDump ($in)");
63 __END__
64 undef
66 SV = PV(0x****) at 0x****
67 REFCNT = 1
68 FLAGS = (PADMY)
69 PV = 0x**** ""\0
70 CUR = 0
71 LEN = 8
75 SV = PVIV(0x****) at 0x****
76 REFCNT = 1
77 FLAGS = (PADMY,IOK,pIOK)
78 IV = 0
79 PV = 0x**** ""\0
80 CUR = 0
81 LEN = 8
85 SV = PVIV(0x****) at 0x****
86 REFCNT = 1
87 FLAGS = (PADMY,IOK,pIOK)
88 IV = 1
89 PV = 0x**** ""\0
90 CUR = 0
91 LEN = 8
95 SV = PVIV(0x****) at 0x****
96 REFCNT = 1
97 FLAGS = (PADMY,POK,pPOK)
98 IV = 1
99 PV = 0x**** ""\0
100 CUR = 0
101 LEN = 8