Permalink
Browse files

[t/spec] tests for optional parameters, typed and untyped (RT #61528)

git-svn-id: http://svn.pugscode.org/pugs@24498 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 6e20293 commit 4ef6e53fe6dee9f9da7d6314f3877030b145825f moritz committed Dec 19, 2008
Showing with 17 additions and 0 deletions.
  1. +17 −0 S06-signature/optional.t
View
@@ -0,0 +1,17 @@
+use v6;
+use Test;
+
+plan 4;
+
+sub opt1($p?) { defined($p) ?? $p !! 'undef'; }
+
+is opt1('abc'), 'abc', 'Can pass optional param';
+is opt1(), 'undef', 'Can leave out optional param';
+
+sub opt_typed(Int $p?) { defined($p) ?? $p !! 'undef' };
+
+is opt_typed(2), 2, 'can pass optional typed param';
+#?rakudo skip 'optional typed params, RT #61528'
+is opt_typed() , 'undef', 'can leave out optional typed param';
+
+# vim: ft=perl6

0 comments on commit 4ef6e53

Please sign in to comment.