use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
{
# try with arrays
- lives_ok {
+ is( exception {
$engine->header([ 1, 2, 3 ]);
- } '... type was coerced without incident';
+ }, undef, '... type was coerced without incident' );
isa_ok($engine->header, 'HTTPHeader');
is_deeply(
# try with hash
- lives_ok {
+ is( exception {
$engine->header({ one => 1, two => 2, three => 3 });
- } '... type was coerced without incident';
+ }, undef, '... type was coerced without incident' );
isa_ok($engine->header, 'HTTPHeader');
is_deeply(
'... got the right hash value of the header');
ok(!defined($engine->header->array), '... no array value set');
- dies_ok {
+ isnt( exception {
$engine->header("Foo");
- } '... dies with the wrong type, even after coercion';
+ }, undef, '... dies with the wrong type, even after coercion' );
- lives_ok {
+ is( exception {
$engine->header(HTTPHeader->new);
- } '... lives with the right type, even after coercion';
+ }, undef, '... lives with the right type, even after coercion' );
}
{
ok(!defined($engine->header->array), '... no array value set');
}
-dies_ok {
+isnt( exception {
Engine->new(header => 'Foo');
-} '... dies correctly with bad params';
+}, undef, '... dies correctly with bad params' );
-dies_ok {
+isnt( exception {
Engine->new(header => \(my $var));
-} '... dies correctly with bad params';
+}, undef, '... dies correctly with bad params' );
{
my $tc = Moose::Util::TypeConstraints::find_type_constraint('HTTPHeader');
isa_ok($from_href, 'HTTPHeader', 'assert_coerce from href to HTTPHeader');
is_deeply($from_href->hash, { a => 1 }, '...and has the right guts');
- throws_ok { $tc->assert_coerce('total garbage') }
- qr/Validation failed for .HTTPHeader./,
- "assert_coerce throws if result is not acceptable";
+ like( exception { $tc->assert_coerce('total garbage') }, qr/Validation failed for .HTTPHeader./, "assert_coerce throws if result is not acceptable" );
}
done_testing;