Skip to content

Commit d83b1c9

Browse files
committed
Test nqp::tryfindmethod
1 parent 218702c commit d83b1c9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

t/nqp/090-findmethod.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plan(13);
1+
plan(16);
22

33
class Foo {
44
has $!attr;
@@ -14,6 +14,12 @@ my $foo := Foo.new(attr => 'frob');
1414
is(nqp::findmethod($foo, 'foo')($foo), 'foo', 'calling result of findmethod only with invocant');
1515
is(nqp::findmethod($foo, 'bar')($foo, 'baz'), 'barfrobbaz', 'calling result of findmethod with argument');
1616

17+
ok(nqp::eqaddr(nqp::findmethod($foo, 'foo'), nqp::tryfindmethod($foo, 'foo')), 'nqp::tryfindmethod works like nqp::findmethod when the method exists');
18+
19+
dies-ok({nqp::findmethod($foo, 'no_such_method_ever')}, "nqp::findmethod throws exception when the method doesn\'t exit");
20+
21+
ok(nqp::isnull(nqp::tryfindmethod($foo, 'no_such_method_ever')), 'nqp::tryfindmethod returns null for missing method');
22+
1723
ok(nqp::can($foo, 'foo') == 1, 'nqp::can with existing method');
1824
ok(nqp::can($foo, 'no_such_method_ever') == 0, 'nqp::can with missing method');
1925

0 commit comments

Comments
 (0)