steal more tests from other modules
[p5sagit/Function-Parameters.git] / t / foreign / MooseX-Method-Signatures / undef_method_arg.t
CommitLineData
595edbcf 1#!perl
2use strict;
3use warnings FATAL => 'all';
4use Test::More;
5use Test::Fatal;
6
7{
8 package Foo;
9 use Function::Parameters qw(:strict);
10
11 method new($class:) { bless {}, $class }
12
98e6239b 13 method m1(:$bar ) { }
14 method m2(:$bar = undef) { }
15 method m3(:$bar ) { }
595edbcf 16
98e6239b 17 method m4( $bar ) { }
595edbcf 18 method m5( $bar = undef ) { }
19 method m6( $bar ) { }
20}
21
22my $foo = Foo->new;
23
98e6239b 24is(exception { $foo->m1(bar => undef) }, undef, 'Explicitly pass undef to positional required arg');
25is(exception { $foo->m2(bar => undef) }, undef, 'Explicitly pass undef to positional explicit optional arg');
26is(exception { $foo->m3(bar => undef) }, undef, 'Explicitly pass undef to positional implicit optional arg');
595edbcf 27
98e6239b 28is(exception { $foo->m4(undef) }, undef, 'Explicitly pass undef to required arg');
595edbcf 29is(exception { $foo->m5(undef) }, undef, 'Explicitly pass undef to explicit required arg');
30is(exception { $foo->m6(undef) }, undef, 'Explicitly pass undef to implicit required arg');
31
32done_testing;