From: Karen Etheridge Date: Sat, 4 Dec 2010 17:21:54 +0000 (-0800) Subject: convert all uses of Test::Exception to Test::Fatal. X-Git-Tag: 0.25~2^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types-Structured.git;a=commitdiff_plain;h=25c705c4f401f9a52eba667e8c72720ace257be6 convert all uses of Test::Exception to Test::Fatal. --- diff --git a/Changes b/Changes index 8bc9dbd..798103e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for MooseX-Types-Structured +{{NEXT}} + - The test suite now uses Test::Fatal instead of Test::Exception (Karen + Etheridge). + 0.24 16 November 2010 - Added some performance enhancing caching code (phaeton) diff --git a/dist.ini b/dist.ini index 3e66564..cffd919 100644 --- a/dist.ini +++ b/dist.ini @@ -21,5 +21,5 @@ Sub::Exporter = 0.982 [Prereqs / BuildRequires] Test::More = 0.94 -Test::Exception = 0.27 +Test::Fatal = 0.003 diff --git a/t/02-tuple.t b/t/02-tuple.t index 68718aa..2710825 100644 --- a/t/02-tuple.t +++ b/t/02-tuple.t @@ -2,7 +2,7 @@ BEGIN { use strict; use warnings; use Test::More tests=>32; - use Test::Exception; + use Test::Fatal; } { @@ -50,9 +50,9 @@ isa_ok $record => 'Test::MooseX::Meta::TypeConstraint::Structured::Tuple' ## Test Tuple type constraint -lives_ok sub { +is( exception { $record->tuple([1,'hello', 'test.abc.test']); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); is $record->tuple->[0], 1 => 'correct set the tuple attribute index 0'; @@ -63,81 +63,81 @@ is $record->tuple->[1], 'hello' is $record->tuple->[2], 'test.abc.test' => 'correct set the tuple attribute index 2'; -throws_ok sub { +like( exception { $record->tuple([1,'hello', 'test.xxx.test']); }, qr/Attribute \(tuple\) does not pass the type constraint/ - => 'Properly failed for bad value in custom type constraint'; + => 'Properly failed for bad value in custom type constraint'); -throws_ok sub { +like( exception { $record->tuple(['asdasd',2, 'test.abc.test']); }, qr/Attribute \(tuple\) does not pass the type constraint/ - => 'Got Expected Error for violating constraints'; + => 'Got Expected Error for violating constraints'); ## Test tuple_with_maybe -lives_ok sub { +is( exception { $record->tuple_with_maybe([1,'hello', 1, $record]); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); -throws_ok sub { +like( exception { $record->tuple_with_maybe([1,'hello', 'a', $record]); }, qr/Attribute \(tuple_with_maybe\) does not pass the type constraint/ - => 'Properly failed for bad value parameterized constraint'; + => 'Properly failed for bad value parameterized constraint'); -lives_ok sub { +is( exception { $record->tuple_with_maybe([1,'hello',undef, $record]); -} => 'Set tuple attribute without error skipping optional parameter'; +} => undef, 'Set tuple attribute without error skipping optional parameter'); ## Test tuple_with_maybe2 -lives_ok sub { +is( exception { $record->tuple_with_maybe2([1,'hello', 1]); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); -throws_ok sub { +like( exception { $record->tuple_with_maybe2([1,'hello', 'a']); }, qr/Attribute \(tuple_with_maybe2\) does not pass the type constraint/ - => 'Properly failed for bad value parameterized constraint'; + => 'Properly failed for bad value parameterized constraint'); -lives_ok sub { +is( exception { $record->tuple_with_maybe2([1,'hello',undef]); -} => 'Set tuple attribute without error skipping optional parameter'; +} => undef, 'Set tuple attribute without error skipping optional parameter'); SKIP: { skip 'Core Maybe incorrectly allows null.', 1, 1; - throws_ok sub { + like( exception { $record->tuple_with_maybe2([1,'hello']); }, qr/Attribute \(tuple_with_maybe2\) does not pass the type constraint/ - => 'Properly fails for missing maybe (needs to be at least undef)'; + => 'Properly fails for missing maybe (needs to be at least undef)'); } ## Test Tuple with parameterized type -lives_ok sub { +is( exception { $record->tuple_with_param([1,'hello', [1,2,3]]); -} => 'Set tuple attribute without error'; +} => undef, 'Set tuple attribute without error'); -throws_ok sub { +like( exception { $record->tuple_with_param([1,'hello', [qw/a b c/]]); }, qr/Attribute \(tuple_with_param\) does not pass the type constraint/ - => 'Properly failed for bad value parameterized constraint'; + => 'Properly failed for bad value parameterized constraint'); ## Test tuple2 (Tuple[Int,Str,Int]) ok $record->tuple2([1,'hello',3]) => "[1,'hello',3] properly suceeds"; -throws_ok sub { +like( exception { $record->tuple2([1,2,'world']); -}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "[1,2,'world'] properly fails"; +}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "[1,2,'world'] properly fails"); -throws_ok sub { +like( exception { $record->tuple2(['hello1',2,3]); -}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,3] properly fails"; +}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,3] properly fails"); -throws_ok sub { +like( exception { $record->tuple2(['hello2',2,'world']); -}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,'world'] properly fails"; +}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,'world'] properly fails"); ## Test tuple_with_parameterized (Tuple[Int,Str,Int,ArrayRef[Int]]) @@ -145,54 +145,54 @@ throws_ok sub { ok $record->tuple_with_parameterized([1,'hello',3,[1,2,3]]) => "[1,'hello',3,[1,2,3]] properly suceeds"; -throws_ok sub { +like( exception { $record->tuple_with_parameterized([1,2,'world']); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ - => "[1,2,'world'] properly fails"; + => "[1,2,'world'] properly fails"); -throws_ok sub { +like( exception { $record->tuple_with_parameterized(['hello1',2,3]); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ - => "['hello',2,3] properly fails"; + => "['hello',2,3] properly fails"); -throws_ok sub { +like( exception { $record->tuple_with_parameterized(['hello2',2,'world']); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ - => "['hello',2,'world'] properly fails"; + => "['hello',2,'world'] properly fails"); -throws_ok sub { +like( exception { $record->tuple_with_parameterized([1,'hello',3,[1,2,'world']]); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ - => "[1,'hello',3,[1,2,'world']] properly fails"; + => "[1,'hello',3,[1,2,'world']] properly fails"); ## Test FiveByFiveAttr -lives_ok sub { +is( exception { $record->FiveByFiveAttr([6,[7,8,9]]); -} => 'Set FiveByFiveAttr correctly'; +} => undef, 'Set FiveByFiveAttr correctly'); -throws_ok sub { +like( exception { $record->FiveByFiveAttr([1,'hello', 'test']); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ - => q{Properly failed for bad value in FiveByFiveAttr [1,'hello', 'test']}; + => q{Properly failed for bad value in FiveByFiveAttr [1,'hello', 'test']}); -throws_ok sub { +like( exception { $record->FiveByFiveAttr([1,[8,9,10]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ - => q{Properly failed for bad value in FiveByFiveAttr [1,[8,9,10]]}; + => q{Properly failed for bad value in FiveByFiveAttr [1,[8,9,10]]}); -throws_ok sub { +like( exception { $record->FiveByFiveAttr([10,[11,12,0]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ - => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12,0]]}; + => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12,0]]}); -throws_ok sub { +like( exception { $record->FiveByFiveAttr([1,[1,1,0]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ - => q{Properly failed for bad value in FiveByFiveAttr [1,[1,1,0]]}; + => q{Properly failed for bad value in FiveByFiveAttr [1,[1,1,0]]}); -throws_ok sub { +like( exception { $record->FiveByFiveAttr([10,[11,12]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ - => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12]}; + => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12]}); diff --git a/t/03-dict.t b/t/03-dict.t index 79176ab..ba87242 100644 --- a/t/03-dict.t +++ b/t/03-dict.t @@ -2,7 +2,7 @@ BEGIN { use strict; use warnings; use Test::More tests=>17; - use Test::Exception; + use Test::Fatal; } { @@ -32,9 +32,9 @@ isa_ok $record => 'Test::MooseX::Meta::TypeConstraint::Structured::Dict' # Test dict Dict[name=>Str, age=>Int] -lives_ok sub { +is( exception { $record->dict({name=>'frith', age=>23}); -} => 'Set dict attribute without error'; +} => undef, 'Set dict attribute without error'); is $record->dict->{name}, 'frith' => 'correct set the dict attribute name'; @@ -42,16 +42,16 @@ is $record->dict->{name}, 'frith' is $record->dict->{age}, 23 => 'correct set the dict attribute age'; -throws_ok sub { +like( exception { $record->dict({name=>[1,2,3], age=>'sdfsdfsd'}); }, qr/Attribute \(dict\) does not pass the type constraint/ - => 'Got Expected Error for bad value in dict'; + => 'Got Expected Error for bad value in dict'); ## Test dict_with_maybe -lives_ok sub { +is( exception { $record->dict_with_maybe({name=>'frith', age=>23}); -} => 'Set dict attribute without error'; +} => undef, 'Set dict attribute without error'); is $record->dict_with_maybe->{name}, 'frith' => 'correct set the dict attribute name'; @@ -59,40 +59,40 @@ is $record->dict_with_maybe->{name}, 'frith' is $record->dict_with_maybe->{age}, 23 => 'correct set the dict attribute age'; -throws_ok sub { +like( exception { $record->dict_with_maybe({name=>[1,2,3], age=>'sdfsdfsd'}); }, qr/Attribute \(dict_with_maybe\) does not pass the type constraint/ - => 'Got Expected Error for bad value in dict'; + => 'Got Expected Error for bad value in dict'); -throws_ok sub { +like( exception { $record->dict_with_maybe({age=>30}); }, qr/Attribute \(dict_with_maybe\) does not pass the type constraint/ - => 'Got Expected Error for missing named parameter'; + => 'Got Expected Error for missing named parameter'); -lives_ok sub { +is( exception { $record->dict_with_maybe({name=>'usal', age=>undef}); -} => 'Set dict attribute without error, skipping maybe'; +} => undef, 'Set dict attribute without error, skipping maybe'); ## 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'); 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'); diff --git a/t/04-map.t b/t/04-map.t index 636b11d..a1f0a56 100644 --- a/t/04-map.t +++ b/t/04-map.t @@ -1,6 +1,7 @@ use strict; use warnings; use Test::More; +use Test::Fatal; use MooseX::Types::Moose qw(Int Num); use MooseX::Types::Structured qw(Map); @@ -9,11 +10,11 @@ my $type = Map[ Int, Num ]; ok($type->assert_valid({ 10 => 10.5 }), "simple Int -> Num mapping"); -eval { $type->assert_valid({ 10.5 => 10.5 }) }; -like($@, qr{value 10\.5}, "non-Int causes rejection on key"); +like( exception { $type->assert_valid({ 10.5 => 10.5 }) }, + qr{value 10\.5}, "non-Int causes rejection on key"); -eval { $type->assert_valid({ 10 => "ten and a half" }) }; -like("$@", qr{value ten and a half}, "non-Num value causes rejection on value"); +like( exception { $type->assert_valid({ 10 => "ten and a half" }) }, + qr{value ten and a half}, "non-Num value causes rejection on value"); ok($type->assert_valid({ }), "empty hashref is a valid mapping of any sort"); diff --git a/t/05-advanced.t b/t/05-advanced.t index 3de3a60..3d28322 100644 --- a/t/05-advanced.t +++ b/t/05-advanced.t @@ -2,7 +2,7 @@ BEGIN { use strict; use warnings; use Test::More tests=>16; - use Test::Exception; + use Test::Fatal; } { @@ -59,75 +59,75 @@ isa_ok $obj => 'Test::MooseX::Meta::TypeConstraint::Structured::Advanced' ## Test EqualLengthAttr -lives_ok sub { +is( exception { $obj->EqualLengthAttr([[6,7,8],[9,10,11]]); -} => 'Set EqualLengthAttr attribute without error'; +} => undef, 'Set EqualLengthAttr attribute without error'); -throws_ok sub { +like( exception { $obj->EqualLengthAttr([1,'hello', 'test.xxx.test']); }, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/ - => q{EqualLengthAttr correctly fails [1,'hello', 'test.xxx.test']}; + => q{EqualLengthAttr correctly fails [1,'hello', 'test.xxx.test']}); -throws_ok sub { +like( exception { $obj->EqualLengthAttr([[6,7],[9,10,11]]); }, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/ - => q{EqualLengthAttr correctly fails [[6,7],[9,10,11]]}; + => q{EqualLengthAttr correctly fails [[6,7],[9,10,11]]}); -throws_ok sub { +like( exception { $obj->EqualLengthAttr([[6,7,1],[9,10,11]]); }, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/ - => q{EqualLengthAttr correctly fails [[6,7,1],[9,10,11]]}; + => q{EqualLengthAttr correctly fails [[6,7,1],[9,10,11]]}); ## Test MoreLengthPleaseAttr -lives_ok sub { +is( exception { $obj->MoreLengthPleaseAttr([[6,7,8,9,10],[11,12,13,14,15]]); -} => 'Set MoreLengthPleaseAttr attribute without error'; +} => undef, 'Set MoreLengthPleaseAttr attribute without error'); -throws_ok sub { +like( exception { $obj->MoreLengthPleaseAttr([[6,7,8,9],[11,12,13,14]]); }, qr/Attribute \(MoreLengthPleaseAttr\) does not pass the type constraint/ - => q{MoreLengthPleaseAttr correctly fails [[6,7,8,9],[11,12,13,14]]}; + => q{MoreLengthPleaseAttr correctly fails [[6,7,8,9],[11,12,13,14]]}); ## Test PersonalInfoAttr -lives_ok sub { +is( exception { $obj->PersonalInfoAttr({name=>'John', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); -} => 'Set PersonalInfoAttr attribute without error 1'; +} => undef, 'Set PersonalInfoAttr attribute without error 1'); -lives_ok sub { +is( exception { $obj->PersonalInfoAttr({name=>'John', stats=>$obj}); -} => 'Set PersonalInfoAttr attribute without error 2'; +} => undef, 'Set PersonalInfoAttr attribute without error 2'); -throws_ok sub { +like( exception { $obj->PersonalInfoAttr({name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]}); }, qr/Attribute \(PersonalInfoAttr\) does not pass the type constraint/ - => q{PersonalInfoAttr correctly fails name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]}; + => q{PersonalInfoAttr correctly fails name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]}); -throws_ok sub { +like( exception { $obj->PersonalInfoAttr({name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); }, qr/Attribute \(PersonalInfoAttr\) does not pass the type constraint/ - => q{PersonalInfoAttr correctly fails name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}; + => q{PersonalInfoAttr correctly fails name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); ## Test MorePersonalInfoAttr -lives_ok sub { +is( exception { $obj->MorePersonalInfoAttr({name=>'Johnnap', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); -} => 'Set MorePersonalInfoAttr attribute without error 1'; +} => undef, 'Set MorePersonalInfoAttr attribute without error 1'); -throws_ok sub { +like( exception { $obj->MorePersonalInfoAttr({name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]}); }, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/ - => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]}; + => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]}); -throws_ok sub { +like( exception { $obj->MorePersonalInfoAttr({name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); }, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/ - => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}; + => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); -throws_ok sub { +like( exception { $obj->MorePersonalInfoAttr({name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); }, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/ - => q{MorePersonalInfoAttr correctly fails name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}; + => q{MorePersonalInfoAttr correctly fails name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); diff --git a/t/07-coerce.t b/t/07-coerce.t index e24ebb7..a550588 100644 --- a/t/07-coerce.t +++ b/t/07-coerce.t @@ -2,7 +2,6 @@ BEGIN { use strict; use warnings; use Test::More tests=>16; - use Test::Exception; } { diff --git a/t/09-optional.t b/t/09-optional.t index 03d0b94..99964bf 100755 --- a/t/09-optional.t +++ b/t/09-optional.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More tests=>46; -use Test::Exception; +use Test::Fatal; use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Optional); @@ -103,88 +103,88 @@ isa_ok $obj => 'Test::MooseX::Meta::TypeConstraint::Structured::Optional' # Test Insane -lives_ok sub { +is( exception { $obj->InsaneAttr([1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]); -} => 'Set InsaneAttr attribute without error [1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]'; +} => undef, 'Set InsaneAttr attribute without error [1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]'); -lives_ok sub { +is( exception { $obj->InsaneAttr([1,$obj,{name=>"John",age=>39},[1,2,3]]); -} => 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39},[1,2,3]]'; +} => undef, 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39},[1,2,3]]'); -lives_ok sub { +is( exception { $obj->InsaneAttr([1,$obj,{name=>"John",age=>39}]); -} => 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39}]'; +} => undef, 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39}]'); -throws_ok sub { +like( exception { $obj->InsaneAttr([1,$obj,{name=>"John",age=>39},[qw/a b c/]]); }, qr/Attribute \(InsaneAttr\) does not pass the type constraint/ - => q{InsaneAttr correctly fails [1,$obj,{name=>"John",age=>39},[qw/a b c/]]}; + => q{InsaneAttr correctly fails [1,$obj,{name=>"John",age=>39},[qw/a b c/]]}); -throws_ok sub { +like( exception { $obj->InsaneAttr([1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]); }, qr/Attribute \(InsaneAttr\) does not pass the type constraint/ - => q{InsaneAttr correctly fails [1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]}; + => q{InsaneAttr correctly fails [1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]}); # Test TupleOptional1Attr -lives_ok sub { +is( exception { $obj->TupleOptional1Attr([1,10,"hello"]); -} => 'Set TupleOptional1Attr attribute without error [1,10,"hello"]'; +} => undef, 'Set TupleOptional1Attr attribute without error [1,10,"hello"]'); -lives_ok sub { +is( exception { $obj->TupleOptional1Attr([1,10,$obj]); -} => 'Set TupleOptional1Attr attribute without error [1,10,$obj]'; +} => undef, 'Set TupleOptional1Attr attribute without error [1,10,$obj]'); -lives_ok sub { +is( exception { $obj->TupleOptional1Attr([1,10]); -} => 'Set TupleOptional1Attr attribute without error [1,10]'; +} => undef, 'Set TupleOptional1Attr attribute without error [1,10]'); -throws_ok sub { +like( exception { $obj->TupleOptional1Attr([1,10,[1,2,3]]); }, qr/Attribute \(TupleOptional1Attr\) does not pass the type constraint/ - => q{TupleOptional1Attr correctly fails [1,10,[1,2,3]]}; + => q{TupleOptional1Attr correctly fails [1,10,[1,2,3]]}); -throws_ok sub { +like( exception { $obj->TupleOptional1Attr([1,10,undef]); }, qr/Attribute \(TupleOptional1Attr\) does not pass the type constraint/ - => q{TupleOptional1Attr correctly fails [1,10,undef]}; + => q{TupleOptional1Attr correctly fails [1,10,undef]}); # Test TupleOptional2Attr -lives_ok sub { +is( exception { $obj->TupleOptional2Attr([1,10,{key1=>1,key2=>$obj}]); -} => 'Set TupleOptional2Attr attribute without error [1,10,{key1=>1,key2=>$obj}]'; +} => undef, 'Set TupleOptional2Attr attribute without error [1,10,{key1=>1,key2=>$obj}]'); -lives_ok sub { +is( exception { $obj->TupleOptional2Attr([1,10]); -} => 'Set TupleOptional2Attr attribute without error [1,10]'; +} => undef, 'Set TupleOptional2Attr attribute without error [1,10]'); -throws_ok sub { +like( exception { $obj->TupleOptional2Attr([1,10,[1,2,3]]); }, qr/Attribute \(TupleOptional2Attr\) does not pass the type constraint/ - => q{TupleOptional2Attr correctly fails [1,10,[1,2,3]]}; + => q{TupleOptional2Attr correctly fails [1,10,[1,2,3]]}); -throws_ok sub { +like( exception { $obj->TupleOptional2Attr([1,10,undef]); }, qr/Attribute \(TupleOptional2Attr\) does not pass the type constraint/ - => q{TupleOptional2Attr correctly fails [1,10,undef]}; + => q{TupleOptional2Attr correctly fails [1,10,undef]}); # Test DictOptional1Attr: Dict[name=>Str, age=>Int, gender=>Optional[Gender]]; -lives_ok sub { +is( exception { $obj->DictOptional1Attr({name=>"John",age=>39,gender=>"male"}); -} => 'Set DictOptional1Attr attribute without error {name=>"John",age=>39,gender=>"male"}'; +} => undef, 'Set DictOptional1Attr attribute without error {name=>"John",age=>39,gender=>"male"}'); -lives_ok sub { +is( exception { $obj->DictOptional1Attr({name=>"Vanessa",age=>34}); -} => 'Set DictOptional1Attr attribute without error {name=>"Vanessa",age=>34}'; +} => undef, 'Set DictOptional1Attr attribute without error {name=>"Vanessa",age=>34}'); -throws_ok sub { +like( exception { $obj->DictOptional1Attr({name=>"John",age=>39,gender=>undef}); }, qr/Attribute \(DictOptional1Attr\) does not pass the type constraint/ - => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>undef}}; + => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>undef}}); -throws_ok sub { +like( exception { $obj->DictOptional1Attr({name=>"John",age=>39,gender=>"aaa"}); }, qr/Attribute \(DictOptional1Attr\) does not pass the type constraint/ - => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>"aaa"}}; + => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>"aaa"}});