X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types-Structured.git;a=blobdiff_plain;f=t%2F04-combined.t;h=41897c62f817620bc86a9b3970ba1b5b6f5c83a9;hp=2d2389b8fd277b248b1d1f052e4930e1fe1f1b30;hb=25c705c4f401f9a52eba667e8c72720ace257be6;hpb=2bcb44acb5b4658e4017e081dcbea29c7bf2528f diff --git a/t/04-combined.t b/t/04-combined.t index 2d2389b..41897c6 100644 --- a/t/04-combined.t +++ b/t/04-combined.t @@ -2,7 +2,7 @@ BEGIN { use strict; use warnings; use Test::More tests=>9; - use Test::Exception; + use Test::Fatal; } { @@ -26,35 +26,35 @@ isa_ok $record => 'Test::MooseX::Meta::TypeConstraint::Structured::Combined' ## Test dict_with_tuple -lives_ok sub { +is( exception { $record->dict_with_tuple({key1=>'Hello', key2=>[1,'World']}); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); -throws_ok sub { +like( exception { $record->dict_with_tuple({key1=>'Hello', key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple\) does not pass the type constraint/ - => 'Threw error on bad constraint'; + => 'Threw error on bad constraint'); ## Test dict_with_tuple_with_union: Dict[key1=>'Str|Object', key2=>Tuple['Int','Str|Object']] -lives_ok sub { +is( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,'World']}); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); -throws_ok sub { +like( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/ - => 'Threw error on bad constraint'; + => 'Threw error on bad constraint'); -lives_ok sub { +is( exception { $record->dict_with_tuple_with_union({key1=>$record, key2=>[1,'World']}); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); -lives_ok sub { +is( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,$record]}); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); -throws_ok sub { +like( exception { $record->dict_with_tuple_with_union({key1=>1, key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/ - => 'Threw error on bad constraint'; + => 'Threw error on bad constraint');