Commit | Line | Data |
---|---|---|
d0c214fd AF |
1 | #!perl |
2 | ||
3 | use Test::More 0.60; | |
4 | ||
5 | # Test::More 0.60 required because: | |
6 | # - is_deeply(undef, $not_undef); now works. [rt.cpan.org 9441] | |
7 | ||
4ab99479 | 8 | BEGIN { plan tests => 1+5*2; } |
d0c214fd AF |
9 | |
10 | BEGIN { use_ok('Data::Dumper') }; | |
11 | ||
12 | # RT 39420: Data::Dumper fails to escape bless class name | |
13 | ||
14 | # test under XS and pure Perl version | |
15 | foreach $Data::Dumper::Useperl (0, 1) { | |
16 | ||
2d55c85b | 17 | #diag("\$Data::Dumper::Useperl = $Data::Dumper::Useperl"); |
d0c214fd AF |
18 | |
19 | { | |
20 | my $t = bless( {}, q{a'b} ); | |
21 | my $dt = Dumper($t); | |
22 | my $o = <<'PERL'; | |
23 | $VAR1 = bless( {}, 'a\'b' ); | |
24 | PERL | |
25 | ||
26 | is($dt, $o, "package name in bless is escaped if needed"); | |
27 | is_deeply(scalar eval($dt), $t, "eval reverts dump"); | |
28 | } | |
29 | ||
30 | { | |
31 | my $t = bless( {}, q{a\\} ); | |
32 | my $dt = Dumper($t); | |
33 | my $o = <<'PERL'; | |
34 | $VAR1 = bless( {}, 'a\\' ); | |
35 | PERL | |
36 | ||
37 | is($dt, $o, "package name in bless is escaped if needed"); | |
38 | is_deeply(scalar eval($dt), $t, "eval reverts dump"); | |
39 | } | |
192c1e27 JH |
40 | SKIP: { |
41 | skip(q/no 're::regexp_pattern'/, 1) | |
42 | if ! defined(*re::regexp_pattern{CODE}); | |
43 | ||
4ab99479 YO |
44 | my $t = bless( qr//, 'foo'); |
45 | my $dt = Dumper($t); | |
25286052 | 46 | my $o = ($] >= 5.013006 ? <<'PERL' : <<'PERL_LEGACY'); |
fb85c044 | 47 | $VAR1 = bless( qr/(?^:)/, 'foo' ); |
4ab99479 | 48 | PERL |
5499dc3d S |
49 | $VAR1 = bless( qr/(?-xism:)/, 'foo' ); |
50 | PERL_LEGACY | |
4ab99479 YO |
51 | |
52 | is($dt, $o, "We can dump blessed qr//'s properly"); | |
d0c214fd AF |
53 | |
54 | } | |
4ab99479 | 55 | } |