This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
b8c8719318bdad0590a0089678146d7ba400b966
[perl5.git] / t / lib / dumper-ovl.t
1 #!./perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     unshift @INC, '../lib' if -d '../lib';
6     require Config; import Config;
7     if ($Config{'extensions'} !~ /\bData\/Dumper\b/) {
8       print "1..0 # Skip: Data::Dumper was not built\n";
9       exit 0;
10     }
11 }
12
13 use Data::Dumper;
14
15 print "1..1\n";
16
17 package Foo;
18 use overload '""' => 'as_string';
19
20 sub new { bless { foo => "bar" }, shift }
21 sub as_string { "%%%%" }
22
23 package main;
24
25 my $f = Foo->new;
26
27 print "#\$f=$f\n";
28
29 $_ = Dumper($f);
30 s/^/#/mg;
31 print $_;
32
33 print "not " unless /bar/ && /Foo/;
34 print "ok 1\n";
35