Commit | Line | Data |
595edbcf |
1 | #!perl |
2 | use strict; |
3 | use warnings FATAL => 'all'; |
4 | use Test::More; |
5 | use Test::Fatal; |
6 | |
7 | { |
8 | package Foo; |
9 | use Function::Parameters qw(:strict); |
10 | |
1a52f2db |
11 | method new($class:) { bless {}, $class } |
595edbcf |
12 | |
1a52f2db |
13 | method m1(:$bar ) { } |
98e6239b |
14 | method m2(:$bar = undef) { } |
1a52f2db |
15 | method m3(:$bar ) { } |
595edbcf |
16 | |
1a52f2db |
17 | method m4( $bar ) { } |
18 | method m5( $bar = undef) { } |
19 | method m6( $bar ) { } |
595edbcf |
20 | } |
21 | |
22 | my $foo = Foo->new; |
23 | |
1a52f2db |
24 | is(exception { $foo->m1(bar => undef) }, undef, 'Explicitly pass undef to named implicit required arg'); |
25 | is(exception { $foo->m2(bar => undef) }, undef, 'Explicitly pass undef to named explicit optional arg'); |
26 | is(exception { $foo->m3(bar => undef) }, undef, 'Explicitly pass undef to named implicit required arg'); |
595edbcf |
27 | |
1a52f2db |
28 | is(exception { $foo->m4(undef) }, undef, 'Explicitly pass undef to implicit required arg'); |
595edbcf |
29 | is(exception { $foo->m5(undef) }, undef, 'Explicitly pass undef to explicit required arg'); |
30 | is(exception { $foo->m6(undef) }, undef, 'Explicitly pass undef to implicit required arg'); |
31 | |
32 | done_testing; |