Skip to content

Commit

Permalink
We now pass 20-return.t and 48-closure.t.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Oct 30, 2010
1 parent 3629a41 commit b11ad22
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
23 changes: 23 additions & 0 deletions t/nqp/20-return.t
@@ -0,0 +1,23 @@
#! nqp

# implicit and explicit returns from subs

plan(3);

sub foo() { 1; }


sub bar() {
return 2;
0;
}

sub baz() {
if (1) { return 3; }
0;
}

ok( foo() == 1 , 'last value in block' );
ok( bar() == 2 , 'explicit return value in block');
ok( baz() == 3 , 'explicit return from nested block');

14 changes: 14 additions & 0 deletions t/nqp/48-closure.t
@@ -0,0 +1,14 @@
#! nqp

plan(2);

sub A($a) {
return { $a * 2 };
}

my $x := A(3);
my $y := A(5);

ok( $y() == 10, "second closure correct" );
ok( $x() == 6, "first closure correct" );

0 comments on commit b11ad22

Please sign in to comment.