Permalink
Browse files

We now pass 20-return.t and 48-closure.t.

  • Loading branch information...
1 parent 3629a41 commit b11ad221ca8501b2d035ef96bedb5d06eddbccae @jnthn committed Oct 30, 2010
Showing with 37 additions and 0 deletions.
  1. +23 −0 t/nqp/20-return.t
  2. +14 −0 t/nqp/48-closure.t
View
23 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');
+
View
14 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.