Skip to content

Commit 585db6c

Browse files
committed
add support an test for nqp::invokable()
1 parent 785d2fa commit 585db6c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/QAST/Operations.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,7 @@ QAST::Operations.add_core_pirop_mapping('unshift_n', 'unshift', '0Pn', :inlinabl
15491549
QAST::Operations.add_core_pirop_mapping('splice', 'splice', '0PPii', :inlinable(1));
15501550
QAST::Operations.add_core_pirop_mapping('islist', 'nqp_islist', 'IP', :inlinable(1));
15511551
QAST::Operations.add_core_pirop_mapping('ishash', 'nqp_ishash', 'IP', :inlinable(1));
1552+
QAST::Operations.add_core_pirop_mapping('isinvokable', 'is_invokable', 'IP', :inlinable(1));
15521553

15531554
# repr-level aggregate operations
15541555
QAST::Operations.add_core_pirop_mapping('r_atpos', 'repr_at_pos_obj', 'PPi', :inlinable(1));

t/nqp/11-sub.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# check subs
44

5-
say('1..12');
5+
say('1..14');
66

77
sub one ( ) {
88
say("ok 1 # sub def and call");
@@ -75,3 +75,6 @@ say('ok ', Qstuff());
7575

7676
sub term:sym<self>() { 12 }
7777
say('ok ', term:sym<self>());
78+
79+
say( (!nqp::isinvokable(sub() {}) ?? 'ok 13' !! 'no 13' ) ~ ' nqp::isinvokable on sub');
80+
say( (!nqp::isinvokable(666) ?? 'ok 14' !! 'no 14' ) ~ ' nqp::isinvokable on non sub');

0 commit comments

Comments
 (0)