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
|
#!/usr/bin/perl
use v5.18;
use warnings;
use Test2::V0;
use Object::Pad 0.800;
class Point {
field $x;
method clear { $x = 0 }
}
{
ok( !eval { Point->clear },
'method on non-instance fails' );
like( $@, qr/^Cannot invoke method on a non-instance /,
'message from method on non-instance' );
}
{
my $obj = bless [], "DifferentClass";
ok( !eval { $obj->Point::clear },
'method on wrong class fails' );
like( $@, qr/^Cannot invoke foreign method on non-derived instance /,
'message from method on wrong class' );
}
done_testing;
|