1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/usr/bin/perl -w
# Test the $arg! required syntax
use strict;
use warnings;
use Test::More;
{
package Stuff;
use lib 't/lib';
use GenErrorRegex qw< required_error >;
use Test::More;
use Test::Exception;
use Method::Signatures;
method whatever($this!) {
return $this;
}
is( Stuff->whatever(23), 23 );
#line 23
throws_ok { Stuff->whatever() } required_error('Stuff', '$this', 'whatever', LINE => 23),
'simple required param error okay';
method some_optional($that!, $this = 22) {
return $that + $this
}
is( Stuff->some_optional(18), 18 + 22 );
#line 33
throws_ok { Stuff->some_optional() } required_error('Stuff', '$that', 'some_optional', LINE => 33),
'some required/some not required param error okay';
}
done_testing();
|