4 use warnings FATAL => 'all';
8 use Function::Parameters qw(:strict);
10 fun no_sig { return @_ }
11 fun no_args() { return @_ }
12 fun one_arg($foo) { return $foo }
13 fun two_args($foo, $bar) { return ($foo, $bar) }
14 fun array_at_end($foo, @stuff) { return ($foo, @stuff) }
15 fun one_named(:$foo) { return $foo; }
16 fun one_named_one_positional($bar, :$foo) { return($foo, $bar) }
18 note "too many arguments"; {
19 is_deeply [no_sig(42)], [42];
21 ok !eval { no_args(42); 1 }, "no args";
22 like $@, qr{Too many arguments};
24 ok !eval { one_arg(23, 42); 1 }, "one arg";
25 like $@, qr{Too many arguments};
27 ok !eval { two_args(23, 42, 99); 1 }, "two args";
28 like $@, qr{Too many arguments};
30 is_deeply [array_at_end(23, 42, 99)], [23, 42, 99], "array at end";
34 note "with positionals"; {
35 is one_named(foo => 42), 42;
36 is one_named(foo => 23, foo => 42), 42;
39 is_deeply [one_named_one_positional(23, foo => 42)], [42, 23];
40 is_deeply [one_named_one_positional(23, foo => 42, foo => 23)], [23, 23];