2 use warnings FATAL => 'all';
9 sub as_string { "welp" }
22 sub new { bless {}, shift }
29 '""' => 'class_string',
34 sub new { bless {}, shift }
35 sub class_string { 'yarp' }
40 sub new { bless {}, shift }
45 is "$o", 'welp', 'subref overload';
46 is sprintf('%d', $o), 219, 'method name overload';
47 ok !$o, 'anon subref overload';
51 my $o = MyClass2->new;
52 eval { my $f = 0+$o };
53 like $@, qr/no method found/, 'fallback value not overwritten';
54 is "$o", 'yarp', 'method name overload not overwritten';
55 is sprintf('%d', $o), 42, 'subref overload not overwritten';
59 my @o = (MyClass3->new) x 2;
62 Role::Tiny->apply_roles_to_object($o, 'MyRole')
64 local $TODO = 'magic not applied to all ref copies on perl < 5.8.9'
65 if $copy && $] < 5.008009;
66 is "$o", 'welp', 'subref overload applied to instance'.$copy;
67 is sprintf('%d', $o), 219, 'method name overload applied to instance'.$copy;
68 ok !$o, 'anon subref overload applied to instance'.$copy;