From: Karen Etheridge Date: Tue, 26 Oct 2010 20:16:01 +0000 (-0700) Subject: convert all uses of Test::Exception to Test::Fatal. X-Git-Tag: 0.25~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=10390913a3dce9f3c43d7797a41b2384634bc9a1;hp=e2d7e14bfc22917ac67b47eb3592b5d0ceb6f8f9;p=gitmo%2FMooseX-Types.git convert all uses of Test::Exception to Test::Fatal. --- diff --git a/Changes b/Changes index baf8063..5465d87 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for MooseX-Types +NEXT + - The test suite now uses Test::Fatal instead of Test::Exception + (Karen Etheridge). + 0.24 Sat Sep 11 19:59:18 CEST 2010 - Avoid more warnings from Moose 1.09 in tests (Dave Rolsky). diff --git a/Makefile.PL b/Makefile.PL index 97457c6..06a4181 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -12,7 +12,7 @@ all_from q{lib/MooseX/Types.pm}; build_requires q{Test::More}, '0.80'; build_requires q{FindBin}, 0; build_requires q{Test::Moose}, 0; -build_requires q{Test::Exception}, 0; +build_requires q{Test::Fatal}, 0; requires q{Moose}, '1.06'; requires q{Sub::Install}, '0.924'; diff --git a/t/13_typedecorator.t b/t/13_typedecorator.t index 800554a..949bf5a 100644 --- a/t/13_typedecorator.t +++ b/t/13_typedecorator.t @@ -3,7 +3,7 @@ use warnings; use strict; use Test::More tests => 62; -use Test::Exception; +use Test::Fatal; use FindBin; use lib "$FindBin::Bin/lib"; @@ -77,7 +77,7 @@ ok $type->arrayrefint01({a=>7,b=>8}) is_deeply $type->arrayrefint01, [qw(7 8)], => 'Assignment and coercion is correct'; -throws_ok sub { +like exception { $type->arrayrefint01([qw(a b c)]) }, qr/Attribute \(arrayrefint01\) does not pass the type constraint/ => 'Dies when values are strings'; @@ -121,7 +121,7 @@ ok $type->arrayrefint03([qw(11 12 13)]) is_deeply $type->arrayrefint03, [qw(11 12 13)], => 'Assignment is correct'; -throws_ok sub { +like exception { $type->arrayrefint03([qw(a b c)]) }, qr/Attribute \(arrayrefint03\) does not pass the type constraint/ => 'Dies when values are strings'; @@ -133,7 +133,7 @@ ok $type->StrOrArrayRef_attr('string') ok $type->StrOrArrayRef_attr([1,2,3]) => 'arrayref part of union is good'; -throws_ok sub { +like exception { $type->StrOrArrayRef_attr({a=>111}); }, qr/Attribute \(StrOrArrayRef_attr\) does not pass the type constraint/ => 'Correctly failed to use a hashref'; @@ -145,11 +145,11 @@ ok $type->AtLeastOneInt_attr([1,2]), is_deeply $type->AtLeastOneInt_attr, [1,2] => "Got expected values."; -throws_ok sub { +like exception { $type->AtLeastOneInt_attr([]); }, qr/Attribute \(AtLeastOneInt_attr\) does not pass the type constraint/ => 'properly fails to assign as []'; -throws_ok sub { +like exception { $type->AtLeastOneInt_attr(['a','b']); }, qr/Attribute \(AtLeastOneInt_attr\) does not pass the type constraint/ => 'properly fails arrayref of strings'; @@ -161,7 +161,7 @@ ok $type->pipeoverloading(1) ok $type->pipeoverloading('a') => 'String for union test accepted'; -throws_ok sub { +like exception { $type->pipeoverloading({a=>1,b=>2}); }, qr/Validation failed for 'Int|Str'/ => 'Union test corrected fails a HashRef'; @@ -173,7 +173,7 @@ ok $type->deep([[{a=>1,b=>2},{c=>3,d=>4}],[{e=>5}]]) is_deeply $type->deep, [[{a=>1,b=>2},{c=>3,d=>4}],[{e=>5}]], => 'Assignment is correct'; -throws_ok sub { +like exception { $type->deep({a=>1,b=>2}); }, qr/Attribute \(deep\) does not pass the type constraint/ => 'Deep Constraints properly fail'; @@ -185,11 +185,11 @@ ok $type->deep2([[{a=>1,b=>2},{c=>3,d=>4}],[{e=>5}]]) is_deeply $type->deep2, [[{a=>1,b=>2},{c=>3,d=>4}],[{e=>5}]], => 'Assignment is correct'; -throws_ok sub { +like exception { $type->deep2({a=>1,b=>2}); }, qr/Attribute \(deep2\) does not pass the type constraint/ => 'Deep Constraints properly fail'; -throws_ok sub { +like exception { $type->deep2([[{a=>1,b=>2},{c=>3,d=>'noway'}],[{e=>5}]]); }, qr/Attribute \(deep2\) does not pass the type constraint/ => 'Deep Constraints properly fail'; @@ -214,7 +214,7 @@ ok $type->enum('Programming') => 'Good Assignment of Programming to Enum'; -throws_ok sub { +like exception { $type->enum('ddddd'); }, qr/Attribute \(enum\) does not pass the type constraint/ => 'Enum properly fails'; @@ -226,7 +226,7 @@ ok $type->SubOfMyArrayRefInt01_attr([15,20,25]) is_deeply $type->SubOfMyArrayRefInt01_attr, [15,20,25], => 'Assignment is correct'; -throws_ok sub { +like exception { $type->SubOfMyArrayRefInt01_attr([15,5,20]); }, qr/Attribute \(SubOfMyArrayRefInt01_attr\) does not pass the type constraint/ => 'SubOfMyArrayRefInt01 Constraints properly fail'; @@ -239,17 +239,17 @@ ok $type->WierdIntergersArrayRef1_attr([5,10,1000]) is_deeply $type->WierdIntergersArrayRef1_attr, [5,10,1000], => 'Assignment is correct'; -throws_ok sub { +like exception { $type->WierdIntergersArrayRef1_attr({a=>1,b=>2}); }, qr/Attribute \(WierdIntergersArrayRef1_attr\) does not pass the type constraint/ => 'Constraints properly fail'; -throws_ok sub { +like exception { $type->WierdIntergersArrayRef1_attr([5,10,1]); }, qr/Attribute \(WierdIntergersArrayRef1_attr\) does not pass the type constraint/ => 'Constraints properly fail'; -throws_ok sub { +like exception { $type->WierdIntergersArrayRef1_attr([1]); }, qr/Attribute \(WierdIntergersArrayRef1_attr\) does not pass the type constraint/ => 'Constraints properly fail'; @@ -262,17 +262,17 @@ ok $type->WierdIntergersArrayRef2_attr([5,10,$type]) is_deeply $type->WierdIntergersArrayRef2_attr, [5,10,$type], => 'Assignment is correct'; -throws_ok sub { +like exception { $type->WierdIntergersArrayRef2_attr({a=>1,b=>2}); }, qr/Attribute \(WierdIntergersArrayRef2_attr\) does not pass the type constraint/ => 'Constraints properly fail'; -throws_ok sub { +like exception { $type->WierdIntergersArrayRef2_attr([5,10,1]); }, qr/Attribute \(WierdIntergersArrayRef2_attr\) does not pass the type constraint/ => 'Constraints properly fail'; -throws_ok sub { +like exception { $type->WierdIntergersArrayRef2_attr([1]); }, qr/Attribute \(WierdIntergersArrayRef2_attr\) does not pass the type constraint/ => 'Constraints properly fail'; diff --git a/t/14_compatibility-sub-exporter.t b/t/14_compatibility-sub-exporter.t index f220be3..1a250f1 100644 --- a/t/14_compatibility-sub-exporter.t +++ b/t/14_compatibility-sub-exporter.t @@ -2,7 +2,6 @@ BEGIN { use strict; use warnings; use Test::More; - use Test::Exception; use FindBin; use lib "$FindBin::Bin/lib"; @@ -16,4 +15,4 @@ use SubExporterCompatibility qw(MyStr something); ok MyStr->check('aaa'), "Correctly passed"; ok !MyStr->check([1]), "Correctly fails"; -ok something(), "Found the something method"; \ No newline at end of file +ok something(), "Found the something method"; diff --git a/t/15_recursion.t b/t/15_recursion.t index f98709f..6d81b73 100644 --- a/t/15_recursion.t +++ b/t/15_recursion.t @@ -21,7 +21,6 @@ BEGIN { BEGIN { use Test::More tests=>5; - use Test::Exception; ## Grab the newly created test type constraint MooseX::Types::Test::Recursion->import(':all'); diff --git a/t/18_combined_libs.t b/t/18_combined_libs.t index a7e2529..cd2178d 100644 --- a/t/18_combined_libs.t +++ b/t/18_combined_libs.t @@ -5,7 +5,7 @@ use FindBin; use lib "$FindBin::Bin/lib"; use Test::More tests => 5; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok 'Combined', qw/Foo2Alias MTFNPY NonEmptyStr/ } @@ -18,6 +18,6 @@ ok MTFNPY; is NonEmptyStr->name, 'TestLibrary2::NonEmptyStr', 'precedence for conflicting types is correct'; -throws_ok { Combined->import('NonExistentType') } +like exception { Combined->import('NonExistentType') }, qr/\Qmain asked for a type (NonExistentType) which is not found in any of the type libraries (TestLibrary TestLibrary2) combined by Combined/, 'asking for a non-existent type from a combined type library gives a useful error'; diff --git a/t/21_coerce_parameterized_types.t b/t/21_coerce_parameterized_types.t index 5b43aa3..4a25a1f 100644 --- a/t/21_coerce_parameterized_types.t +++ b/t/21_coerce_parameterized_types.t @@ -1,7 +1,6 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::Exception; use Test::More tests => 2;