Browse files

[t] and [t/spec]

 * moved nested_named.t to spec/, and cleaned up
 * fudged closure-parameter.t for rakudo


git-svn-id: http://svn.pugscode.org/pugs@25023 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 389ca7c commit b15954792c462414deac49eae9b4221b8640c1fb moritz committed Jan 25, 2009
Showing with 31 additions and 0 deletions.
  1. +29 −0 S06-signature/closure-over-parameters.t
  2. +2 −0 S06-signature/closure-parameters.t
View
29 S06-signature/closure-over-parameters.t
@@ -0,0 +1,29 @@
+use v6;
+
+use Test;
+
+=begin desc
+
+Closure over parameters of outer subs, as per
+# L<S04/The Relationship of Blocks and Declarations/"Every block is a
+# closure">
+# L<S06/Dynamically scoped subroutines>
+
+=end desc
+
+plan 4;
+
+sub factorial (Int $n) {
+ my sub facti (Int $acc, Int $i) {
+ return $acc if $i > $n;
+ facti($acc * $i, $i + 1);
+ }
+ facti(1, 1);
+} ;
+
+is factorial(0), 1, "closing over params of outer subs (0)";
+is factorial(1), 1, "closing over params of outer subs (1)";
+is factorial(2), 2, "closing over params of outer subs (2)";
+is factorial(3), 6, "closing over params of outer subs (3)";
+
+# vim: ft=perl6
View
2 S06-signature/closure-parameters.t
@@ -18,6 +18,7 @@ plan 9;
}
# with a signature for the closure
+#?rakudo skip 'type syntax parse failure'
{
my sub testit (&testcode:(Int)) {testcode(12)}
my sub testint(Int $foo) {return 1}
@@ -27,6 +28,7 @@ plan 9;
eval_dies_ok('testit(&teststr)', 'code dies with invalid signature (1)');
}
+#?rakudo skip 'type syntax parse failure'
{
my sub testit (&testcode:(Int --> Bool)) {testcode()}
my Bool sub testintbool(Int $foo) {return Bool::True}

0 comments on commit b159547

Please sign in to comment.