Skip to content

Commit

Permalink
Expand test 79 to also check callercode works in methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Sep 2, 2013
1 parent cba09d3 commit b867c93
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion t/nqp/79-callercode.t
@@ -1,4 +1,4 @@
plan(3);
plan(5);

sub foo_inner() {
my $caller := nqp::callercode();
Expand Down Expand Up @@ -28,3 +28,23 @@ sub bar($arg) {
}
nqp::setcodeobj(&bar,"first");
bar(1);

class Foo {
has $!attr;
method a($arg) {
if $arg == 1 {
$!attr := 100;
self.b(1);
} elsif $arg == 2 {
ok(1,'nqp::callercode work for methods');
ok($!attr == 110,'the attribute has the correct value');
}
}
method b($arg) {
$!attr := $!attr + 10;
my $caller := nqp::callercode();
$caller(self,2);
}
}
my $foo := Foo.new();
$foo.a(1);

0 comments on commit b867c93

Please sign in to comment.