6 require q(./test.pl); plan(tests => 7);
14 package OverloadingTest;
19 use overload '""' => sub { ref(shift) . " stringified" },
22 sub new { bless {} => shift }
24 package InheritingFromOverloadedTest;
27 use base 'OverloadingTest';
31 my $x = InheritingFromOverloadedTest->new();
32 isa_ok($x, 'InheritingFromOverloadedTest');
34 my $y = OverloadingTest->new();
35 isa_ok($y, 'OverloadingTest');
37 is("$x", 'InheritingFromOverloadedTest stringified', '... got the right value when stringifing');
38 is("$y", 'OverloadingTest stringified', '... got the right value when stringifing');
40 ok(($y eq 'OverloadingTest stringified'), '... eq was handled correctly');
44 $result = $x eq 'InheritingFromOverloadedTest stringified'
46 ok(!$@, '... this should not throw an exception');
47 ok($result, '... and we should get the true value');