use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
# Note that setting coerce => 1 for the Num type tests that we don't try to do
# coercions for a type which doesn't have any coercions.
# added to test 'optional' on validated_hash
sub baropt {
- my $self = shift;
+ my $self = shift;
my %params = validated_hash(
\@_,
size1 => { isa => 'Size', coerce => 1, optional => 1 },
[ $params{size1}, $params{size2}, $params{number} ];
}
-
sub baz {
my $self = shift;
my ( $size1, $size2, $number ) = validated_list(
[ $size1, $size2, $number ];
}
-
sub quux {
my $self = shift;
my ( $size1, $size2, $number ) = validated_list(
'got the return value right with coercions for size1'
);
-throws_ok { $foo->bar( size1 => 30, size2 => [ 1, 2, 3 ], number => 30 ) }
-qr/\QThe 'size2' parameter/,
- '... the size2 param cannot be coerced';
+like(
+ exception { $foo->bar( size1 => 30, size2 => [ 1, 2, 3 ], number => 30 ) }
+ , qr/\QThe 'size2' parameter/, '... the size2 param cannot be coerced' );
-throws_ok { $foo->bar( size1 => 30, size2 => 10, number => 'something' ) }
-qr/\QThe 'number' parameter/,
- '... the number param cannot be coerced because there is no coercion defined for Num';
+like(
+ exception { $foo->bar( size1 => 30, size2 => 10, number => 'something' ) }
+ , qr/\QThe 'number' parameter/,
+ '... the number param cannot be coerced because there is no coercion defined for Num'
+);
is_deeply(
$foo->baz( size1 => 10, size2 => 20, number => 30 ),
'got the return value right with coercions for size1'
);
-throws_ok { $foo->baz( size1 => 30, size2 => [ 1, 2, 3 ], number => 30 ) }
-qr/\QThe 'size2' parameter/,
- '... the size2 param cannot be coerced';
+like(
+ exception { $foo->baz( size1 => 30, size2 => [ 1, 2, 3 ], number => 30 ) }
+ , qr/\QThe 'size2' parameter/, '... the size2 param cannot be coerced' );
-throws_ok { $foo->baz( size1 => 30, size2 => 10, number => 'something' ) }
-qr/\QThe 'number' parameter/,
- '... the number param cannot be coerced';
+like(
+ exception { $foo->baz( size1 => 30, size2 => 10, number => 'something' ) }
+ , qr/\QThe 'number' parameter/,
+ '... the number param cannot be coerced'
+);
is_deeply(
$foo->baropt( size2 => 4 ),
'got the return value right with coercion for the first param'
);
-throws_ok { $foo->ran_out( [ 1, 2 ], [ 1, 2 ] ) }
-qr/\QParameter #2/,
- '... did not attempt to coerce the second parameter';
-
+like(
+ exception { $foo->ran_out( [ 1, 2 ], [ 1, 2 ] ) }, qr/\QParameter #2/,
+ '... did not attempt to coerce the second parameter'
+);
is_deeply(
$foo->ran_out(),