This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Convert Data::Dumper's overload.t to Test::More
[perl5.git] / dist / Data-Dumper / t / bless.t
CommitLineData
d0c214fd
AF
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
4ab99479 8BEGIN { plan tests => 1+5*2; }
d0c214fd
AF
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
2d55c85b 17#diag("\$Data::Dumper::Useperl = $Data::Dumper::Useperl");
d0c214fd
AF
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}
192c1e27
JH
40SKIP: {
41 skip(q/no 're::regexp_pattern'/, 1)
42 if ! defined(*re::regexp_pattern{CODE});
43
4ab99479
YO
44my $t = bless( qr//, 'foo');
45my $dt = Dumper($t);
25286052 46my $o = ($] >= 5.013006 ? <<'PERL' : <<'PERL_LEGACY');
fb85c044 47$VAR1 = bless( qr/(?^:)/, 'foo' );
4ab99479 48PERL
5499dc3d
S
49$VAR1 = bless( qr/(?-xism:)/, 'foo' );
50PERL_LEGACY
4ab99479
YO
51
52is($dt, $o, "We can dump blessed qr//'s properly");
d0c214fd
AF
53
54}
4ab99479 55}