Skip to content

Commit

Permalink
Test closure parameters without calling the parameter
Browse files Browse the repository at this point in the history
This way, we can test if failure is occurring in the as a result
of binding arguments in the function that accepts a closure parameter,
rather than calling the closure parameter itself.  For example:

    my sub call-me(&blondie:(Str)) { blondie('') }

Does `call-me(-> Int $foo { })` fail while binding `call-me` or
`&blondie`?
  • Loading branch information
hoelzro committed Dec 9, 2014
1 parent 9d3f4e9 commit 37a17ea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion S06-signature/closure-parameters.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 15;
plan 17;

# L<S06/Closure parameters>

Expand All @@ -23,8 +23,13 @@ plan 15;
my sub testint(Int $foo) {return 1} #OK not used
my sub teststr(Str $foo) {return 'foo'} #OK not used

my sub test-but-dont-call(&testcode:(Int)) { True }

ok(testit(&testint), 'code runs with proper signature (1)');
eval_dies_ok('testit(&teststr)', 'code dies with invalid signature (1)');

ok(test-but-dont-call(&testint), 'code runs with proper signature (1)');
eval_dies_ok('test-but-dont-call(&teststr)', 'code dies with invalid signature (1)');
}

{
Expand Down

0 comments on commit 37a17ea

Please sign in to comment.