This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip failing DD tests under 5.6
[perl5.git] / dist / Data-Dumper / t / overload.t
1 #!./perl -w
2
3 BEGIN {
4     if ($ENV{PERL_CORE}){
5         require Config; import Config;
6         no warnings 'once';
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
14 use strict;
15 use Data::Dumper;
16
17 use Test::More tests => 4;
18
19 package Foo;
20 use overload '""' => 'as_string';
21
22 sub new { bless { foo => "bar" }, shift }
23 sub as_string { "%%%%" }
24
25 package main;
26
27 my $f = Foo->new;
28
29 isa_ok($f, 'Foo');
30 is("$f", '%%%%', 'String overloading works');
31
32 my $d = Dumper($f);
33
34 like($d, qr/bar/);
35 like($d, qr/Foo/);
36