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+2*5; } 9 10BEGIN { use_ok('Data::Dumper') }; 11 12# RT 39420: Data::Dumper fails to escape bless class name 13 14run_tests_for_bless(); 15SKIP: { 16 skip "XS version was unavailable, so we already ran with pure Perl", 5 17 if $Data::Dumper::Useperl; 18 local $Data::Dumper::Useperl = 1; 19 run_tests_for_bless(); 20} 21 22sub run_tests_for_bless { 23note("\$Data::Dumper::Useperl = $Data::Dumper::Useperl"); 24 25{ 26my $t = bless( {}, q{a'b} ); 27my $dt = Dumper($t); 28my $o = <<'PERL'; 29$VAR1 = bless( {}, 'a\'b' ); 30PERL 31 32is($dt, $o, "package name in bless is escaped if needed"); 33is_deeply(scalar eval($dt), $t, "eval reverts dump"); 34} 35 36{ 37my $t = bless( {}, q{a\\} ); 38my $dt = Dumper($t); 39my $o = <<'PERL'; 40$VAR1 = bless( {}, 'a\\' ); 41PERL 42 43is($dt, $o, "package name in bless is escaped if needed"); 44is_deeply(scalar eval($dt), $t, "eval reverts dump"); 45} 46SKIP: { 47 skip(q/no 're::regexp_pattern'/, 1) 48 if ! defined(*re::regexp_pattern{CODE}); 49 50my $t = bless( qr//, 'foo'); 51my $dt = Dumper($t); 52my $o = ($] > 5.010 ? <<'PERL' : <<'PERL_LEGACY'); 53$VAR1 = bless( qr//, 'foo' ); 54PERL 55$VAR1 = bless( qr/(?-xism:)/, 'foo' ); 56PERL_LEGACY 57 58is($dt, $o, "We can dump blessed qr//'s properly"); 59 60} 61 62} # END sub run_tests_for_bless() 63