1#!perl 2 3use 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 8BEGIN { plan tests => 1+5*2; } 9 10BEGIN { 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 15foreach $Data::Dumper::Useperl (0, 1) { 16 17#diag("\$Data::Dumper::Useperl = $Data::Dumper::Useperl"); 18 19{ 20my $t = bless( {}, q{a'b} ); 21my $dt = Dumper($t); 22my $o = <<'PERL'; 23$VAR1 = bless( {}, 'a\'b' ); 24PERL 25 26is($dt, $o, "package name in bless is escaped if needed"); 27is_deeply(scalar eval($dt), $t, "eval reverts dump"); 28} 29 30{ 31my $t = bless( {}, q{a\\} ); 32my $dt = Dumper($t); 33my $o = <<'PERL'; 34$VAR1 = bless( {}, 'a\\' ); 35PERL 36 37is($dt, $o, "package name in bless is escaped if needed"); 38is_deeply(scalar eval($dt), $t, "eval reverts dump"); 39} 40SKIP: { 41 skip(q/no 're::regexp_pattern'/, 1) 42 if ! defined(*re::regexp_pattern{CODE}); 43 44my $t = bless( qr//, 'foo'); 45my $dt = Dumper($t); 46my $o = <<'PERL'; 47$VAR1 = bless( qr/(?-xism:)/, 'foo' ); 48PERL 49 50is($dt, $o, "We can dump blessed qr//'s properly"); 51 52} 53} 54