1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Devel::OverloadInfo;
{
package Foo;
# *MUST* be a deref overload standalone, any additional will not do
use overload (
"&{}" => sub { sub { 42 } },
fallback => 1,
);
}
{
package SubFoo;
# Must have subclass inheriting the overload
use parent -norequire => 'Foo';
}
Devel::OverloadInfo::overload_info('SubFoo');
my $x = bless {}, 'SubFoo';
is exception {
ok !!$x, "un-overloaded negation works after inspection before first bless";
}, undef, "un-overloaded negation lives after inspection before first bless";
is exception {
is $x->(), 42, "overloaded dereference works after inspection before first bless";
}, undef, "overloaded dereference lives after inspection before first bless";
done_testing;
|