Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix nqp::setinvokespec on parrot. Add a test for it.
  • Loading branch information
pmurias committed Jul 12, 2013
1 parent 0d19655 commit 30d991e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vm/parrot/ops/nqp.ops
Expand Up @@ -2374,6 +2374,7 @@ inline op set_invocation_spec(invar PMC, invar PMC, in STR, invar PMC) :base_cor
InvocationSpec *new_spec = mem_allocate_zeroed_typed(InvocationSpec);
new_spec->value_slot.class_handle = $2;
new_spec->value_slot.attr_name = $3;
new_spec->value_slot.hint = NO_HINT;
new_spec->invocation_handler = $4;

/* Free any existing spec and put the new one in place. */
Expand Down
27 changes: 27 additions & 0 deletions t/nqp/70-invokespec.t
@@ -0,0 +1,27 @@
plan(2);
class Foo {
has $!here_we_keep_the_code_ref;
has $!other_place_we_could_keep_the_code_ref_in;
method set_code_ref($code_ref) {
$!here_we_keep_the_code_ref := $code_ref;
}
method set_code_ref_differently($code_ref) {
$!other_place_we_could_keep_the_code_ref_in := $code_ref;
}
}
class Bar is Foo {
}
nqp::setinvokespec(Foo,Foo,'$!here_we_keep_the_code_ref',nqp::null());

nqp::setinvokespec(Bar,Foo,'$!other_place_we_could_keep_the_code_ref_in',nqp::null());

my $foo := Foo.new();
$foo.set_code_ref(sub() {123});
$foo.set_code_ref_differently(sub() {456});
ok($foo() == 123,"basic setinvokespec");

my $bar := Bar.new();
$bar.set_code_ref(sub() {1001});
$bar.set_code_ref_differently(sub() {1002});
ok($bar() == 1002,"setinvokespec with a attribute in a subclass");

0 comments on commit 30d991e

Please sign in to comment.