21 package OverloadingTest;
26 use overload '""' => sub { ref(shift) . " stringified" },
29 sub new { bless {} => shift }
31 package InheritingFromOverloadedTest;
34 use base 'OverloadingTest';
38 my $x = InheritingFromOverloadedTest->new();
39 object_ok($x, 'InheritingFromOverloadedTest');
41 my $y = OverloadingTest->new();
42 object_ok($y, 'OverloadingTest');
44 is("$x", 'InheritingFromOverloadedTest stringified', '... got the right value when stringifing');
45 is("$y", 'OverloadingTest stringified', '... got the right value when stringifing');
47 ok(($y eq 'OverloadingTest stringified'), '... eq was handled correctly');
51 $result = $x eq 'InheritingFromOverloadedTest stringified'
53 ok(!$@, '... this should not throw an exception');
54 ok($result, '... and we should get the true value');