Browse files

[t/spec] test multi dispatch over the signature of closure parameters

git-svn-id: http://svn.pugscode.org/pugs@27849 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent ce6699c commit 5ab90cfbf89fda6b9c47a9abecd8a0abad5cc3f4 moritz committed Aug 2, 2009
Showing with 23 additions and 1 deletion.
  1. +23 −1 S06-signature/closure-parameters.t
View
24 S06-signature/closure-parameters.t
@@ -1,7 +1,7 @@
use v6;
use Test;
-plan 9;
+plan 14;
# L<S06/Closure parameters>
@@ -42,4 +42,26 @@ plan 9;
eval_dies_ok('testit(&teststrint)', 'code dies with invalid signature (4)');
}
+#?rakudo skip 'type syntax parse failure'
+{
+ multi sub t1 (&code:(Int)) { 'Int' };
+ multi sub t1 (&code:(Str)) { 'Str' };
+ multi sub t1 (&code:(Str --> Bool)) { 'Str --> Bool' };
+ multi sub t1 (&code:(Any, Any)) { 'Two' };
+
+ is t1(-> $a, $b { }), 'Two',
+ 'Multi dispatch based on closure parameter syntax (1)'
+ is t1(-> Int $a { }), 'Int',
+ 'Multi dispatch based on closure parameter syntax (2)'
+ is t1(-> Str $a { }), 'Str',
+ 'Multi dispatch based on closure parameter syntax (3)'
+
+ sub takes-str-returns-bool(Str $x --> Bool) { True }
+ is t1(&takes-str-returns-bool), 'Str --> Bool',
+ 'Multi dispatch based on closure parameter syntax (4)'
+
+ dies_ok { t1( -> { 3 }) },
+ 'Multi dispatch based on closure parameter syntax (5)'
+}
+
# vim: ft=perl6

0 comments on commit 5ab90cf

Please sign in to comment.