Skip to content

Commit

Permalink
Add test for nqp::curcode();
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Aug 6, 2013
1 parent c9a07ec commit b4a38bb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions t/nqp/75-curcode.t
@@ -0,0 +1,24 @@
plan(3);

sub foo($arg) {
my $this := nqp::curcode();
if $arg == 1 {
$this(7);
} elsif $arg == 7 {
ok("nqp::curcode returns the correct sub");
}
}
foo(1);

sub bar($arg) {
my $this := nqp::curcode();
if $arg == 1 {
ok(nqp::getcodeobj($this) eq "first","nqp::getcodeobj works on result of nqp::curcode");
nqp::setcodeobj($this,"second");
$this(7);
} elsif $arg == 7 {
ok(nqp::getcodeobj($this) eq "second","nqp::setcodeobj works on result of nqp::curcode");
}
}
nqp::setcodeobj(&bar,"first");
bar(1);

0 comments on commit b4a38bb

Please sign in to comment.