From: Karen Etheridge Date: Sun, 24 Oct 2010 19:19:21 +0000 (-0700) Subject: convert all uses of Test::Exception to Test::Fatal. X-Git-Tag: 1.18~67 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=be0ed15704fdad5f2d8517380a6f24687432c1dd;p=gitmo%2FMoose.git convert all uses of Test::Exception to Test::Fatal. --- diff --git a/Makefile.PL b/Makefile.PL index 2f73418..6590d6f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -26,7 +26,7 @@ requires 'Task::Weaken' => '0'; requires 'Try::Tiny' => '0.02'; test_requires 'Test::More' => '0.88'; -test_requires 'Test::Exception' => '0.27'; +test_requires 'Test::Fatal' => '0.001'; test_requires 'Test::Requires' => '0.05'; author_requires 'DateTime'; diff --git a/author/extract-inline-tests b/author/extract-inline-tests index 77fb246..8cdb4cc 100755 --- a/author/extract-inline-tests +++ b/author/extract-inline-tests @@ -76,7 +76,7 @@ use warnings; my $base = $self->SUPER::process(@_); - $base =~ s/(\$\| = 1;)/use Test::Exception;\n$1/; + $base =~ s/(\$\| = 1;)/use Test::Fatal;\n$1/; return $base; } diff --git a/lib/Moose/Cookbook/Basics/Recipe1.pod b/lib/Moose/Cookbook/Basics/Recipe1.pod index 8fe4a8c..4fc7e0a 100644 --- a/lib/Moose/Cookbook/Basics/Recipe1.pod +++ b/lib/Moose/Cookbook/Basics/Recipe1.pod @@ -250,14 +250,14 @@ is( $point->y, 2, '... got the right value for y' ); $point->y(10); is( $point->y, 10, '... got the right (changed) value for y' ); -dies_ok { +ok exception { $point->y('Foo'); -} +}, '... cannot assign a non-Int to y'; -dies_ok { +ok exception { Point->new(); -} +}, '... must provide required attributes to new'; $point->clear(); @@ -267,19 +267,19 @@ is( $point->y, 0, '... got the right (cleared) value for y' ); # check the type constraints on the constructor -lives_ok { +ok ! exception { Point->new( x => 0, y => 0 ); -} +}, '... can assign a 0 to x and y'; -dies_ok { +ok exception { Point->new( x => 10, y => 'Foo' ); -} +}, '... cannot assign a non-Int to y'; -dies_ok { +ok exception { Point->new( x => 'Foo', y => 10 ); -} +}, '... cannot assign a non-Int to x'; # Point3D @@ -299,24 +299,24 @@ is( $point3d->x, 0, '... got the right (cleared) value for x' ); is( $point3d->y, 0, '... got the right (cleared) value for y' ); is( $point3d->z, 0, '... got the right (cleared) value for z' ); -dies_ok { +ok exception { Point3D->new( x => 10, y => 'Foo', z => 3 ); -} +}, '... cannot assign a non-Int to y'; -dies_ok { +ok exception { Point3D->new( x => 'Foo', y => 10, z => 3 ); -} +}, '... cannot assign a non-Int to x'; -dies_ok { +ok exception { Point3D->new( x => 0, y => 10, z => 'Bar' ); -} +}, '... cannot assign a non-Int to z'; -dies_ok { +ok exception { Point3D->new( x => 10, y => 3 ); -} +}, '... z is a required attribute for Point3D'; # test some class introspection diff --git a/lib/Moose/Cookbook/Basics/Recipe2.pod b/lib/Moose/Cookbook/Basics/Recipe2.pod index 9f1a4dd..9087d4e 100644 --- a/lib/Moose/Cookbook/Basics/Recipe2.pod +++ b/lib/Moose/Cookbook/Basics/Recipe2.pod @@ -236,9 +236,9 @@ my $savings_account; isa_ok( $savings_account, 'BankAccount' ); is( $savings_account->balance, 250, '... got the right savings balance' ); - lives_ok { + ok ! exception { $savings_account->withdraw(50); - } + }, '... withdrew from savings successfully'; is( $savings_account->balance, 200, '... got the right savings balance after withdrawl' ); @@ -262,9 +262,9 @@ my $savings_account; is( $checking_account->balance, 100, '... got the right checkings balance' ); - lives_ok { + ok ! exception { $checking_account->withdraw(50); - } + }, '... withdrew from checking successfully'; is( $checking_account->balance, 50, '... got the right checkings balance after withdrawl' ); @@ -272,9 +272,9 @@ my $savings_account; '... got the right savings balance after checking withdrawl (no overdraft)' ); - lives_ok { + ok ! exception { $checking_account->withdraw(200); - } + }, '... withdrew from checking successfully'; is( $checking_account->balance, 0, '... got the right checkings balance after withdrawl' ); @@ -297,16 +297,16 @@ my $savings_account; is( $checking_account->balance, 100, '... got the right checkings balance' ); - lives_ok { + ok ! exception { $checking_account->withdraw(50); - } + }, '... withdrew from checking successfully'; is( $checking_account->balance, 50, '... got the right checkings balance after withdrawl' ); - dies_ok { + ok exception { $checking_account->withdraw(200); - } + }, '... withdrawl failed due to attempted overdraft'; is( $checking_account->balance, 50, '... got the right checkings balance after withdrawl failure' ); diff --git a/lib/Moose/Cookbook/Basics/Recipe3.pod b/lib/Moose/Cookbook/Basics/Recipe3.pod index 1028ecd..e7a2b5b 100644 --- a/lib/Moose/Cookbook/Basics/Recipe3.pod +++ b/lib/Moose/Cookbook/Basics/Recipe3.pod @@ -261,9 +261,9 @@ ok(!$left->has_right, '... $left no right node yet'); is($left->node, undef, '... left has got no node value'); -lives_ok { +ok ! exception { $left->node('left') -} '... assign to lefts node'; +}, '... assign to lefts node'; is($left->node, 'left', '... left now has a node value'); @@ -278,9 +278,9 @@ ok($root->has_right, '... now we have a right node'); my $right = $root->right; isa_ok($right, 'BinaryTree'); -lives_ok { +ok ! exception { $right->node('right') -} '... assign to rights node'; +}, '... assign to rights node'; is($right->node, 'right', '... left now has a node value'); @@ -310,9 +310,9 @@ ok(isweak($left_left->{parent}), '... parent is a weakened ref'); my $left_right = BinaryTree->new; isa_ok($left_right, 'BinaryTree'); -lives_ok { +ok ! exception { $left->right($left_right) -} '... assign to rights node'; +}, '... assign to rights node'; ok($left_right->has_parent, '... left does have a parent'); @@ -324,9 +324,9 @@ ok(isweak($left_right->{parent}), '... parent is a weakened ref'); # and check the error -dies_ok { +ok exception { $left_right->right($left_left) -} '... cant assign a node which already has a parent'; +}, '... cant assign a node which already has a parent'; =end testing diff --git a/lib/Moose/Cookbook/Basics/Recipe4.pod b/lib/Moose/Cookbook/Basics/Recipe4.pod index 325b43b..ee11206 100644 --- a/lib/Moose/Cookbook/Basics/Recipe4.pod +++ b/lib/Moose/Cookbook/Basics/Recipe4.pod @@ -315,7 +315,7 @@ it under the same terms as Perl itself. use Scalar::Util 'isweak'; my $ii; -lives_ok { +ok ! exception { $ii = Company->new( { name => 'Infinity Interactive', @@ -351,7 +351,7 @@ lives_ok { ] } ); -} +}, '... created the entire company successfully'; isa_ok( $ii, 'Company' ); @@ -460,54 +460,54 @@ foreach my $employee ( @{ $new_company->employees } ) { ## check some error conditions for the subtypes -dies_ok { +ok exception { Address->new( street => {} ),; -} +}, '... we die correctly with bad args'; -dies_ok { +ok exception { Address->new( city => {} ),; -} +}, '... we die correctly with bad args'; -dies_ok { +ok exception { Address->new( state => 'British Columbia' ),; -} +}, '... we die correctly with bad args'; -lives_ok { +ok ! exception { Address->new( state => 'Connecticut' ),; -} +}, '... we live correctly with good args'; -dies_ok { +ok exception { Address->new( zip_code => 'AF5J6$' ),; -} +}, '... we die correctly with bad args'; -lives_ok { +ok ! exception { Address->new( zip_code => '06443' ),; -} +}, '... we live correctly with good args'; -dies_ok { +ok exception { Company->new(),; -} +}, '... we die correctly without good args'; -lives_ok { +ok ! exception { Company->new( name => 'Foo' ),; -} +}, '... we live correctly without good args'; -dies_ok { +ok exception { Company->new( name => 'Foo', employees => [ Person->new ] ),; -} +}, '... we die correctly with good args'; -lives_ok { +ok ! exception { Company->new( name => 'Foo', employees => [] ),; -} +}, '... we live correctly with good args'; =end testing diff --git a/lib/Moose/Cookbook/Basics/Recipe5.pod b/lib/Moose/Cookbook/Basics/Recipe5.pod index d901d57..45de2c4 100644 --- a/lib/Moose/Cookbook/Basics/Recipe5.pod +++ b/lib/Moose/Cookbook/Basics/Recipe5.pod @@ -257,24 +257,24 @@ isa_ok( $r, 'Request' ); is( $header4->content_type, 'application/pdf', '... got the right content type in the header' ); - dies_ok { + ok exception { $r->headers('Foo'); - } + }, '... dies when it gets bad params'; } { is( $r->protocol, undef, '... got nothing by default' ); - lives_ok { + ok ! exception { $r->protocol('HTTP/1.0'); - } + }, '... set the protocol correctly'; is( $r->protocol, 'HTTP/1.0', '... got nothing by default' ); - dies_ok { + ok exception { $r->protocol('http/1.0'); - } + }, '... the protocol died with bar params correctly'; } diff --git a/lib/Moose/Cookbook/Meta/Recipe6.pod b/lib/Moose/Cookbook/Meta/Recipe6.pod index 91eaac3..98cedad 100644 --- a/lib/Moose/Cookbook/Meta/Recipe6.pod +++ b/lib/Moose/Cookbook/Meta/Recipe6.pod @@ -149,11 +149,12 @@ it under the same terms as Perl itself. package main; -use Test::Exception; +use Test::More; +use Test::Fatal; my $user = MyApp::User->new( password => 'foo!' ); -throws_ok { $user->_reset_password } +like exception { $user->_reset_password }, qr/The MyApp::User::_reset_password method is private/, '_reset_password method dies if called outside MyApp::User class'; diff --git a/t/010_basics/001_basic_class_setup.t b/t/010_basics/001_basic_class_setup.t index b8130f9..2299375 100644 --- a/t/010_basics/001_basic_class_setup.t +++ b/t/010_basics/001_basic_class_setup.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -19,9 +19,9 @@ isa_ok(Foo->meta, 'Moose::Meta::Class'); ok(Foo->meta->has_method('meta'), '... we got the &meta method'); ok(Foo->isa('Moose::Object'), '... Foo is automagically a Moose::Object'); -dies_ok { +ok exception { Foo->meta->has_method() -} '... has_method requires an arg'; +}, '... has_method requires an arg'; can_ok('Foo', 'does'); diff --git a/t/010_basics/002_require_superclasses.t b/t/010_basics/002_require_superclasses.t index ad09165..04cbac7 100644 --- a/t/010_basics/002_require_superclasses.t +++ b/t/010_basics/002_require_superclasses.t @@ -6,7 +6,7 @@ use warnings; use lib 't/lib', 'lib'; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -14,7 +14,7 @@ use Test::Exception; package Bar; use Moose; - ::lives_ok { extends 'Foo' } 'loaded Foo superclass correctly'; + ::ok ! ::exception { extends 'Foo' }, 'loaded Foo superclass correctly'; } { @@ -22,7 +22,7 @@ use Test::Exception; package Baz; use Moose; - ::lives_ok { extends 'Bar' } 'loaded (inline) Bar superclass correctly'; + ::ok ! ::exception { extends 'Bar' }, 'loaded (inline) Bar superclass correctly'; } { @@ -30,7 +30,7 @@ use Test::Exception; package Foo::Bar; use Moose; - ::lives_ok { extends 'Foo', 'Bar' } + ::ok ! ::exception { extends 'Foo', 'Bar' }, 'loaded Foo and (inline) Bar superclass correctly'; } @@ -39,7 +39,7 @@ use Test::Exception; package Bling; use Moose; - ::throws_ok { extends 'No::Class' } + ::like ::exception { extends 'No::Class' }, qr{Can't locate No/Class\.pm in \@INC}, 'correct error when superclass could not be found'; } @@ -53,7 +53,7 @@ use Test::Exception; package Tiger; use Moose; - ::lives_ok { extends 'Foo', Affe => { -version => 13 } } + ::ok ! ::exception { extends 'Foo', Affe => { -version => 13 } }, 'extends with version requirement'; } @@ -61,7 +61,7 @@ use Test::Exception; package Birne; use Moose; - ::throws_ok { extends 'Foo', Affe => { -version => 42 } } + ::like ::exception { extends 'Foo', Affe => { -version => 42 } }, qr/Affe version 42 required--this is only version 23/, 'extends with unsatisfied version requirement'; } diff --git a/t/010_basics/003_super_and_override.t b/t/010_basics/003_super_and_override.t index 7ea63ea..abb3f21 100644 --- a/t/010_basics/003_super_and_override.t +++ b/t/010_basics/003_super_and_override.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -72,9 +72,9 @@ is($foo->baz(), 'Foo::baz', '... got the right value from &baz'); sub bling { 'Bling::bling' } - ::dies_ok { + ::ok ::exception { override 'bling' => sub {}; - } '... cannot override a method which has a local equivalent'; + }, '... cannot override a method which has a local equivalent'; } diff --git a/t/010_basics/004_inner_and_augment.t b/t/010_basics/004_inner_and_augment.t index eecd547..4d0e032 100644 --- a/t/010_basics/004_inner_and_augment.t +++ b/t/010_basics/004_inner_and_augment.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -77,9 +77,9 @@ is($foo->baz(), 'Foo::baz()', '... got the right value from &baz'); sub bling { 'Bling::bling' } - ::dies_ok { + ::ok ::exception { augment 'bling' => sub {}; - } '... cannot augment a method which has a local equivalent'; + }, '... cannot augment a method which has a local equivalent'; } diff --git a/t/010_basics/010_method_modifier_with_regexp.t b/t/010_basics/010_method_modifier_with_regexp.t index bc51d34..404e20b 100644 --- a/t/010_basics/010_method_modifier_with_regexp.t +++ b/t/010_basics/010_method_modifier_with_regexp.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -69,17 +69,17 @@ is( $Cat::AFTER_BARK_COUNTER, 2, 'after modifier is called twice' ); package Dog::Role; use Moose::Role; - ::dies_ok { + ::ok ::exception { before qr/bark.*/ => sub {}; - } '... this is not currently supported'; + }, '... this is not currently supported'; - ::dies_ok { + ::ok ::exception { around qr/bark.*/ => sub {}; - } '... this is not currently supported'; + }, '... this is not currently supported'; - ::dies_ok { + ::ok ::exception { after qr/bark.*/ => sub {}; - } '... this is not currently supported'; + }, '... this is not currently supported'; } diff --git a/t/010_basics/011_moose_respects_type_constraints.t b/t/010_basics/011_moose_respects_type_constraints.t index 3e0997a..e8ef84d 100644 --- a/t/010_basics/011_moose_respects_type_constraints.t +++ b/t/010_basics/011_moose_respects_type_constraints.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util::TypeConstraints; @@ -50,12 +50,12 @@ ok(!$foo_constraint->check('Bar'), '... my constraint failed correctly'); my $bar = Bar->new; isa_ok($bar, 'Bar'); -lives_ok { +ok ! exception { $bar->foo('Foo'); -} '... checked the type constraint correctly'; +}, '... checked the type constraint correctly'; -dies_ok { +ok exception { $bar->foo(Foo->new); -} '... checked the type constraint correctly'; +}, '... checked the type constraint correctly'; done_testing; diff --git a/t/010_basics/012_rebless.t b/t/010_basics/012_rebless.t index 2ec0c20..1004720 100644 --- a/t/010_basics/012_rebless.t +++ b/t/010_basics/012_rebless.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util 'blessed'; use Moose::Util::TypeConstraints; @@ -58,13 +58,13 @@ my $bar = Parent->new; is(blessed($foo), 'Parent', 'Parent->new gives a Parent object'); is($foo->name, undef, 'No name yet'); is($foo->lazy_classname, 'Parent', "lazy attribute initialized"); -lives_ok { $foo->type_constrained(10.5) } "Num type constraint for now.."; +ok ! exception { $foo->type_constrained(10.5) }, "Num type constraint for now.."; # try to rebless, except it will fail due to Child's stricter type constraint -throws_ok { Child->meta->rebless_instance($foo) } +like exception { Child->meta->rebless_instance($foo) }, qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' with value 10\.5/, '... this failed cause of type check'; -throws_ok { Child->meta->rebless_instance($bar) } +like exception { Child->meta->rebless_instance($bar) }, qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' with value 5\.5/, '... this failed cause of type check';; @@ -80,7 +80,7 @@ is($foo->name, 'Junior', "Child->name's default came through"); is($foo->lazy_classname, 'Parent', "lazy attribute was already initialized"); is($bar->lazy_classname, 'Child', "lazy attribute just now initialized"); -throws_ok { $foo->type_constrained(10.5) } +like exception { $foo->type_constrained(10.5) }, qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' with value 10\.5/, '... this failed cause of type check'; diff --git a/t/010_basics/013_create.t b/t/010_basics/013_create.t index 1c8003b..825dfd7 100644 --- a/t/010_basics/013_create.t +++ b/t/010_basics/013_create.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Class; @@ -24,13 +24,13 @@ use Test::Exception; my $new_class; -lives_ok { +ok ! exception { $new_class = Moose::Meta::Class->create( 'Class::WithFoo', superclasses => ['Class'], roles => ['Foo'], ); -} 'creating lives'; +}, 'creating lives'; ok $new_class; my $with_foo = Class::WithFoo->new; @@ -38,23 +38,23 @@ my $with_foo = Class::WithFoo->new; ok $with_foo->foo_role_applied; isa_ok $with_foo, 'Class', '$with_foo'; -throws_ok { +like exception { Moose::Meta::Class->create( 'Made::Of::Fail', superclasses => ['Class'], roles => 'Foo', # "oops" ); -} qr/You must pass an ARRAY ref of roles/; +}, qr/You must pass an ARRAY ref of roles/; ok !Made::Of::Fail->isa('UNIVERSAL'), "did not create Made::Of::Fail"; -dies_ok { +ok exception { Moose::Meta::Class->create( 'Continuing::To::Fail', superclasses => ['Class'], roles => ['Foo', 'Conflicts::With::Foo'], ); -} 'conflicting roles == death'; +}, 'conflicting roles == death'; # XXX: Continuing::To::Fail gets created anyway diff --git a/t/010_basics/016_load_into_main.t b/t/010_basics/016_load_into_main.t index 4198721..0c1c00f 100644 --- a/t/010_basics/016_load_into_main.t +++ b/t/010_basics/016_load_into_main.t @@ -4,11 +4,11 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; -lives_ok { +ok ! exception { eval 'use Moose'; -} "export to main"; +}, "export to main"; isa_ok( main->meta, "Moose::Meta::Class" ); diff --git a/t/010_basics/017_error_handling.t b/t/010_basics/017_error_handling.t index 542c79c..79222d3 100644 --- a/t/010_basics/017_error_handling.t +++ b/t/010_basics/017_error_handling.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; # This tests the error handling in Moose::Object only @@ -13,12 +13,12 @@ use Test::Exception; use Moose; } -throws_ok { Foo->new('bad') } qr/^\QSingle parameters to new() must be a HASH ref/, +like exception { Foo->new('bad') }, qr/^\QSingle parameters to new() must be a HASH ref/, 'A single non-hashref arg to a constructor throws an error'; -throws_ok { Foo->new(undef) } qr/^\QSingle parameters to new() must be a HASH ref/, +like exception { Foo->new(undef) }, qr/^\QSingle parameters to new() must be a HASH ref/, 'A single non-hashref arg to a constructor throws an error'; -throws_ok { Foo->does() } qr/^\QYou must supply a role name to does()/, +like exception { Foo->does() }, qr/^\QYou must supply a role name to does()/, 'Cannot call does() without a role name'; done_testing; diff --git a/t/010_basics/022_buildargs_warning.t b/t/010_basics/022_buildargs_warning.t index 7c99849..07b2b61 100644 --- a/t/010_basics/022_buildargs_warning.t +++ b/t/010_basics/022_buildargs_warning.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::Exception; +use Test::Fatal; use Test::More; use Test::Moose qw( with_immutable ); @@ -17,7 +17,7 @@ use Test::Requires { } with_immutable { - lives_and { + ok ! exception { stderr_like { Baz->new( x => 42, 'y' ) } qr{\QThe new() method for Baz expects a hash reference or a key/value list. You passed an odd number of arguments at t/010_basics/022_buildargs_warning.t line \E\d+}, 'warning when passing an odd number of args to new()'; diff --git a/t/010_basics/030_deprecations.t b/t/010_basics/030_deprecations.t index a1313bf..d14fe5a 100644 --- a/t/010_basics/030_deprecations.t +++ b/t/010_basics/030_deprecations.t @@ -1,14 +1,14 @@ use strict; use warnings; -use Test::Exception; +use Test::Fatal; use Test::More; use Test::Requires { 'Test::Output' => '0.01', }; -# All tests are wrapped with lives_and because the stderr output tests will +# All tests are wrapped with exception{} because the stderr output tests will # otherwise eat exceptions, and the test just dies silently. { @@ -24,7 +24,7 @@ use Test::Requires { use Moose; - ::lives_and( + ::ok not ::exception( sub { ::stderr_like{ has foo => ( traits => ['String'], @@ -68,7 +68,7 @@ use Test::Requires { use Moose; - ::lives_and( + ::ok not ::exception( sub { ::stderr_is{ has foo => ( traits => ['String'], @@ -104,7 +104,7 @@ use Test::Requires { use Moose; - ::lives_and( + ::ok not ::exception( sub { ::stderr_is{ has foo => ( traits => ['String'], @@ -139,7 +139,7 @@ use Test::Requires { use Moose; - ::lives_and( + ::ok not ::exception( sub { ::stderr_is{ has foo => ( traits => ['String'], diff --git a/t/020_attributes/001_attribute_reader_generation.t b/t/020_attributes/001_attribute_reader_generation.t index f51140b..d8dbb62 100644 --- a/t/020_attributes/001_attribute_reader_generation.t +++ b/t/020_attributes/001_attribute_reader_generation.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -44,17 +44,17 @@ use Test::Exception; can_ok($foo, 'get_foo'); is($foo->get_foo(), undef, '... got an undefined value'); - dies_ok { + ok exception { $foo->get_foo(100); - } '... get_foo is a read-only'; + }, '... get_foo is a read-only'; ok(!exists($foo->{lazy_foo}), '... no value in get_lazy_foo slot'); can_ok($foo, 'get_lazy_foo'); is($foo->get_lazy_foo(), 10, '... got an deferred value'); - dies_ok { + ok exception { $foo->get_lazy_foo(100); - } '... get_lazy_foo is a read-only'; + }, '... get_lazy_foo is a read-only'; } { diff --git a/t/020_attributes/002_attribute_writer_generation.t b/t/020_attributes/002_attribute_writer_generation.t index f166150..81d7950 100644 --- a/t/020_attributes/002_attribute_writer_generation.t +++ b/t/020_attributes/002_attribute_writer_generation.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util 'isweak'; @@ -57,33 +57,33 @@ use Scalar::Util 'isweak'; can_ok($foo, 'set_foo'); is($foo->get_foo(), undef, '... got an unset value'); - lives_ok { + ok ! exception { $foo->set_foo(100); - } '... set_foo wrote successfully'; + }, '... set_foo wrote successfully'; is($foo->get_foo(), 100, '... got the correct set value'); ok(!isweak($foo->{foo}), '... it is not a weak reference'); # required writer - dies_ok { + ok exception { Foo->new; - } '... cannot create without the required attribute'; + }, '... cannot create without the required attribute'; can_ok($foo, 'set_foo_required'); is($foo->get_foo_required(), 'required', '... got an unset value'); - lives_ok { + ok ! exception { $foo->set_foo_required(100); - } '... set_foo_required wrote successfully'; + }, '... set_foo_required wrote successfully'; is($foo->get_foo_required(), 100, '... got the correct set value'); - dies_ok { + ok exception { $foo->set_foo_required(); - } '... set_foo_required died successfully with no value'; + }, '... set_foo_required died successfully with no value'; - lives_ok { + ok ! exception { $foo->set_foo_required(undef); - } '... set_foo_required did accept undef'; + }, '... set_foo_required did accept undef'; ok(!isweak($foo->{foo_required}), '... it is not a weak reference'); @@ -91,14 +91,14 @@ use Scalar::Util 'isweak'; can_ok($foo, 'set_foo_int'); is($foo->get_foo_int(), undef, '... got an unset value'); - lives_ok { + ok ! exception { $foo->set_foo_int(100); - } '... set_foo_int wrote successfully'; + }, '... set_foo_int wrote successfully'; is($foo->get_foo_int(), 100, '... got the correct set value'); - dies_ok { + ok exception { $foo->set_foo_int("Foo"); - } '... set_foo_int died successfully'; + }, '... set_foo_int died successfully'; ok(!isweak($foo->{foo_int}), '... it is not a weak reference'); @@ -108,9 +108,9 @@ use Scalar::Util 'isweak'; can_ok($foo, 'set_foo_weak'); is($foo->get_foo_weak(), undef, '... got an unset value'); - lives_ok { + ok ! exception { $foo->set_foo_weak($test); - } '... set_foo_weak wrote successfully'; + }, '... set_foo_weak wrote successfully'; is($foo->get_foo_weak(), $test, '... got the correct set value'); ok(isweak($foo->{foo_weak}), '... it is a weak reference'); diff --git a/t/020_attributes/003_attribute_accessor_generation.t b/t/020_attributes/003_attribute_accessor_generation.t index 0603f95..532b558 100644 --- a/t/020_attributes/003_attribute_accessor_generation.t +++ b/t/020_attributes/003_attribute_accessor_generation.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util 'isweak'; @@ -90,29 +90,29 @@ use Scalar::Util 'isweak'; can_ok($foo, 'foo'); is($foo->foo(), undef, '... got an unset value'); - lives_ok { + ok ! exception { $foo->foo(100); - } '... foo wrote successfully'; + }, '... foo wrote successfully'; is($foo->foo(), 100, '... got the correct set value'); ok(!isweak($foo->{foo}), '... it is not a weak reference'); # required writer - dies_ok { + ok exception { Foo->new; - } '... cannot create without the required attribute'; + }, '... cannot create without the required attribute'; can_ok($foo, 'foo_required'); is($foo->foo_required(), 'required', '... got an unset value'); - lives_ok { + ok ! exception { $foo->foo_required(100); - } '... foo_required wrote successfully'; + }, '... foo_required wrote successfully'; is($foo->foo_required(), 100, '... got the correct set value'); - lives_ok { + ok ! exception { $foo->foo_required(undef); - } '... foo_required did not die with undef'; + }, '... foo_required did not die with undef'; is($foo->foo_required, undef, "value is undef"); @@ -129,14 +129,14 @@ use Scalar::Util 'isweak'; can_ok($foo, 'foo_int'); is($foo->foo_int(), undef, '... got an unset value'); - lives_ok { + ok ! exception { $foo->foo_int(100); - } '... foo_int wrote successfully'; + }, '... foo_int wrote successfully'; is($foo->foo_int(), 100, '... got the correct set value'); - dies_ok { + ok exception { $foo->foo_int("Foo"); - } '... foo_int died successfully'; + }, '... foo_int died successfully'; ok(!isweak($foo->{foo_int}), '... it is not a weak reference'); @@ -146,9 +146,9 @@ use Scalar::Util 'isweak'; can_ok($foo, 'foo_weak'); is($foo->foo_weak(), undef, '... got an unset value'); - lives_ok { + ok ! exception { $foo->foo_weak($test); - } '... foo_weak wrote successfully'; + }, '... foo_weak wrote successfully'; is($foo->foo_weak(), $test, '... got the correct set value'); ok(isweak($foo->{foo_weak}), '... it is a weak reference'); @@ -156,14 +156,14 @@ use Scalar::Util 'isweak'; can_ok( $foo, 'foo_deref'); is_deeply( [$foo->foo_deref()], [], '... default default value'); my @list; - lives_ok { + ok ! exception { @list = $foo->foo_deref(); - } "... doesn't deref undef value"; + }, "... doesn't deref undef value"; is_deeply( \@list, [], "returns empty list in list context"); - lives_ok { + ok ! exception { $foo->foo_deref( [ qw/foo bar gorch/ ] ); - } '... foo_deref wrote successfully'; + }, '... foo_deref wrote successfully'; is( Scalar::Util::reftype( scalar $foo->foo_deref() ), "ARRAY", "returns an array reference in scalar context" ); is_deeply( scalar($foo->foo_deref()), [ qw/foo bar gorch/ ], "correct array" ); @@ -175,9 +175,9 @@ use Scalar::Util 'isweak'; can_ok( $foo, 'foo_deref' ); is_deeply( [$foo->foo_deref_ro()], [], "... default default value" ); - dies_ok { + ok exception { $foo->foo_deref_ro( [] ); - } "... read only"; + }, "... read only"; $foo->{foo_deref_ro} = [qw/la la la/]; @@ -188,14 +188,14 @@ use Scalar::Util 'isweak'; is_deeply( { $foo->foo_deref_hash() }, {}, "... default default value" ); my %hash; - lives_ok { + ok ! exception { %hash = $foo->foo_deref_hash(); - } "... doesn't deref undef value"; + }, "... doesn't deref undef value"; is_deeply( \%hash, {}, "returns empty list in list context"); - lives_ok { + ok ! exception { $foo->foo_deref_hash( { foo => 1, bar => 2 } ); - } '... foo_deref_hash wrote successfully'; + }, '... foo_deref_hash wrote successfully'; is_deeply( scalar($foo->foo_deref_hash), { foo => 1, bar => 2 }, "scalar context" ); diff --git a/t/020_attributes/004_attribute_triggers.t b/t/020_attributes/004_attribute_triggers.t index b8ec580..803cc63 100644 --- a/t/020_attributes/004_attribute_triggers.t +++ b/t/020_attributes/004_attribute_triggers.t @@ -6,7 +6,7 @@ use warnings; use Scalar::Util 'isweak'; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -50,27 +50,27 @@ use Test::Exception; my $baz = Baz->new; isa_ok($baz, 'Baz'); - lives_ok { + ok ! exception { $foo->bar($bar); - } '... did not die setting bar'; + }, '... did not die setting bar'; is($foo->bar, $bar, '... set the value foo.bar correctly'); is($bar->foo, $foo, '... which in turn set the value bar.foo correctly'); ok(isweak($bar->{foo}), '... bar.foo is a weak reference'); - lives_ok { + ok ! exception { $foo->bar(undef); - } '... did not die un-setting bar'; + }, '... did not die un-setting bar'; is($foo->bar, undef, '... set the value foo.bar correctly'); is($bar->foo, $foo, '... which in turn set the value bar.foo correctly'); # test the writer - lives_ok { + ok ! exception { $foo->set_baz($baz); - } '... did not die setting baz'; + }, '... did not die setting baz'; is($foo->get_baz, $baz, '... set the value foo.baz correctly'); is($baz->foo, $foo, '... which in turn set the value baz.foo correctly'); @@ -105,13 +105,13 @@ use Test::Exception; package Bling; use Moose; - ::dies_ok { + ::ok ::exception { has('bling' => (is => 'rw', trigger => 'Fail')); - } '... a trigger must be a CODE ref'; + }, '... a trigger must be a CODE ref'; - ::dies_ok { + ::ok ::exception { has('bling' => (is => 'rw', trigger => [])); - } '... a trigger must be a CODE ref'; + }, '... a trigger must be a CODE ref'; } # Triggers do not fire on built values @@ -140,7 +140,7 @@ use Test::Exception; { my $blarg; - lives_ok { $blarg = Blarg->new; } 'Blarg->new() lives'; + ok ! exception { $blarg = Blarg->new; }, 'Blarg->new() lives'; ok($blarg, 'Have a $blarg'); foreach my $attr (qw/foo bar baz/) { is($blarg->$attr(), "default $attr value", "$attr has default value"); @@ -152,7 +152,7 @@ use Test::Exception; is_deeply(\%Blarg::trigger_calls, { map { $_ => 1 } qw/foo bar baz/ }, 'All triggers fired once on assign'); is_deeply(\%Blarg::trigger_vals, { map { $_ => "Different $_ value" } qw/foo bar baz/ }, 'All triggers given assigned values'); - lives_ok { $blarg => Blarg->new( map { $_ => "Yet another $_ value" } qw/foo bar baz/ ) } '->new() with parameters'; + ok ! exception { $blarg => Blarg->new( map { $_ => "Yet another $_ value" } qw/foo bar baz/ ) }, '->new() with parameters'; is_deeply(\%Blarg::trigger_calls, { map { $_ => 2 } qw/foo bar baz/ }, 'All triggers fired once on construct'); is_deeply(\%Blarg::trigger_vals, { map { $_ => "Yet another $_ value" } qw/foo bar baz/ }, 'All triggers given assigned values'); } diff --git a/t/020_attributes/005_attribute_does.t b/t/020_attributes/005_attribute_does.t index 945717b..61332a5 100644 --- a/t/020_attributes/005_attribute_does.t +++ b/t/020_attributes/005_attribute_does.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -46,25 +46,25 @@ isa_ok($foo, 'Foo::Class'); my $bar = Bar::Class->new; isa_ok($bar, 'Bar::Class'); -lives_ok { +ok ! exception { $foo->bar($bar); -} '... bar passed the type constraint okay'; +}, '... bar passed the type constraint okay'; -dies_ok { +ok exception { $foo->bar($foo); -} '... foo did not pass the type constraint okay'; +}, '... foo did not pass the type constraint okay'; -lives_ok { +ok ! exception { $foo->baz($bar); -} '... baz passed the type constraint okay'; +}, '... baz passed the type constraint okay'; -dies_ok { +ok exception { $foo->baz($foo); -} '... foo did not pass the type constraint okay'; +}, '... foo did not pass the type constraint okay'; -lives_ok { +ok ! exception { $bar->foo($foo); -} '... foo passed the type constraint okay'; +}, '... foo passed the type constraint okay'; @@ -76,9 +76,9 @@ lives_ok { # if isa and does appear together, then see if Class->does(Role) # if it does not,.. we have a conflict... so we die loudly - ::dies_ok { + ::ok ::exception { has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class'); - } '... cannot have a does() which is not done by the isa()'; + }, '... cannot have a does() which is not done by the isa()'; } { @@ -93,9 +93,9 @@ lives_ok { # if isa and does appear together, then see if Class->does(Role) # if it does not,.. we have a conflict... so we die loudly - ::dies_ok { + ::ok ::exception { has 'foo' => (isa => 'Bling', does => 'Bar::Class'); - } '... cannot have a isa() which is cannot does()'; + }, '... cannot have a isa() which is cannot does()'; } done_testing; diff --git a/t/020_attributes/006_attribute_required.t b/t/020_attributes/006_attribute_required.t index 5df07cc..f226544 100644 --- a/t/020_attributes/006_attribute_required.t +++ b/t/020_attributes/006_attribute_required.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -44,25 +44,25 @@ use Test::Exception; } #Yeah.. this doesn't work like this anymore, see below. (groditi) -#throws_ok { +#like exception { # Foo->new(bar => 10, baz => undef); -#} qr/^Attribute \(baz\) is required and cannot be undef/, '... must supply all the required attribute'; +#}, qr/^Attribute \(baz\) is required and cannot be undef/, '... must supply all the required attribute'; -#throws_ok { +#like exception { # Foo->new(bar => 10, boo => undef); -#} qr/^Attribute \(boo\) is required and cannot be undef/, '... must supply all the required attribute'; +#}, qr/^Attribute \(boo\) is required and cannot be undef/, '... must supply all the required attribute'; -lives_ok { +ok ! exception { Foo->new(bar => 10, baz => undef); -} '... undef is a valid attribute value'; +}, '... undef is a valid attribute value'; -lives_ok { +ok ! exception { Foo->new(bar => 10, boo => undef); -} '... undef is a valid attribute value'; +}, '... undef is a valid attribute value'; -throws_ok { +like exception { Foo->new; -} qr/^Attribute \(bar\) is required/, '... must supply all the required attribute'; +}, qr/^Attribute \(bar\) is required/, '... must supply all the required attribute'; done_testing; diff --git a/t/020_attributes/007_attribute_custom_metaclass.t b/t/020_attributes/007_attribute_custom_metaclass.t index 58c1ec1..c1f518e 100644 --- a/t/020_attributes/007_attribute_custom_metaclass.t +++ b/t/020_attributes/007_attribute_custom_metaclass.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -53,9 +53,9 @@ use Test::Exception; package Bar; use Moose; - ::lives_ok { + ::ok ! ::exception { has 'bar' => (metaclass => 'Bar::Meta::Attribute'); - } '... the attribute metaclass need not be a Moose::Meta::Attribute as long as it behaves'; + }, '... the attribute metaclass need not be a Moose::Meta::Attribute as long as it behaves'; } { @@ -70,13 +70,13 @@ use Test::Exception; package Another::Foo; use Moose; - ::lives_ok { + ::ok ! ::exception { has 'foo' => (metaclass => 'Foo'); - } '... the attribute metaclass alias worked correctly'; + }, '... the attribute metaclass alias worked correctly'; - ::lives_ok { + ::ok ! ::exception { has 'bar' => (metaclass => 'Bar', is => 'bare'); - } '... the attribute metaclass alias worked correctly'; + }, '... the attribute metaclass alias worked correctly'; } { diff --git a/t/020_attributes/008_attribute_type_unions.t b/t/020_attributes/008_attribute_type_unions.t index f2ad610..ac30ddc 100644 --- a/t/020_attributes/008_attribute_type_unions.t +++ b/t/020_attributes/008_attribute_type_unions.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -17,39 +17,39 @@ use Test::Exception; my $foo = Foo->new; isa_ok($foo, 'Foo'); -lives_ok { +ok ! exception { $foo->bar([]) -} '... set bar successfully with an ARRAY ref'; +}, '... set bar successfully with an ARRAY ref'; -lives_ok { +ok ! exception { $foo->bar({}) -} '... set bar successfully with a HASH ref'; +}, '... set bar successfully with a HASH ref'; -dies_ok { +ok exception { $foo->bar(100) -} '... couldnt set bar successfully with a number'; +}, '... couldnt set bar successfully with a number'; -dies_ok { +ok exception { $foo->bar(sub {}) -} '... couldnt set bar successfully with a CODE ref'; +}, '... couldnt set bar successfully with a CODE ref'; # check the constructor -lives_ok { +ok ! exception { Foo->new(bar => []) -} '... created new Foo with bar successfully set with an ARRAY ref'; +}, '... created new Foo with bar successfully set with an ARRAY ref'; -lives_ok { +ok ! exception { Foo->new(bar => {}) -} '... created new Foo with bar successfully set with a HASH ref'; +}, '... created new Foo with bar successfully set with a HASH ref'; -dies_ok { +ok exception { Foo->new(bar => 50) -} '... didnt create a new Foo with bar as a number'; +}, '... didnt create a new Foo with bar as a number'; -dies_ok { +ok exception { Foo->new(bar => sub {}) -} '... didnt create a new Foo with bar as a CODE ref'; +}, '... didnt create a new Foo with bar as a CODE ref'; { package Bar; @@ -61,38 +61,38 @@ dies_ok { my $bar = Bar->new; isa_ok($bar, 'Bar'); -lives_ok { +ok ! exception { $bar->baz('a string') -} '... set baz successfully with a string'; +}, '... set baz successfully with a string'; -lives_ok { +ok ! exception { $bar->baz(sub { 'a sub' }) -} '... set baz successfully with a CODE ref'; +}, '... set baz successfully with a CODE ref'; -dies_ok { +ok exception { $bar->baz(\(my $var1)) -} '... couldnt set baz successfully with a SCALAR ref'; +}, '... couldnt set baz successfully with a SCALAR ref'; -dies_ok { +ok exception { $bar->baz({}) -} '... couldnt set bar successfully with a HASH ref'; +}, '... couldnt set bar successfully with a HASH ref'; # check the constructor -lives_ok { +ok ! exception { Bar->new(baz => 'a string') -} '... created new Bar with baz successfully set with a string'; +}, '... created new Bar with baz successfully set with a string'; -lives_ok { +ok ! exception { Bar->new(baz => sub { 'a sub' }) -} '... created new Bar with baz successfully set with a CODE ref'; +}, '... created new Bar with baz successfully set with a CODE ref'; -dies_ok { +ok exception { Bar->new(baz => \(my $var2)) -} '... didnt create a new Bar with baz as a number'; +}, '... didnt create a new Bar with baz as a number'; -dies_ok { +ok exception { Bar->new(baz => {}) -} '... didnt create a new Bar with baz as a HASH ref'; +}, '... didnt create a new Bar with baz as a HASH ref'; done_testing; diff --git a/t/020_attributes/009_attribute_inherited_slot_specs.t b/t/020_attributes/009_attribute_inherited_slot_specs.t index 71bc254..2e089cb 100644 --- a/t/020_attributes/009_attribute_inherited_slot_specs.t +++ b/t/020_attributes/009_attribute_inherited_slot_specs.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -59,138 +59,138 @@ use Test::Exception; extends 'Foo'; - ::lives_ok { + ::ok ! ::exception { has '+bar' => (default => 'Bar::bar'); - } '... we can change the default attribute option'; + }, '... we can change the default attribute option'; - ::lives_ok { + ::ok ! ::exception { has '+baz' => (isa => 'ArrayRef'); - } '... we can add change the isa as long as it is a subtype'; + }, '... we can add change the isa as long as it is a subtype'; - ::lives_ok { + ::ok ! ::exception { has '+foo' => (coerce => 1); - } '... we can change/add coerce as an attribute option'; + }, '... we can change/add coerce as an attribute option'; - ::lives_ok { + ::ok ! ::exception { has '+gorch' => (required => 1); - } '... we can change/add required as an attribute option'; + }, '... we can change/add required as an attribute option'; - ::lives_ok { + ::ok ! ::exception { has '+gloum' => (lazy => 1); - } '... we can change/add lazy as an attribute option'; + }, '... we can change/add lazy as an attribute option'; - ::lives_ok { + ::ok ! ::exception { has '+gloum' => (lazy_build => 1); - } '... we can add lazy_build as an attribute option'; + }, '... we can add lazy_build as an attribute option'; - ::lives_ok { + ::ok ! ::exception { has '+bunch_of_stuff' => (isa => 'ArrayRef[Int]'); - } '... extend an attribute with parameterized type'; + }, '... extend an attribute with parameterized type'; - ::lives_ok { + ::ok ! ::exception { has '+one_last_one' => (isa => subtype('Ref', where { blessed $_ eq 'CODE' })); - } '... extend an attribute with anon-subtype'; + }, '... extend an attribute with anon-subtype'; - ::lives_ok { + ::ok ! ::exception { has '+one_last_one' => (isa => 'Value'); - } '... now can extend an attribute with a non-subtype'; + }, '... now can extend an attribute with a non-subtype'; - ::lives_ok { + ::ok ! ::exception { has '+fleem' => (weak_ref => 1); - } '... now allowed to add the weak_ref option via inheritance'; + }, '... now allowed to add the weak_ref option via inheritance'; - ::lives_ok { + ::ok ! ::exception { has '+bling' => (handles => ['hello']); - } '... we can add the handles attribute option'; + }, '... we can add the handles attribute option'; # this one will *not* work here .... - ::dies_ok { + ::ok ::exception { has '+blang' => (handles => ['hello']); - } '... we can not alter the handles attribute option'; - ::lives_ok { + }, '... we can not alter the handles attribute option'; + ::ok ! ::exception { has '+fail' => (isa => 'Ref'); - } '... can now create an attribute with an improper subtype relation'; - ::dies_ok { + }, '... can now create an attribute with an improper subtype relation'; + ::ok ::exception { has '+other_fail' => (trigger => sub {}); - } '... cannot create an attribute with an illegal option'; - ::throws_ok { + }, '... cannot create an attribute with an illegal option'; + ::like ::exception { has '+does_not_exist' => (isa => 'Str'); - } qr/in Bar/, '... cannot extend a non-existing attribute'; + }, qr/in Bar/, '... cannot extend a non-existing attribute'; } my $foo = Foo->new; isa_ok($foo, 'Foo'); is($foo->foo, undef, '... got the right undef default value'); -lives_ok { $foo->foo('FooString') } '... assigned foo correctly'; +ok ! exception { $foo->foo('FooString') }, '... assigned foo correctly'; is($foo->foo, 'FooString', '... got the right value for foo'); -dies_ok { $foo->foo([]) } '... foo is not coercing (as expected)'; +ok exception { $foo->foo([]) }, '... foo is not coercing (as expected)'; is($foo->bar, 'Foo::bar', '... got the right default value'); -dies_ok { $foo->bar(10) } '... Foo::bar is a read/only attr'; +ok exception { $foo->bar(10) }, '... Foo::bar is a read/only attr'; is($foo->baz, undef, '... got the right undef default value'); { my $hash_ref = {}; - lives_ok { $foo->baz($hash_ref) } '... Foo::baz accepts hash refs'; + ok ! exception { $foo->baz($hash_ref) }, '... Foo::baz accepts hash refs'; is($foo->baz, $hash_ref, '... got the right value assigned to baz'); my $array_ref = []; - lives_ok { $foo->baz($array_ref) } '... Foo::baz accepts an array ref'; + ok ! exception { $foo->baz($array_ref) }, '... Foo::baz accepts an array ref'; is($foo->baz, $array_ref, '... got the right value assigned to baz'); my $scalar_ref = \(my $var); - lives_ok { $foo->baz($scalar_ref) } '... Foo::baz accepts scalar ref'; + ok ! exception { $foo->baz($scalar_ref) }, '... Foo::baz accepts scalar ref'; is($foo->baz, $scalar_ref, '... got the right value assigned to baz'); - lives_ok { $foo->bunch_of_stuff([qw[one two three]]) } '... Foo::bunch_of_stuff accepts an array of strings'; + ok ! exception { $foo->bunch_of_stuff([qw[one two three]]) }, '... Foo::bunch_of_stuff accepts an array of strings'; - lives_ok { $foo->one_last_one(sub { 'Hello World'}) } '... Foo::one_last_one accepts a code ref'; + ok ! exception { $foo->one_last_one(sub { 'Hello World'}) }, '... Foo::one_last_one accepts a code ref'; my $code_ref = sub { 1 }; - lives_ok { $foo->baz($code_ref) } '... Foo::baz accepts a code ref'; + ok ! exception { $foo->baz($code_ref) }, '... Foo::baz accepts a code ref'; is($foo->baz, $code_ref, '... got the right value assigned to baz'); } -dies_ok { +ok exception { Bar->new; -} '... cannot create Bar without required gorch param'; +}, '... cannot create Bar without required gorch param'; my $bar = Bar->new(gorch => 'Bar::gorch'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Foo'); is($bar->foo, undef, '... got the right undef default value'); -lives_ok { $bar->foo('FooString') } '... assigned foo correctly'; +ok ! exception { $bar->foo('FooString') }, '... assigned foo correctly'; is($bar->foo, 'FooString', '... got the right value for foo'); -lives_ok { $bar->foo([]) } '... assigned foo correctly'; +ok ! exception { $bar->foo([]) }, '... assigned foo correctly'; is($bar->foo, 'FooArrayRef', '... got the right value for foo'); is($bar->gorch, 'Bar::gorch', '... got the right default value'); is($bar->bar, 'Bar::bar', '... got the right default value'); -dies_ok { $bar->bar(10) } '... Bar::bar is a read/only attr'; +ok exception { $bar->bar(10) }, '... Bar::bar is a read/only attr'; is($bar->baz, undef, '... got the right undef default value'); { my $hash_ref = {}; - dies_ok { $bar->baz($hash_ref) } '... Bar::baz does not accept hash refs'; + ok exception { $bar->baz($hash_ref) }, '... Bar::baz does not accept hash refs'; my $array_ref = []; - lives_ok { $bar->baz($array_ref) } '... Bar::baz can accept an array ref'; + ok ! exception { $bar->baz($array_ref) }, '... Bar::baz can accept an array ref'; is($bar->baz, $array_ref, '... got the right value assigned to baz'); my $scalar_ref = \(my $var); - dies_ok { $bar->baz($scalar_ref) } '... Bar::baz does not accept a scalar ref'; + ok exception { $bar->baz($scalar_ref) }, '... Bar::baz does not accept a scalar ref'; - lives_ok { $bar->bunch_of_stuff([1, 2, 3]) } '... Bar::bunch_of_stuff accepts an array of ints'; - dies_ok { $bar->bunch_of_stuff([qw[one two three]]) } '... Bar::bunch_of_stuff does not accept an array of strings'; + ok ! exception { $bar->bunch_of_stuff([1, 2, 3]) }, '... Bar::bunch_of_stuff accepts an array of ints'; + ok exception { $bar->bunch_of_stuff([qw[one two three]]) }, '... Bar::bunch_of_stuff does not accept an array of strings'; my $code_ref = sub { 1 }; - dies_ok { $bar->baz($code_ref) } '... Bar::baz does not accept a code ref'; + ok exception { $bar->baz($code_ref) }, '... Bar::baz does not accept a code ref'; } # check some meta-stuff diff --git a/t/020_attributes/010_attribute_delegation.t b/t/020_attributes/010_attribute_delegation.t index bcd4cc7..c2f50b9 100644 --- a/t/020_attributes/010_attribute_delegation.t +++ b/t/020_attributes/010_attribute_delegation.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; # ------------------------------------------------------------------- @@ -77,9 +77,9 @@ isa_ok($foo, 'Foo'); is($foo->bar, 25, '... got the right foo->bar'); -lives_ok { +ok ! exception { $bar->foo($foo); -} '... assigned the new Foo to Bar->foo'; +}, '... assigned the new Foo to Bar->foo'; is($bar->foo, $foo, '... assigned bar->foo with the new Foo'); @@ -323,13 +323,13 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); package Goorch::Autoloaded; use Moose; - ::dies_ok { + ::ok ::exception { has 'foo' => ( is => 'rw', default => sub { Foo::Autoloaded->new }, handles => qr/bar/ ); - } '... you cannot delegate to AUTOLOADED class with regexp'; + }, '... you cannot delegate to AUTOLOADED class with regexp'; } # check HASH based delegation w/ AUTOLOAD @@ -368,9 +368,9 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); is($foo->bar, 25, '... got the right foo->bar'); - lives_ok { + ok ! exception { $bar->foo($foo); - } '... assigned the new Foo to Bar->foo'; + }, '... assigned the new Foo to Bar->foo'; is($bar->foo, $foo, '... assigned bar->foo with the new Foo'); @@ -414,9 +414,9 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); is($foo->bar, 25, '... got the right foo->bar'); - lives_ok { + ok ! exception { $baz->foo($foo); - } '... assigned the new Foo to Baz->foo'; + }, '... assigned the new Foo to Baz->foo'; is($baz->foo, $foo, '... assigned baz->foo with the new Foo'); @@ -445,15 +445,15 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); # not an object { my $i = Bar->new(foo => undef); - throws_ok { $i->foo_bar } qr/is not defined/, + like exception { $i->foo_bar }, qr/is not defined/, 'useful error from unblessed reference'; my $j = Bar->new(foo => []); - throws_ok { $j->foo_bar } qr/is not an object \(got 'ARRAY/, + like exception { $j->foo_bar }, qr/is not an object \(got 'ARRAY/, 'useful error from unblessed reference'; my $k = Bar->new(foo => "Foo"); - lives_ok { $k->foo_baz } "but not for class name"; + ok ! exception { $k->foo_baz }, "but not for class name"; } done_testing; diff --git a/t/020_attributes/011_more_attr_delegation.t b/t/020_attributes/011_more_attr_delegation.t index 18b8fc1..b2f278b 100644 --- a/t/020_attributes/011_more_attr_delegation.t +++ b/t/020_attributes/011_more_attr_delegation.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -94,41 +94,41 @@ do not fail at compile time. sub parent_method_1 { "parent_1" } ::can_ok('Parent', 'parent_method_1'); - ::dies_ok { + ::ok ::exception { has child_a => ( is => "ro", default => sub { ChildA->new }, handles => qr/.*/, ); - } "all_methods requires explicit isa"; + }, "all_methods requires explicit isa"; - ::lives_ok { + ::ok ! ::exception { has child_a => ( isa => "ChildA", is => "ro", default => sub { ChildA->new }, handles => qr/.*/, ); - } "allow all_methods with explicit isa"; + }, "allow all_methods with explicit isa"; - ::lives_ok { + ::ok ! ::exception { has child_b => ( is => 'ro', default => sub { ChildB->new }, handles => [qw/child_b_method_1/], ); - } "don't need to declare isa if method list is predefined"; + }, "don't need to declare isa if method list is predefined"; - ::lives_ok { + ::ok ! ::exception { has child_c => ( isa => "ChildC", is => "ro", default => sub { ChildC->new }, handles => qr/_la$/, ); - } "can declare regex collector"; + }, "can declare regex collector"; - ::dies_ok { + ::ok ::exception { has child_d => ( is => "ro", default => sub { ChildD->new }, @@ -136,9 +136,9 @@ do not fail at compile time. my ( $class, $delegate_class ) = @_; } ); - } "can't create attr with generative handles parameter and no isa"; + }, "can't create attr with generative handles parameter and no isa"; - ::lives_ok { + ::ok ! ::exception { has child_d => ( isa => "ChildD", is => "ro", @@ -148,19 +148,19 @@ do not fail at compile time. return; } ); - } "can't create attr with generative handles parameter and no isa"; + }, "can't create attr with generative handles parameter and no isa"; - ::lives_ok { + ::ok ! ::exception { has child_e => ( isa => "ChildE", is => "ro", default => sub { ChildE->new }, handles => ["child_e_method_2"], ); - } "can delegate to non moose class using explicit method list"; + }, "can delegate to non moose class using explicit method list"; my $delegate_class; - ::lives_ok { + ::ok ! ::exception { has child_f => ( isa => "ChildF", is => "ro", @@ -170,30 +170,30 @@ do not fail at compile time. return; }, ); - } "subrefs on non moose class give no meta"; + }, "subrefs on non moose class give no meta"; ::is( $delegate_class, "ChildF", "plain classes are handed down to subs" ); - ::lives_ok { + ::ok ! ::exception { has child_g => ( isa => "ChildG", default => sub { ChildG->new }, handles => ["child_g_method_1"], ); - } "can delegate to object even without explicit reader"; + }, "can delegate to object even without explicit reader"; ::can_ok('Parent', 'parent_method_1'); - ::dies_ok { + ::ok ::exception { has child_h => ( isa => "ChildH", is => "ro", default => sub { ChildH->new }, handles => sub { map { $_, $_ } $_[1]->get_all_method_names }, ); - } "Can't override exisiting class method in delegate"; + }, "Can't override exisiting class method in delegate"; ::can_ok('Parent', 'parent_method_1'); - ::lives_ok { + ::ok ! ::exception { has child_i => ( isa => "ChildI", is => "ro", @@ -203,7 +203,7 @@ do not fail at compile time. $_[1]->get_all_method_names; }, ); - } "Test handles code ref for skipping predefined methods"; + }, "Test handles code ref for skipping predefined methods"; sub parent_method { "p" } diff --git a/t/020_attributes/012_misc_attribute_tests.t b/t/020_attributes/012_misc_attribute_tests.t index 7f855a3..dc827ff 100644 --- a/t/020_attributes/012_misc_attribute_tests.t +++ b/t/020_attributes/012_misc_attribute_tests.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -57,13 +57,13 @@ use Test::Exception; my $test = Test::For::Lazy::TypeConstraint->new; isa_ok($test, 'Test::For::Lazy::TypeConstraint'); - dies_ok { + ok exception { $test->bad_lazy_attr; - } '... this does not work'; + }, '... this does not work'; - lives_ok { + ok ! exception { $test->good_lazy_attr; - } '... this does not work'; + }, '... this does not work'; } { @@ -118,9 +118,9 @@ use Test::Exception; } - dies_ok { + ok exception { Test::UndefDefault::Attributes->new; - } '... default must return a value which passes the type constraint'; + }, '... default must return a value which passes the type constraint'; } @@ -138,9 +138,9 @@ use Test::Exception; is($moose_obj->a_str( 'foobar' ), 'foobar', 'setter took string'); ok($moose_obj, 'this is a *not* a string'); - throws_ok { + like exception { $moose_obj->a_str( $moose_obj ) - } qr/Attribute \(a_str\) does not pass the type constraint because\: Validation failed for 'Str' with value OverloadedStr=HASH\(0x.+?\)/, + }, qr/Attribute \(a_str\) does not pass the type constraint because\: Validation failed for 'Str' with value OverloadedStr=HASH\(0x.+?\)/, '... dies without overloading the string'; } @@ -153,14 +153,14 @@ use Test::Exception; has 'a_num' => ( isa => 'Int' , is => 'rw', default => 7.5 ); } - throws_ok { + like exception { OverloadBreaker->new; - } qr/Attribute \(a_num\) does not pass the type constraint because\: Validation failed for 'Int' with value 7\.5/, + }, qr/Attribute \(a_num\) does not pass the type constraint because\: Validation failed for 'Int' with value 7\.5/, '... this doesnt trip overload to break anymore '; - lives_ok { + ok ! exception { OverloadBreaker->new(a_num => 5); - } '... this works fine though'; + }, '... this works fine though'; } @@ -192,9 +192,9 @@ use Test::Exception; has 'foo' => ( required => 1, builder => 'build_foo', is => 'ro'); } - dies_ok { + ok exception { Test::Builder::Attribute::Broken->new; - } '... no builder, wtf'; + }, '... no builder, wtf'; } @@ -244,7 +244,7 @@ use Test::Exception; ok(!$instance->_has_foo, "noo _foo value yet"); is($instance->foo, 'works', "foo builder works"); is($instance->_foo, 'works too', "foo builder works too"); - throws_ok { $instance->fool } + like exception { $instance->fool }, qr/Test::LazyBuild::Attribute does not support builder method \'_build_fool\' for attribute \'fool\'/, "Correct error when a builder method is not present"; @@ -256,8 +256,8 @@ use Test::Exception; use Moose; } -lives_ok { OutOfClassTest::has('foo', is => 'bare'); } 'create attr via direct sub call'; -lives_ok { OutOfClassTest->can('has')->('bar', is => 'bare'); } 'create attr via can'; +ok ! exception { OutOfClassTest::has('foo', is => 'bare'); }, 'create attr via direct sub call'; +ok ! exception { OutOfClassTest->can('has')->('bar', is => 'bare'); }, 'create attr via can'; ok(OutOfClassTest->meta->get_attribute('foo'), 'attr created from sub call'); ok(OutOfClassTest->meta->get_attribute('bar'), 'attr created from can'); @@ -268,7 +268,7 @@ ok(OutOfClassTest->meta->get_attribute('bar'), 'attr created from can'); package Foo; use Moose; - ::throws_ok { has 'foo' => ( 'ro', isa => 'Str' ) } + ::like ::exception { has 'foo' => ( 'ro', isa => 'Str' ) }, qr/^Usage/, 'has throws error with odd number of attribute options'; } diff --git a/t/020_attributes/013_attr_dereference_test.t b/t/020_attributes/013_attr_dereference_test.t index fa78897..42953be 100644 --- a/t/020_attributes/013_attr_dereference_test.t +++ b/t/020_attributes/013_attr_dereference_test.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -15,14 +15,14 @@ use Test::Exception; use Moose; use Moose::Util::TypeConstraints; - ::lives_ok { + ::ok ! ::exception { has 'customers' => ( is => 'ro', isa => subtype('ArrayRef' => where { (blessed($_) && $_->isa('Customer') || return) for @$_; 1 }), auto_deref => 1, ); - } '... successfully created attr'; + }, '... successfully created attr'; } { @@ -68,13 +68,13 @@ use Test::Exception; { my $autoderef = AutoDeref->new; - dies_ok { + ok exception { $autoderef->bar(1, 2, 3); - } '... its auto-de-ref-ing, not auto-en-ref-ing'; + }, '... its auto-de-ref-ing, not auto-en-ref-ing'; - lives_ok { + ok ! exception { $autoderef->bar([ 1, 2, 3 ]) - } '... set the results of bar correctly'; + }, '... set the results of bar correctly'; is_deeply [ $autoderef->bar ], [ 1, 2, 3 ], '... auto-dereffed correctly'; } diff --git a/t/020_attributes/014_misc_attribute_coerce_lazy.t b/t/020_attributes/014_misc_attribute_coerce_lazy.t index fe61494..67f9100 100644 --- a/t/020_attributes/014_misc_attribute_coerce_lazy.t +++ b/t/020_attributes/014_misc_attribute_coerce_lazy.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; @@ -43,8 +43,8 @@ use Test::Exception; my $r = Request->new; isa_ok($r, 'Request'); -lives_ok { +ok ! exception { $r->headers; -} '... this coerces and passes the type constraint even with lazy'; +}, '... this coerces and passes the type constraint even with lazy'; done_testing; diff --git a/t/020_attributes/015_attribute_traits.t b/t/020_attributes/015_attribute_traits.t index 428919e..3f65560 100644 --- a/t/020_attributes/015_attribute_traits.t +++ b/t/020_attributes/015_attribute_traits.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; diff --git a/t/020_attributes/016_attribute_traits_registered.t b/t/020_attributes/016_attribute_traits_registered.t index 14cd0df..bfded60 100644 --- a/t/020_attributes/016_attribute_traits_registered.t +++ b/t/020_attributes/016_attribute_traits_registered.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; diff --git a/t/020_attributes/017_attribute_traits_n_meta.t b/t/020_attributes/017_attribute_traits_n_meta.t index 7815564..4af9aeb 100644 --- a/t/020_attributes/017_attribute_traits_n_meta.t +++ b/t/020_attributes/017_attribute_traits_n_meta.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; diff --git a/t/020_attributes/018_no_init_arg.t b/t/020_attributes/018_no_init_arg.t index e5ea6c2..22ef62a 100644 --- a/t/020_attributes/018_no_init_arg.t +++ b/t/020_attributes/018_no_init_arg.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; diff --git a/t/020_attributes/019_attribute_lazy_initializer.t b/t/020_attributes/019_attribute_lazy_initializer.t index 3ac82d8..6c57598 100644 --- a/t/020_attributes/019_attribute_lazy_initializer.t +++ b/t/020_attributes/019_attribute_lazy_initializer.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -143,8 +143,8 @@ use Test::Exception; __PACKAGE__->meta->make_immutable; } -dies_ok { +ok exception { Fail::Bar->new(foo => 10) -} '... this fails, because initializer returns a bad type'; +}, '... this fails, because initializer returns a bad type'; done_testing; diff --git a/t/020_attributes/020_trigger_and_coerce.t b/t/020_attributes/020_trigger_and_coerce.t index c3aac65..39fd577 100644 --- a/t/020_attributes/020_trigger_and_coerce.t +++ b/t/020_attributes/020_trigger_and_coerce.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { diff --git a/t/020_attributes/021_method_generation_rules.t b/t/020_attributes/021_method_generation_rules.t index 646e572..3873713 100644 --- a/t/020_attributes/021_method_generation_rules.t +++ b/t/020_attributes/021_method_generation_rules.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -33,9 +33,9 @@ ok($class, "Can define attr with rw + writer"); $obj = $class->new(); can_ok($obj, qw/foo _foo/); -lives_ok {$obj->_foo(1)} "$class->_foo is writer"; +ok ! exception {$obj->_foo(1)}, "$class->_foo is writer"; is($obj->foo(), 1, "$class->foo is reader"); -dies_ok {$obj->foo(2)} "$class->foo is not writer"; # this should fail +ok exception {$obj->foo(2)}, "$class->foo is not writer"; # this should fail ok(!defined $obj->_foo(), "$class->_foo is not reader"); $class = make_class('ro', 'writer', 'Test::Class::WriterRO'); @@ -44,9 +44,9 @@ ok($class, "Can define attr with ro + writer"); $obj = $class->new(); can_ok($obj, qw/foo _foo/); -lives_ok {$obj->_foo(1)} "$class->_foo is writer"; +ok ! exception {$obj->_foo(1)}, "$class->_foo is writer"; is($obj->foo(), 1, "$class->foo is reader"); -dies_ok {$obj->foo(1)} "$class->foo is not writer"; +ok exception {$obj->foo(1)}, "$class->foo is not writer"; isnt($obj->_foo(), 1, "$class->_foo is not reader"); $class = make_class('rw', 'accessor', 'Test::Class::AccessorRW'); @@ -55,9 +55,9 @@ ok($class, "Can define attr with rw + accessor"); $obj = $class->new(); can_ok($obj, qw/_foo/); -lives_ok {$obj->_foo(1)} "$class->_foo is writer"; +ok ! exception {$obj->_foo(1)}, "$class->_foo is writer"; is($obj->_foo(), 1, "$class->foo is reader"); -dies_ok { make_class('ro', 'accessor', "Test::Class::AccessorRO"); } "Cant define attr with ro + accessor"; +ok exception { make_class('ro', 'accessor', "Test::Class::AccessorRO"); }, "Cant define attr with ro + accessor"; done_testing; diff --git a/t/020_attributes/022_illegal_options_for_inheritance.t b/t/020_attributes/022_illegal_options_for_inheritance.t index fdf6276..d806670 100644 --- a/t/020_attributes/022_illegal_options_for_inheritance.t +++ b/t/020_attributes/022_illegal_options_for_inheritance.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Foo; @@ -24,12 +24,12 @@ use Test::Exception; extends 'Foo'; - ::lives_ok { has '+foo' => (is => 'rw') } "can override is"; - ::throws_ok { has '+foo' => (reader => 'bar') } qr/illegal/, "can't override reader"; - ::lives_ok { has '+foo' => (clearer => 'baz') } "can override unspecified things"; + ::ok ! ::exception { has '+foo' => (is => 'rw') }, "can override is"; + ::like ::exception { has '+foo' => (reader => 'bar') }, qr/illegal/, "can't override reader"; + ::ok ! ::exception { has '+foo' => (clearer => 'baz') }, "can override unspecified things"; - ::throws_ok { has '+bar' => (clearer => 'quux') } qr/illegal/, "can't override clearer"; - ::lives_ok { has '+bar' => (predicate => 'has_bar') } "can override unspecified things"; + ::like ::exception { has '+bar' => (clearer => 'quux') }, qr/illegal/, "can't override clearer"; + ::ok ! ::exception { has '+bar' => (predicate => 'has_bar') }, "can override unspecified things"; } { @@ -47,13 +47,13 @@ use Test::Exception; package Bar; use Moose; - ::lives_ok { + ::ok ! ::exception { has bar => ( traits => ['Bar::Meta::Attribute'], my_illegal_option => 'FOO', is => 'bare', ); - } "can use illegal options"; + }, "can use illegal options"; has baz => ( traits => ['Bar::Meta::Attribute'], @@ -67,10 +67,10 @@ use Test::Exception; extends 'Bar'; - ::throws_ok { has '+bar' => (my_illegal_option => 'BAR') } + ::like ::exception { has '+bar' => (my_illegal_option => 'BAR') }, qr/illegal/, "can't override illegal attribute"; - ::lives_ok { has '+baz' => (my_illegal_option => 'BAR') } + ::ok ! ::exception { has '+baz' => (my_illegal_option => 'BAR') }, "can add illegal option if superclass doesn't set it"; } diff --git a/t/020_attributes/023_attribute_names.t b/t/020_attributes/023_attribute_names.t index ebcfd09..ab17444 100644 --- a/t/020_attributes/023_attribute_names.t +++ b/t/020_attributes/023_attribute_names.t @@ -3,57 +3,57 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; my $exception_regex = qr/You must provide a name for the attribute/; { package My::Role; use Moose::Role; - ::throws_ok { + ::like ::exception { has; - } $exception_regex, 'has; fails'; + }, $exception_regex, 'has; fails'; - ::throws_ok { + ::like ::exception { has undef; - } $exception_regex, 'has undef; fails'; + }, $exception_regex, 'has undef; fails'; - ::lives_ok { + ::ok ! ::exception { has "" => ( is => 'bare', ); - } 'has ""; works now'; + }, 'has ""; works now'; - ::lives_ok { + ::ok ! ::exception { has 0 => ( is => 'bare', ); - } 'has 0; works now'; + }, 'has 0; works now'; } { package My::Class; use Moose; - ::throws_ok { + ::like ::exception { has; - } $exception_regex, 'has; fails'; + }, $exception_regex, 'has; fails'; - ::throws_ok { + ::like ::exception { has undef; - } $exception_regex, 'has undef; fails'; + }, $exception_regex, 'has undef; fails'; - ::lives_ok { + ::ok ! ::exception { has "" => ( is => 'bare', ); - } 'has ""; works now'; + }, 'has ""; works now'; - ::lives_ok { + ::ok ! ::exception { has 0 => ( is => 'bare', ); - } 'has 0; works now'; + }, 'has 0; works now'; } done_testing; diff --git a/t/020_attributes/025_chained_coercion.t b/t/020_attributes/025_chained_coercion.t index 59cc470..79dcc7c 100644 --- a/t/020_attributes/025_chained_coercion.t +++ b/t/020_attributes/025_chained_coercion.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Baz; diff --git a/t/020_attributes/028_no_slot_access.t b/t/020_attributes/028_no_slot_access.t index d9a5eca..acd7e05 100644 --- a/t/020_attributes/028_no_slot_access.t +++ b/t/020_attributes/028_no_slot_access.t @@ -61,31 +61,31 @@ use warnings; use Moose::Util::MetaRole; use Test::More; - use Test::Exception; + use Test::Fatal; Moose::Util::MetaRole::apply_metaroles( for => __PACKAGE__, class_metaroles => { instance => ['MooseX::SomeAwesomeDBFields'] }, ); - lives_ok { + ok ! exception { has lazy_attr => ( is => 'ro', isa => 'Bool', lazy => 1, default => sub {0}, ); - } + }, "Adding lazy accessor does not use inline_slot_access"; - lives_ok { + ok ! exception { has rw_attr => ( is => 'rw', ); - } + }, "Adding read-write accessor does not use inline_slot_access"; - lives_ok { __PACKAGE__->meta->make_immutable; } + ok ! exception { __PACKAGE__->meta->make_immutable; }, "Inling constructor does not use inline_slot_access"; done_testing; diff --git a/t/020_attributes/029_accessor_context.t b/t/020_attributes/029_accessor_context.t index b13a594..4bd9f38 100644 --- a/t/020_attributes/029_accessor_context.t +++ b/t/020_attributes/029_accessor_context.t @@ -3,9 +3,9 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; -lives_ok { +ok ! exception { package My::Class; use Moose; @@ -44,9 +44,9 @@ lives_ok { auto_deref => 1, ); -} 'class definition'; +}, 'class definition'; -lives_ok { +ok ! exception { my $o = My::Class->new(); is_deeply [scalar $o->s_rw], [undef], 'uninitialized scalar attribute/rw in scalar context'; @@ -65,6 +65,6 @@ lives_ok { is_deeply [scalar $o->h_ro], [undef], 'uninitialized HashRef attribute/ro in scalar context'; is_deeply [$o->h_ro], [], 'uninitialized HashRef attribute/ro in list context'; -} 'testing'; +}, 'testing'; done_testing; diff --git a/t/020_attributes/031_delegation_and_modifiers.t b/t/020_attributes/031_delegation_and_modifiers.t index cab7f0d..5b6f12a 100644 --- a/t/020_attributes/031_delegation_and_modifiers.t +++ b/t/020_attributes/031_delegation_and_modifiers.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Bar; diff --git a/t/030_roles/001_meta_role.t b/t/030_roles/001_meta_role.t index 2a040f3..568307f 100644 --- a/t/030_roles/001_meta_role.t +++ b/t/030_roles/001_meta_role.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role; use Moose::Util::TypeConstraints (); @@ -45,9 +45,9 @@ is_deeply( ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute'); -lives_ok { +ok ! exception { $foo_role->add_attribute('bar' => (is => 'rw', isa => 'Foo')); -} '... added the bar attribute okay'; +}, '... added the bar attribute okay'; is_deeply( [ $foo_role->get_attribute_list() ], @@ -66,9 +66,9 @@ is( 'bar has a Foo class type' ); -lives_ok { +ok ! exception { $foo_role->add_attribute('baz' => (is => 'ro')); -} '... added the baz attribute okay'; +}, '... added the baz attribute okay'; is_deeply( [ sort $foo_role->get_attribute_list() ], @@ -81,9 +81,9 @@ my $baz = $foo_role->get_attribute('baz'); is_deeply( $baz->original_options, { is => 'ro' }, 'original options for baz attribute' ); -lives_ok { +ok ! exception { $foo_role->remove_attribute('bar'); -} '... removed the bar attribute okay'; +}, '... removed the bar attribute okay'; is_deeply( [ $foo_role->get_attribute_list() ], @@ -98,9 +98,9 @@ ok($foo_role->has_attribute('baz'), '... FooRole does still have the baz attribu ok(!$foo_role->has_before_method_modifiers('boo'), '... no boo:before modifier'); my $method = sub { "FooRole::boo:before" }; -lives_ok { +ok ! exception { $foo_role->add_before_method_modifier('boo' => $method); -} '... added a method modifier okay'; +}, '... added a method modifier okay'; ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier'); is(($foo_role->get_before_method_modifiers('boo'))[0], $method, '... got the right method back'); diff --git a/t/030_roles/002_role.t b/t/030_roles/002_role.t index 778cd5d..ebccefc 100644 --- a/t/030_roles/002_role.t +++ b/t/030_roles/002_role.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -38,9 +38,9 @@ words, should 'has_method' return true for them? override 'bling' => sub { "FooRole::bling:override" }; override 'fling' => sub { "FooRole::fling:override" }; - ::dies_ok { extends() } '... extends() is not supported'; - ::dies_ok { augment() } '... augment() is not supported'; - ::dies_ok { inner() } '... inner() is not supported'; + ::ok ::exception { extends() }, '... extends() is not supported'; + ::ok ::exception { augment() }, '... augment() is not supported'; + ::ok ::exception { inner() }, '... inner() is not supported'; no Moose::Role; } diff --git a/t/030_roles/003_apply_role.t b/t/030_roles/003_apply_role.t index e58c0e2..b31caf1 100644 --- a/t/030_roles/003_apply_role.t +++ b/t/030_roles/003_apply_role.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package FooRole; @@ -46,11 +46,11 @@ use Test::Exception; extends 'BarClass'; - ::throws_ok { with 'FooRole' => { -version => 42 } } + ::like ::exception { with 'FooRole' => { -version => 42 } }, qr/FooRole version 42 required--this is only version 23/, 'applying role with unsatisfied version requirement'; - ::lives_ok { with 'FooRole' => { -version => 13 } } + ::ok ! ::exception { with 'FooRole' => { -version => 13 } }, 'applying role with satisfied version requirement'; sub blau {'FooClass::blau'} # << the role wraps this ... @@ -72,19 +72,19 @@ isa_ok( $foo_class_meta, 'Moose::Meta::Class' ); my $foobar_class_meta = FooBarClass->meta; isa_ok( $foobar_class_meta, 'Moose::Meta::Class' ); -dies_ok { +ok exception { $foo_class_meta->does_role(); -} +}, '... does_role requires a role name'; -dies_ok { +ok exception { $foo_class_meta->add_role(); -} +}, '... apply_role requires a role'; -dies_ok { +ok exception { $foo_class_meta->add_role( bless( {} => 'Fail' ) ); -} +}, '... apply_role requires a role'; ok( $foo_class_meta->does_role('FooRole'), @@ -171,22 +171,22 @@ foreach my $foo ( $foo, $foobar ) { ok( !defined( $foo->baz ), '... $foo->baz is undefined' ); ok( !defined( $foo->bar ), '... $foo->bar is undefined' ); - dies_ok { + ok exception { $foo->baz(1); - } + }, '... baz is a read-only accessor'; - dies_ok { + ok exception { $foo->bar(1); - } + }, '... bar is a read-write accessor with a type constraint'; my $foo2 = FooClass->new(); isa_ok( $foo2, 'FooClass' ); - lives_ok { + ok ! exception { $foo->bar($foo2); - } + }, '... bar is a read-write accessor with a type constraint'; is( $foo->bar, $foo2, '... got the right value for bar now' ); diff --git a/t/030_roles/004_role_composition_errors.t b/t/030_roles/004_role_composition_errors.t index b2c58f4..8249c27 100644 --- a/t/030_roles/004_role_composition_errors.t +++ b/t/030_roles/004_role_composition_errors.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -27,7 +27,7 @@ is_deeply( package Foo::Class; use Moose; - ::dies_ok { with('Foo::Role') } + ::ok ::exception { with('Foo::Role') }, '... no foo method implemented by Foo::Class'; } @@ -37,9 +37,9 @@ is_deeply( package Bar::Class; use Moose; - ::dies_ok { with('Foo::Class') } + ::ok ::exception { with('Foo::Class') }, '... cannot consume a class, it must be a role'; - ::lives_ok { with('Foo::Role') } + ::ok ! ::exception { with('Foo::Role') }, '... has a foo method implemented by Bar::Class'; sub foo {'Bar::Class::foo'} @@ -51,7 +51,7 @@ is_deeply( package Bar::Role; use Moose::Role; - ::lives_ok { with('Foo::Role') } + ::ok ! ::exception { with('Foo::Role') }, '... has a foo method implemented by Bar::Role'; sub foo {'Bar::Role::foo'} @@ -69,7 +69,7 @@ is_deeply( package Baz::Role; use Moose::Role; - ::lives_ok { with('Foo::Role') } + ::ok ! ::exception { with('Foo::Role') }, '... no foo method implemented by Baz::Role'; } @@ -85,7 +85,7 @@ is_deeply( package Baz::Class; use Moose; - ::dies_ok { with('Baz::Role') } + ::ok ::exception { with('Baz::Role') }, '... no foo method implemented by Baz::Class2'; } @@ -95,7 +95,7 @@ is_deeply( package Baz::Class2; use Moose; - ::lives_ok { with('Baz::Role') } + ::ok ! ::exception { with('Baz::Role') }, '... has a foo method implemented by Baz::Class2'; sub foo {'Baz::Class2::foo'} @@ -115,7 +115,7 @@ is_deeply( package Quux::Class; use Moose; - ::throws_ok { with('Quux::Role') } + ::like ::exception { with('Quux::Role') }, qr/\Q'Quux::Role' requires the methods 'meth1', 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class'/, 'exception mentions all the missing required methods at once'; } @@ -126,7 +126,7 @@ is_deeply( sub meth1 { } - ::throws_ok { with('Quux::Role') } + ::like ::exception { with('Quux::Role') }, qr/'Quux::Role' requires the methods 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class2'/, 'exception mentions all the missing required methods at once, but not the one that exists'; } @@ -138,7 +138,7 @@ is_deeply( has 'meth1' => ( is => 'ro' ); has 'meth2' => ( is => 'ro' ); - ::throws_ok { with('Quux::Role') } + ::like ::exception { with('Quux::Role') }, qr/'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class3'/, 'exception mentions all the missing methods at once, but not the accessors'; } @@ -150,7 +150,7 @@ is_deeply( sub meth1 { } has 'meth2' => ( is => 'ro' ); - ::throws_ok { with('Quux::Role') } + ::like ::exception { with('Quux::Role') }, qr/'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class4'/, 'exception mentions all the require methods that are accessors at once, as well as missing methods, but not the one that exists'; } diff --git a/t/030_roles/005_role_conflict_detection.t b/t/030_roles/005_role_conflict_detection.t index d33b1c0..51ee9a0 100644 --- a/t/030_roles/005_role_conflict_detection.t +++ b/t/030_roles/005_role_conflict_detection.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -32,16 +32,16 @@ Mutually recursive roles. package My::Test1; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Foo', 'Role::Bar'; - } '... our mutually recursive roles combine okay'; + }, '... our mutually recursive roles combine okay'; package My::Test2; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Bar', 'Role::Foo'; - } '... our mutually recursive roles combine okay (no matter what order)'; + }, '... our mutually recursive roles combine okay (no matter what order)'; } my $test1 = My::Test1->new; @@ -98,32 +98,32 @@ Role method conflicts package My::Test3; use Moose; - ::throws_ok { + ::like ::exception { with 'Role::Bling', 'Role::Bling::Bling'; - } qr/Due to a method name conflict in roles 'Role::Bling' and 'Role::Bling::Bling', the method 'bling' must be implemented or excluded by 'My::Test3'/, '... role methods conflict and method was required'; + }, qr/Due to a method name conflict in roles 'Role::Bling' and 'Role::Bling::Bling', the method 'bling' must be implemented or excluded by 'My::Test3'/, '... role methods conflict and method was required'; package My::Test4; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Bling'; with 'Role::Bling::Bling'; - } '... role methods didnt conflict when manually combined'; + }, '... role methods didnt conflict when manually combined'; package My::Test5; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Bling::Bling'; with 'Role::Bling'; - } '... role methods didnt conflict when manually combined (in opposite order)'; + }, '... role methods didnt conflict when manually combined (in opposite order)'; package My::Test6; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Bling::Bling', 'Role::Bling'; - } '... role methods didnt conflict when manually resolved'; + }, '... role methods didnt conflict when manually resolved'; sub bling { 'My::Test6::bling' } } @@ -187,35 +187,35 @@ Role attribute conflicts package My::Test7; use Moose; - ::throws_ok { + ::like ::exception { with 'Role::Boo', 'Role::Boo::Hoo'; - } qr/We have encountered an attribute conflict/, + }, qr/We have encountered an attribute conflict/, '... role attrs conflict and method was required'; package My::Test8; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Boo'; with 'Role::Boo::Hoo'; - } '... role attrs didnt conflict when manually combined'; + }, '... role attrs didnt conflict when manually combined'; package My::Test9; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Boo::Hoo'; with 'Role::Boo'; - } '... role attrs didnt conflict when manually combined'; + }, '... role attrs didnt conflict when manually combined'; package My::Test10; use Moose; has 'ghost' => (is => 'ro', default => 'My::Test10::ghost'); - ::throws_ok { + ::like ::exception { with 'Role::Boo', 'Role::Boo::Hoo'; - } qr/We have encountered an attribute conflict/, + }, qr/We have encountered an attribute conflict/, '... role attrs conflict and cannot be manually disambiguted'; } @@ -275,34 +275,34 @@ Role override method conflicts extends 'My::Test::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Role::Truth'; - } '... composed the role with override okay'; + }, '... composed the role with override okay'; package My::Test12; use Moose; extends 'My::Test::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Role::Plot'; - } '... composed the role with override okay'; + }, '... composed the role with override okay'; package My::Test13; use Moose; - ::dies_ok { + ::ok ::exception { with 'Role::Plot'; - } '... cannot compose it because we have no superclass'; + }, '... cannot compose it because we have no superclass'; package My::Test14; use Moose; extends 'My::Test::Base'; - ::throws_ok { + ::like ::exception { with 'Role::Plot', 'Role::Truth'; - } qr/Two \'override\' methods of the same name encountered/, + }, qr/Two \'override\' methods of the same name encountered/, '... cannot compose it because we have no superclass'; } @@ -328,9 +328,9 @@ is(My::Test14->twist(), 'My::Test::Base::twist', '... got the right method retur package Role::Reality; use Moose::Role; - ::throws_ok { + ::like ::exception { with 'Role::Plot'; - } qr/A local method of the same name as been found/, + }, qr/A local method of the same name as been found/, '... could not compose roles here, it dies'; sub twist { @@ -361,9 +361,9 @@ is(Role::Reality->meta->get_method('twist')->(), package Conflicts; use Moose; - ::throws_ok { + ::like ::exception { with qw(Role1 Role2); - } qr/Due to a method name conflict in roles 'Role1' and 'Role2', the method 'foo' must be implemented or excluded by 'Conflicts'/; + }, qr/Due to a method name conflict in roles 'Role1' and 'Role2', the method 'foo' must be implemented or excluded by 'Conflicts'/; } =pod @@ -418,108 +418,108 @@ Now I have to decide actually what happens, and how to fix it. package My::Test15; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Method'; - } '... composed the method role into the method class'; + }, '... composed the method role into the method class'; sub ghost { 'My::Test15::ghost' } package My::Test16; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Method'; - } '... composed the method role into the attribute class'; + }, '... composed the method role into the attribute class'; has 'ghost' => (is => 'ro', default => 'My::Test16::ghost'); package My::Test17; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Attribute'; - } '... composed the attribute role into the method class'; + }, '... composed the attribute role into the method class'; sub ghost { 'My::Test17::ghost' } package My::Test18; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Attribute'; - } '... composed the attribute role into the attribute class'; + }, '... composed the attribute role into the attribute class'; has 'ghost' => (is => 'ro', default => 'My::Test18::ghost'); package My::Test19; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Method', 'Role::Method2'; - } '... composed method roles into class with method tiebreaker'; + }, '... composed method roles into class with method tiebreaker'; sub ghost { 'My::Test19::ghost' } package My::Test20; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Method', 'Role::Method2'; - } '... composed method roles into class with attribute tiebreaker'; + }, '... composed method roles into class with attribute tiebreaker'; has 'ghost' => (is => 'ro', default => 'My::Test20::ghost'); package My::Test21; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Attribute', 'Role::Attribute2'; - } '... composed attribute roles into class with method tiebreaker'; + }, '... composed attribute roles into class with method tiebreaker'; sub ghost { 'My::Test21::ghost' } package My::Test22; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Attribute', 'Role::Attribute2'; - } '... composed attribute roles into class with attribute tiebreaker'; + }, '... composed attribute roles into class with attribute tiebreaker'; has 'ghost' => (is => 'ro', default => 'My::Test22::ghost'); package My::Test23; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Method', 'Role::Attribute'; - } '... composed method and attribute role into class with method tiebreaker'; + }, '... composed method and attribute role into class with method tiebreaker'; sub ghost { 'My::Test23::ghost' } package My::Test24; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Method', 'Role::Attribute'; - } '... composed method and attribute role into class with attribute tiebreaker'; + }, '... composed method and attribute role into class with attribute tiebreaker'; has 'ghost' => (is => 'ro', default => 'My::Test24::ghost'); package My::Test25; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Attribute', 'Role::Method'; - } '... composed attribute and method role into class with method tiebreaker'; + }, '... composed attribute and method role into class with method tiebreaker'; sub ghost { 'My::Test25::ghost' } package My::Test26; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Attribute', 'Role::Method'; - } '... composed attribute and method role into class with attribute tiebreaker'; + }, '... composed attribute and method role into class with attribute tiebreaker'; has 'ghost' => (is => 'ro', default => 'My::Test26::ghost'); } diff --git a/t/030_roles/006_role_exclusion.t b/t/030_roles/006_role_exclusion.t index 1d80e84..bc2bfca 100644 --- a/t/030_roles/006_role_exclusion.t +++ b/t/030_roles/006_role_exclusion.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -53,28 +53,28 @@ the roles into the same class package My::Test1; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Molecule::Organic'; - } '... adding the role (w/ excluded roles) okay'; + }, '... adding the role (w/ excluded roles) okay'; package My::Test2; use Moose; - ::throws_ok { + ::like ::exception { with 'Molecule::Organic', 'Molecule::Inorganic'; - } qr/Conflict detected: Role Molecule::Organic excludes role 'Molecule::Inorganic'/, + }, qr/Conflict detected: Role Molecule::Organic excludes role 'Molecule::Inorganic'/, '... adding the role w/ excluded role conflict dies okay'; package My::Test3; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Molecule::Organic'; - } '... adding the role (w/ excluded roles) okay'; + }, '... adding the role (w/ excluded roles) okay'; - ::throws_ok { + ::like ::exception { with 'Molecule::Inorganic'; - } qr/Conflict detected: My::Test3 excludes role 'Molecule::Inorganic'/, + }, qr/Conflict detected: My::Test3 excludes role 'Molecule::Inorganic'/, '... adding the role w/ excluded role conflict dies okay'; } @@ -108,9 +108,9 @@ the roles into the a superclass extends 'Methane'; - ::throws_ok { + ::like ::exception { with 'Molecule::Inorganic'; - } qr/Conflict detected: My::Test4 excludes role \'Molecule::Inorganic\'/, + }, qr/Conflict detected: My::Test4 excludes role \'Molecule::Inorganic\'/, '... cannot add exculded role into class which extends Methane'; } diff --git a/t/030_roles/007_roles_and_req_method_edge_cases.t b/t/030_roles/007_roles_and_req_method_edge_cases.t index bdbcf45..6da415f 100644 --- a/t/030_roles/007_roles_and_req_method_edge_cases.t +++ b/t/030_roles/007_roles_and_req_method_edge_cases.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -35,9 +35,9 @@ not remove the requirement) use warnings; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method will not exist yet (but we will live)'; + }, '... the required "foo" method will not exist yet (but we will live)'; override 'foo' => sub { 'Role::ProvideFoo::foo' }; } @@ -67,9 +67,9 @@ second class citizens. extends 'Class::ProvideFoo::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method will be found in the superclass'; + }, '... the required "foo" method will be found in the superclass'; override 'foo' => sub { 'Class::ProvideFoo::foo' }; @@ -80,9 +80,9 @@ second class citizens. override 'foo' => sub { 'Class::ProvideFoo::foo' }; - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method exists, although it is overriden locally'; + }, '... the required "foo" method exists, although it is overriden locally'; } @@ -99,9 +99,9 @@ method modifier. extends 'Class::ProvideFoo::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method will be found in the superclass'; + }, '... the required "foo" method will be found in the superclass'; before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; @@ -112,9 +112,9 @@ method modifier. before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method exists, although it is a before modifier locally'; + }, '... the required "foo" method exists, although it is a before modifier locally'; package Class::ProvideFoo::Before3; use Moose; @@ -124,9 +124,9 @@ method modifier. sub foo { 'Class::ProvideFoo::foo' } before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method exists locally, and it is modified locally'; + }, '... the required "foo" method exists locally, and it is modified locally'; package Class::ProvideFoo::Before4; use Moose; @@ -140,9 +140,9 @@ method modifier. ::is(__PACKAGE__->meta->get_method('foo')->get_original_method->package_name, __PACKAGE__, '... but the original method is from our package'); - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method exists in the symbol table (and we will live)'; + }, '... the required "foo" method exists in the symbol table (and we will live)'; } @@ -160,9 +160,9 @@ method modifier. extends 'Class::ProvideFoo::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method will be found in the superclass (but then overriden)'; + }, '... the required "foo" method will be found in the superclass (but then overriden)'; has 'foo' => (is => 'ro'); @@ -173,9 +173,9 @@ method modifier. has 'foo' => (is => 'ro'); - ::lives_ok { + ::ok ! ::exception { with 'Role::RequireFoo'; - } '... the required "foo" method exists, and is an accessor'; + }, '... the required "foo" method exists, and is an accessor'; } # ... @@ -211,9 +211,9 @@ method modifier. use Moose; extends 'Foo::Class::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role'; - } '... our role combined successfully'; + }, '... our role combined successfully'; } # a method required in a role and implemented in a superclass, with a method @@ -236,16 +236,16 @@ method modifier. use Moose; extends 'Bar::Class::Base'; after bar => sub { "o noes" }; - # technically we could run lives_ok here, too, but putting it into a + # technically we could run ok exception {} here, too, but putting it into a # grandchild class makes it more obvious why this matters. } { package Bar::Class::Grandchild; use Moose; extends 'Bar::Class::Child'; - ::lives_ok { + ::ok ! ::exception { with 'Bar::Role'; - } 'required method exists in superclass as non-modifier, so we live'; + }, 'required method exists in superclass as non-modifier, so we live'; } { @@ -264,16 +264,16 @@ method modifier. use Moose; extends 'Bar2::Class::Base'; override bar => sub { "o noes" }; - # technically we could run lives_ok here, too, but putting it into a + # technically we could run ok exception {} here, too, but putting it into a # grandchild class makes it more obvious why this matters. } { package Bar2::Class::Grandchild; use Moose; extends 'Bar2::Class::Child'; - ::lives_ok { + ::ok ! ::exception { with 'Bar2::Role'; - } 'required method exists in superclass as non-modifier, so we live'; + }, 'required method exists in superclass as non-modifier, so we live'; } done_testing; diff --git a/t/030_roles/008_role_conflict_edge_cases.t b/t/030_roles/008_role_conflict_edge_cases.t index aff9bd9..7f3636a 100644 --- a/t/030_roles/008_role_conflict_edge_cases.t +++ b/t/030_roles/008_role_conflict_edge_cases.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -33,9 +33,9 @@ a conflict) package My::Test::Class1; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Derived1', 'Role::Derived2'; - } '... roles composed okay (no conflicts)'; + }, '... roles composed okay (no conflicts)'; } ok(Role::Base->meta->has_method('foo'), '... have the method foo as expected'); @@ -79,9 +79,9 @@ a method conflict with method modifiers extends 'My::Test::Class2::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Role::Derived3', 'Role::Derived4'; - } '... roles composed okay (no conflicts)'; + }, '... roles composed okay (no conflicts)'; } ok(Role::Base2->meta->has_override_method_modifier('foo'), '... have the method foo as expected'); @@ -132,9 +132,9 @@ same for before/afters as well extends 'My::Test::Class3::Base'; - ::lives_ok { + ::ok ! ::exception { with 'Role::Derived5', 'Role::Derived6'; - } '... roles composed okay (no conflicts)'; + }, '... roles composed okay (no conflicts)'; } ok(Role::Base3->meta->has_around_method_modifiers('foo'), '... have the method foo as expected'); @@ -175,9 +175,9 @@ a conflict) package My::Test::Class4; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::Derived7', 'Role::Derived8'; - } '... roles composed okay (no conflicts)'; + }, '... roles composed okay (no conflicts)'; } ok(Role::Base4->meta->has_attribute('foo'), '... have the attribute foo as expected'); diff --git a/t/030_roles/009_more_role_edge_cases.t b/t/030_roles/009_more_role_edge_cases.t index 4a4fde0..522630c 100644 --- a/t/030_roles/009_more_role_edge_cases.t +++ b/t/030_roles/009_more_role_edge_cases.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -30,9 +30,9 @@ use Test::Exception; package SubAB; use Moose; - ::lives_ok { + ::ok ! ::exception { with "SubAA", "RootA"; - } '... role was composed as expected'; + }, '... role was composed as expected'; } ok( SubAB->does("SubAA"), "does SubAA"); @@ -45,9 +45,9 @@ use Test::Exception; can_ok( $i, "foo" ); my $foo_rv; - lives_ok { + ok ! exception { $foo_rv = $i->foo; - } '... called foo successfully'; + }, '... called foo successfully'; is($foo_rv, "RootA::foo", "... got the right foo rv"); } @@ -94,9 +94,9 @@ use Test::Exception; package SubBB; use Moose; - ::lives_ok { + ::ok ! ::exception { with "SubBA"; - } '... composed the role successfully'; + }, '... composed the role successfully'; } ok( SubBB->does("SubBA"), "BB does SubBA" ); @@ -107,20 +107,20 @@ use Test::Exception; can_ok( $i, "foo" ); my $foo_rv; - lives_ok { + ok ! exception { $foo_rv = $i->foo - } '... called foo successfully'; + }, '... called foo successfully'; is( $foo_rv, "RootB::foo", "foo rv" ); is( $i->counter, 1, "after hook called" ); - lives_ok { $i->foo } '... called foo successfully (again)'; + ok ! exception { $i->foo }, '... called foo successfully (again)'; is( $i->counter, 2, "after hook called (again)" ); ok(SubBA->meta->has_method('foo'), '... this has the foo method'); #my $subba_foo_rv; - #lives_ok { + #ok ! exception { # $subba_foo_rv = SubBA::foo(); - #} '... called the sub as a function correctly'; + #}, '... called the sub as a function correctly'; #is($subba_foo_rv, 'RootB::foo', '... the SubBA->foo is still the RootB version'); } @@ -143,9 +143,9 @@ use Test::Exception; with "RootC"; - ::dies_ok { + ::ok ::exception { override foo => sub { "overridden" }; - } '... cannot compose an override over a local method'; + }, '... cannot compose an override over a local method'; } } diff --git a/t/030_roles/011_overriding.t b/t/030_roles/011_overriding.t index 300a39f..096868a 100644 --- a/t/030_roles/011_overriding.t +++ b/t/030_roles/011_overriding.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -22,9 +22,9 @@ use Test::Exception; package Role::C; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with qw(Role::A Role::B); # no conflict here - } "define role C"; + }, "define role C"; sub foo { 'Role::C::foo' } sub zot { 'Role::C::zot' } @@ -32,9 +32,9 @@ use Test::Exception; package Class::A; use Moose; - ::lives_ok { + ::ok ! ::exception { with qw(Role::C); - } "define class A"; + }, "define class A"; sub zot { 'Class::A::zot' } } @@ -61,16 +61,16 @@ is( Class::A->new->xxy, "Role::B::xxy", "... got the right xxy method" ); package Class::A::Conflict; use Moose; - ::throws_ok { + ::like ::exception { with 'Role::A::Conflict'; - } qr/Due to a method name conflict in roles 'Role::A' and 'Role::A::Conflict', the method 'bar' must be implemented or excluded by 'Class::A::Conflict'/, '... did not fufill the requirement of &bar method'; + }, qr/Due to a method name conflict in roles 'Role::A' and 'Role::A::Conflict', the method 'bar' must be implemented or excluded by 'Class::A::Conflict'/, '... did not fufill the requirement of &bar method'; package Class::A::Resolved; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Role::A::Conflict'; - } '... did fufill the requirement of &bar method'; + }, '... did fufill the requirement of &bar method'; sub bar { 'Class::A::Resolved::bar' } } @@ -100,9 +100,9 @@ is( Class::A::Resolved->new->bar, 'Class::A::Resolved::bar', "... got the right package Role::F; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with qw(Role::D Role::E); # conflict between 'foo's here - } "define role Role::F"; + }, "define role Role::F"; sub foo { 'Role::F::foo' } sub zot { 'Role::F::zot' } @@ -110,9 +110,9 @@ is( Class::A::Resolved->new->bar, 'Class::A::Resolved::bar', "... got the right package Class::B; use Moose; - ::lives_ok { + ::ok ! ::exception { with qw(Role::F); - } "define class Class::B"; + }, "define class Class::B"; sub zot { 'Class::B::zot' } } @@ -134,9 +134,9 @@ ok(!Role::F->meta->requires_method('foo'), '... Role::F fufilled the &foo requir package Role::D::And::E::Conflict; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with qw(Role::D Role::E); # conflict between 'foo's here - } "... define role Role::D::And::E::Conflict"; + }, "... define role Role::D::And::E::Conflict"; sub foo { 'Role::D::And::E::Conflict::foo' } # this overrides ... @@ -168,9 +168,9 @@ ok(Role::D::And::E::Conflict->meta->requires_method('bar'), '... Role::D::And::E package Role::I; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with qw(Role::J Role::H); # conflict between 'foo's here - } "define role Role::I"; + }, "define role Role::I"; sub zot { 'Role::I::zot' } sub zzy { 'Role::I::zzy' } @@ -178,18 +178,18 @@ ok(Role::D::And::E::Conflict->meta->requires_method('bar'), '... Role::D::And::E package Class::C; use Moose; - ::throws_ok { + ::like ::exception { with qw(Role::I); - } qr/Due to a method name conflict in roles 'Role::H' and 'Role::J', the method 'foo' must be implemented or excluded by 'Class::C'/, "defining class Class::C fails"; + }, qr/Due to a method name conflict in roles 'Role::H' and 'Role::J', the method 'foo' must be implemented or excluded by 'Class::C'/, "defining class Class::C fails"; sub zot { 'Class::C::zot' } package Class::E; use Moose; - ::lives_ok { + ::ok ! ::exception { with qw(Role::I); - } "resolved with method"; + }, "resolved with method"; sub foo { 'Class::E::foo' } sub zot { 'Class::E::zot' } @@ -205,7 +205,7 @@ is( Class::E->new->xxy, "Role::J::xxy", "... got the right &xxy method" ); ok(Role::I->meta->requires_method('foo'), '... Role::I still have the &foo requirement'); { - lives_ok { + ok ! exception { package Class::D; use Moose; @@ -215,7 +215,7 @@ ok(Role::I->meta->requires_method('foo'), '... Role::I still have the &foo requi with qw(Role::I); - } "resolved with attr"; + }, "resolved with attr"; can_ok( Class::D->new, qw(foo bar xxy zot) ); is( eval { Class::D->new->bar }, "Role::H::bar", "bar" ); diff --git a/t/030_roles/012_method_exclusion_in_composition.t b/t/030_roles/012_method_exclusion_in_composition.t index fa74523..8e3083e 100644 --- a/t/030_roles/012_method_exclusion_in_composition.t +++ b/t/030_roles/012_method_exclusion_in_composition.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -58,20 +58,20 @@ ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is requ package My::Foo::Class; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role' => { -excludes => 'foo' }, 'Bar::Role' => { -excludes => 'foo' }, 'Baz::Role'; - } '... composed our roles correctly'; + }, '... composed our roles correctly'; package My::Foo::Class::Broken; use Moose; - ::throws_ok { + ::like ::exception { with 'Foo::Role', 'Bar::Role' => { -excludes => 'foo' }, 'Baz::Role'; - } qr/Due to a method name conflict in roles 'Baz::Role' and 'Foo::Role', the method 'foo' must be implemented or excluded by 'My::Foo::Class::Broken'/, + }, qr/Due to a method name conflict in roles 'Baz::Role' and 'Foo::Role', the method 'foo' must be implemented or excluded by 'My::Foo::Class::Broken'/, '... composed our roles correctly'; } @@ -86,11 +86,11 @@ ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is requ package My::Foo::Role; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role' => { -excludes => 'foo' }, 'Bar::Role' => { -excludes => 'foo' }, 'Baz::Role'; - } '... composed our roles correctly'; + }, '... composed our roles correctly'; } ok(My::Foo::Role->meta->has_method('foo'), "we have a foo method"); @@ -100,11 +100,11 @@ ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not package My::Foo::Role::Other; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role', 'Bar::Role' => { -excludes => 'foo' }, 'Baz::Role'; - } '... composed our roles correctly'; + }, '... composed our roles correctly'; } ok(!My::Foo::Role::Other->meta->has_method('foo'), "we dont have a foo method"); diff --git a/t/030_roles/013_method_aliasing_in_composition.t b/t/030_roles/013_method_aliasing_in_composition.t index 6487561..9b6ef04 100644 --- a/t/030_roles/013_method_aliasing_in_composition.t +++ b/t/030_roles/013_method_aliasing_in_composition.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -20,16 +20,16 @@ use Test::Exception; package My::Class; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'My::Role' => { -alias => { bar => 'role_bar' } }; - } '... this succeeds'; + }, '... this succeeds'; package My::Class::Failure; use Moose; - ::throws_ok { + ::like ::exception { with 'My::Role' => { -alias => { bar => 'role_bar' } }; - } qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds'; + }, qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds'; sub role_bar { 'FAIL' } } @@ -40,18 +40,18 @@ ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz bar ro package My::OtherRole; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with 'My::Role' => { -alias => { bar => 'role_bar' } }; - } '... this succeeds'; + }, '... this succeeds'; sub bar { 'My::OtherRole::bar' } package My::OtherRole::Failure; use Moose::Role; - ::throws_ok { + ::like ::exception { with 'My::Role' => { -alias => { bar => 'role_bar' } }; - } qr/Cannot create a method alias if a local method of the same name exists/, '... cannot alias to a name that exists'; + }, qr/Cannot create a method alias if a local method of the same name exists/, '... cannot alias to a name that exists'; sub role_bar { 'FAIL' } } @@ -64,9 +64,9 @@ ok(!My::OtherRole->meta->requires_method('role_bar'), '... and the &role_bar met package My::AliasingRole; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with 'My::Role' => { -alias => { bar => 'role_bar' } }; - } '... this succeeds'; + }, '... this succeeds'; } ok(My::AliasingRole->meta->has_method($_), "we have a $_ method") for qw(foo baz role_bar); @@ -91,20 +91,20 @@ ok(!My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is package My::Foo::Class; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, 'Bar::Role' => { -alias => { 'foo' => 'bar_foo' }, -excludes => 'foo' }, 'Baz::Role'; - } '... composed our roles correctly'; + }, '... composed our roles correctly'; package My::Foo::Class::Broken; use Moose; - ::throws_ok { + ::like ::exception { with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, 'Bar::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, 'Baz::Role'; - } qr/Due to a method name conflict in roles 'Bar::Role' and 'Foo::Role', the method 'foo_foo' must be implemented or excluded by 'My::Foo::Class::Broken'/, + }, qr/Due to a method name conflict in roles 'Bar::Role' and 'Foo::Role', the method 'foo_foo' must be implemented or excluded by 'My::Foo::Class::Broken'/, '... composed our roles correctly'; } @@ -121,11 +121,11 @@ ok(!My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is package My::Foo::Role; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, 'Bar::Role' => { -alias => { 'foo' => 'bar_foo' }, -excludes => 'foo' }, 'Baz::Role'; - } '... composed our roles correctly'; + }, '... composed our roles correctly'; } ok(My::Foo::Role->meta->has_method($_), "we have a $_ method") for qw/foo foo_foo bar_foo/;; @@ -136,11 +136,11 @@ ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not package My::Foo::Role::Other; use Moose::Role; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, 'Bar::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, 'Baz::Role'; - } '... composed our roles correctly'; + }, '... composed our roles correctly'; } ok(!My::Foo::Role::Other->meta->has_method('foo_foo'), "we dont have a foo_foo method"); @@ -150,9 +150,9 @@ ok(My::Foo::Role::Other->meta->requires_method('foo_foo'), '... and the &foo met package My::Foo::AliasOnly; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' } }, - } '... composed our roles correctly'; + }, '... composed our roles correctly'; } ok(My::Foo::AliasOnly->meta->has_method('foo'), 'we have a foo method'); @@ -170,14 +170,12 @@ ok(My::Foo::AliasOnly->meta->has_method('foo_foo'), '.. and the aliased foo_foo package Role::Bar; use Moose::Role; - use Test::Exception; - - lives_ok { + ::ok ! ::exception { with 'Role::Foo' => { -alias => { x1 => 'foo_x1' }, -excludes => ['y1'], }; - } + }, 'Compose Role::Foo into Role::Bar with alias and exclude'; sub x1 {} @@ -194,14 +192,12 @@ ok(My::Foo::AliasOnly->meta->has_method('foo_foo'), '.. and the aliased foo_foo package Role::Baz; use Moose::Role; - use Test::Exception; - - lives_ok { + ::ok ! ::exception { with 'Role::Foo' => { -alias => { x1 => 'foo_x1' }, -excludes => ['y1'], }; - } + }, 'Compose Role::Foo into Role::Baz with alias and exclude'; } diff --git a/t/030_roles/014_more_alias_and_exclude.t b/t/030_roles/014_more_alias_and_exclude.t index 1bba604..4dd460c 100644 --- a/t/030_roles/014_more_alias_and_exclude.t +++ b/t/030_roles/014_more_alias_and_exclude.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -45,12 +45,12 @@ use Test::Exception; package My::Class; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'Foo' => { -excludes => [qw/bar baz gorch/], -alias => { gorch => 'foo_gorch' } }, 'Bar' => { -excludes => [qw/foo baz gorch/] }, 'Baz' => { -excludes => [qw/foo bar gorch/], -alias => { foo => 'baz_foo', bar => 'baz_bar' } }, 'Gorch' => { -excludes => [qw/foo bar baz/] }; - } '... everything works out all right'; + }, '... everything works out all right'; } my $c = My::Class->new; diff --git a/t/030_roles/015_runtime_roles_and_attrs.t b/t/030_roles/015_runtime_roles_and_attrs.t index 865e252..cfcbcba 100644 --- a/t/030_roles/015_runtime_roles_and_attrs.t +++ b/t/030_roles/015_runtime_roles_and_attrs.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util 'blessed'; @@ -36,9 +36,9 @@ ok(!$obj->can( 'talk' ), "... the role is not composed yet"); ok(!$obj->can( 'fur' ), 'ditto'); ok(!$obj->does('Dog'), '... we do not do any roles yet'); -dies_ok { +ok exception { $obj->dog($obj) -} '... and setting the accessor fails (not a Dog yet)'; +}, '... and setting the accessor fails (not a Dog yet)'; Dog->meta->apply($obj); @@ -48,9 +48,9 @@ ok($obj->can('fur'), "it has fur"); is($obj->talk, 'woof', '... got the right return value for the newly composed method'); -lives_ok { +ok ! exception { $obj->dog($obj) -} '... and setting the accessor is okay'; +}, '... and setting the accessor is okay'; is($obj->fur, "dirty", "role attr initialized"); diff --git a/t/030_roles/016_runtime_roles_and_nonmoose.t b/t/030_roles/016_runtime_roles_and_nonmoose.t index ec4e657..906da55 100644 --- a/t/030_roles/016_runtime_roles_and_nonmoose.t +++ b/t/030_roles/016_runtime_roles_and_nonmoose.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util 'blessed'; @@ -39,9 +39,9 @@ isa_ok($foo, 'Foo'); ok(!$bar->can( 'talk' ), "... the role is not composed yet"); -dies_ok { +ok exception { $foo->dog($bar) -} '... and setting the accessor fails (not a Dog yet)'; +}, '... and setting the accessor fails (not a Dog yet)'; Dog->meta->apply($bar); @@ -49,8 +49,8 @@ ok($bar->can('talk'), "... the role is now composed at the object level"); is($bar->talk, 'woof', '... got the right return value for the newly composed method'); -lives_ok { +ok ! exception { $foo->dog($bar) -} '... and setting the accessor is okay'; +}, '... and setting the accessor is okay'; done_testing; diff --git a/t/030_roles/017_extending_role_attrs.t b/t/030_roles/017_extending_role_attrs.t index 16bc2e7..452bebc 100644 --- a/t/030_roles/017_extending_role_attrs.t +++ b/t/030_roles/017_extending_role_attrs.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -29,9 +29,9 @@ on role attributes works right. with 'Foo::Role'; - ::lives_ok { + ::ok ! ::exception { has '+bar' => (default => sub { 100 }); - } '... extended the attribute successfully'; + }, '... extended the attribute successfully'; } my $foo = Foo->new; @@ -54,11 +54,11 @@ is($foo->bar, 100, '... got the extended attribute'); with 'Bar::Role'; - ::lives_ok { + ::ok ! ::exception { has '+foo' => ( isa => 'Int', ) - } "... narrowed the role's type constraint successfully"; + }, "... narrowed the role's type constraint successfully"; } my $bar = Bar->new(foo => 42); @@ -67,7 +67,7 @@ is($bar->foo, 42, '... got the extended attribute'); $bar->foo(100); is($bar->foo, 100, "... can change the attribute's value to an Int"); -throws_ok { $bar->foo("baz") } qr/^Attribute \(foo\) does not pass the type constraint because: Validation failed for 'Int' with value baz at /; +like exception { $bar->foo("baz") }, qr/^Attribute \(foo\) does not pass the type constraint because: Validation failed for 'Int' with value baz at /; is($bar->foo, 100, "... still has the old Int value"); @@ -85,11 +85,11 @@ is($bar->foo, 100, "... still has the old Int value"); with 'Baz::Role'; - ::lives_ok { + ::ok ! ::exception { has '+baz' => ( isa => 'Int | ClassName', ) - } "... narrowed the role's type constraint successfully"; + }, "... narrowed the role's type constraint successfully"; } my $baz = Baz->new(baz => 99); @@ -98,7 +98,7 @@ is($baz->baz, 99, '... got the extended attribute'); $baz->baz('Foo'); is($baz->baz, 'Foo', "... can change the attribute's value to a ClassName"); -throws_ok { $baz->baz("zonk") } qr/^Attribute \(baz\) does not pass the type constraint because: Validation failed for 'ClassName\|Int' with value zonk at /; +like exception { $baz->baz("zonk") }, qr/^Attribute \(baz\) does not pass the type constraint because: Validation failed for 'ClassName\|Int' with value zonk at /; is_deeply($baz->baz, 'Foo', "... still has the old ClassName value"); @@ -121,11 +121,11 @@ is_deeply($baz->baz, 'Foo', "... still has the old ClassName value"); => as 'Int' => where { $_ > 0 }; - ::lives_ok { + ::ok ! ::exception { has '+quux' => ( isa => 'Positive | ArrayRef', ) - } "... narrowed the role's type constraint successfully"; + }, "... narrowed the role's type constraint successfully"; } my $quux = Quux->new(quux => 99); @@ -136,10 +136,10 @@ is($quux->quux, 100, "... can change the attribute's value to an Int"); $quux->quux(["hi"]); is_deeply($quux->quux, ["hi"], "... can change the attribute's value to an ArrayRef"); -throws_ok { $quux->quux("quux") } qr/^Attribute \(quux\) does not pass the type constraint because: Validation failed for 'ArrayRef\|Positive' with value quux at /; +like exception { $quux->quux("quux") }, qr/^Attribute \(quux\) does not pass the type constraint because: Validation failed for 'ArrayRef\|Positive' with value quux at /; is_deeply($quux->quux, ["hi"], "... still has the old ArrayRef value"); -throws_ok { $quux->quux({a => 1}) } qr/^Attribute \(quux\) does not pass the type constraint because: Validation failed for 'ArrayRef\|Positive' with value HASH\(\w+\) at /; +like exception { $quux->quux({a => 1}) }, qr/^Attribute \(quux\) does not pass the type constraint because: Validation failed for 'ArrayRef\|Positive' with value HASH\(\w+\) at /; is_deeply($quux->quux, ["hi"], "... still has the old ArrayRef value"); @@ -159,17 +159,17 @@ is_deeply($quux->quux, ["hi"], "... still has the old ArrayRef value"); with 'Err::Role'; - ::lives_ok { + ::ok ! ::exception { has '+err1' => (isa => 'Defined'); - } "can get less specific in the subclass"; + }, "can get less specific in the subclass"; - ::lives_ok { + ::ok ! ::exception { has '+err2' => (isa => 'Bool'); - } "or change the type completely"; + }, "or change the type completely"; - ::lives_ok { + ::ok ! ::exception { has '+err3' => (isa => 'Str | ArrayRef'); - } "or add new types to the union"; + }, "or add new types to the union"; } { @@ -178,9 +178,9 @@ is_deeply($quux->quux, ["hi"], "... still has the old ArrayRef value"); with 'Foo::Role'; - ::throws_ok { + ::like ::exception { has '+bar' => ( is => 'ro' ); - } qr/has '\+attr' is not supported in roles/, + }, qr/has '\+attr' is not supported in roles/, "Test has '+attr' in roles explodes"; } diff --git a/t/030_roles/018_runtime_roles_w_params.t b/t/030_roles/018_runtime_roles_w_params.t index 0ca57ed..df0edb8 100644 --- a/t/030_roles/018_runtime_roles_w_params.t +++ b/t/030_roles/018_runtime_roles_w_params.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -26,9 +26,9 @@ use Test::Exception; is($foo->bar, 'BAR', '... got the expect value'); ok(!$foo->can('baz'), '... no baz method though'); - lives_ok { + ok ! exception { Bar->meta->apply($foo) - } '... this works'; + }, '... this works'; is($foo->bar, 'BAR', '... got the expect value'); ok($foo->can('baz'), '... we have baz method now'); @@ -43,9 +43,9 @@ use Test::Exception; is($foo->bar, 'BAR', '... got the expect value'); ok(!$foo->can('baz'), '... no baz method though'); - lives_ok { + ok ! exception { Bar->meta->apply($foo, (rebless_params => { baz => 'FOO-BAZ' })) - } '... this works'; + }, '... this works'; is($foo->bar, 'BAR', '... got the expect value'); ok($foo->can('baz'), '... we have baz method now'); @@ -60,9 +60,9 @@ use Test::Exception; is($foo->bar, 'BAR', '... got the expect value'); ok(!$foo->can('baz'), '... no baz method though'); - lives_ok { + ok ! exception { Bar->meta->apply($foo, (rebless_params => { bar => 'FOO-BAR', baz => 'FOO-BAZ' })) - } '... this works'; + }, '... this works'; is($foo->bar, 'FOO-BAR', '... got the expect value'); ok($foo->can('baz'), '... we have baz method now'); diff --git a/t/030_roles/020_role_composite.t b/t/030_roles/020_role_composite.t index 1362868..5800e5e 100644 --- a/t/030_roles/020_role_composite.t +++ b/t/030_roles/020_role_composite.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -48,9 +48,9 @@ use Moose::Meta::Role::Composite; Role::Baz ); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this composed okay'; + }, '... this composed okay'; ##... now nest 'em { diff --git a/t/030_roles/021_role_composite_exclusion.t b/t/030_roles/021_role_composite_exclusion.t index 322cd0a..ffd8441 100644 --- a/t/030_roles/021_role_composite_exclusion.t +++ b/t/030_roles/021_role_composite_exclusion.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -33,7 +33,7 @@ ok(Role::ExcludesFoo->meta->excludes_role('Role::Foo'), '... got the right exclu ok(Role::DoesExcludesFoo->meta->excludes_role('Role::Foo'), '... got the right exclusions'); # test simple exclusion -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -42,7 +42,7 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; # test no conflicts { @@ -56,9 +56,9 @@ dies_ok { is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this lives as expected'; + }, '... this lives as expected'; } # test no conflicts w/exclusion @@ -73,16 +73,16 @@ dies_ok { is($c->name, 'Role::Bar|Role::ExcludesFoo', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this lives as expected'; + }, '... this lives as expected'; is_deeply([$c->get_excluded_roles_list], ['Role::Foo'], '... has excluded roles'); } # test conflict with an "inherited" exclusion -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -92,10 +92,10 @@ dies_ok { ) ); -} '... this fails as expected'; +}, '... this fails as expected'; # test conflict with an "inherited" exclusion of an "inherited" role -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -104,6 +104,6 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; done_testing; diff --git a/t/030_roles/022_role_composition_req_methods.t b/t/030_roles/022_role_composition_req_methods.t index e3f1beb..04f6140 100644 --- a/t/030_roles/022_role_composition_req_methods.t +++ b/t/030_roles/022_role_composition_req_methods.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -39,9 +39,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_required_method_list ], @@ -62,9 +62,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::ProvidesFoo', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_required_method_list ], @@ -86,9 +86,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_required_method_list ], @@ -111,9 +111,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::ProvidesBar|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_required_method_list ], diff --git a/t/030_roles/023_role_composition_attributes.t b/t/030_roles/023_role_composition_attributes.t index b8f8af0..570eb4e 100644 --- a/t/030_roles/023_role_composition_attributes.t +++ b/t/030_roles/023_role_composition_attributes.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -43,9 +43,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_attribute_list ], @@ -55,7 +55,7 @@ use Moose::Meta::Role::Composite; } # test simple conflict -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -64,10 +64,10 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; # test complex conflict -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -78,10 +78,10 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; # test simple conflict -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -90,6 +90,6 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; done_testing; diff --git a/t/030_roles/024_role_composition_methods.t b/t/030_roles/024_role_composition_methods.t index 5183245..e03eec2 100644 --- a/t/030_roles/024_role_composition_methods.t +++ b/t/030_roles/024_role_composition_methods.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -49,9 +49,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_method_list ], @@ -72,9 +72,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::FooConflict', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_method_list ], @@ -103,9 +103,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar|Role::FooConflict|Role::BarConflict', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_method_list ], @@ -132,9 +132,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::AnotherFooConflict', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_method_list ], diff --git a/t/030_roles/025_role_composition_override.t b/t/030_roles/025_role_composition_override.t index 4c428f2..cc5008d 100644 --- a/t/030_roles/025_role_composition_override.t +++ b/t/030_roles/025_role_composition_override.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -48,9 +48,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this lives ok'; + }, '... this lives ok'; is_deeply( [ sort $c->get_method_modifier_list('override') ], @@ -60,7 +60,7 @@ use Moose::Meta::Role::Composite; } # test simple overrides w/ conflicts -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -69,10 +69,10 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; # test simple overrides w/ conflicts -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -81,11 +81,11 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; # test simple overrides w/ conflicts -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -95,11 +95,11 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; # test simple overrides w/ conflicts -dies_ok { +ok exception { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -109,6 +109,6 @@ dies_ok { ] ) ); -} '... this fails as expected'; +}, '... this fails as expected'; done_testing; diff --git a/t/030_roles/026_role_composition_method_mods.t b/t/030_roles/026_role_composition_method_mods.t index 5df6523..bd043b9 100644 --- a/t/030_roles/026_role_composition_method_mods.t +++ b/t/030_roles/026_role_composition_method_mods.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -62,9 +62,9 @@ use Moose::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - lives_ok { + ok ! exception { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + }, '... this succeeds as expected'; is_deeply( [ sort $c->get_method_modifier_list('before') ], diff --git a/t/030_roles/031_roles_applied_in_create.t b/t/030_roles/031_roles_applied_in_create.t index 10d698c..4ca7341 100644 --- a/t/030_roles/031_roles_applied_in_create.t +++ b/t/030_roles/031_roles_applied_in_create.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Class; use Moose::Util; @@ -13,7 +13,7 @@ use lib 't/lib', 'lib'; # Note that this test passed (pre svn #5543) if we inlined the role # definitions in this file, as it was very timing sensitive. -lives_ok( +ok (! exception ( sub { my $builder_meta = Moose::Meta::Class->create( 'YATTA' => ( @@ -21,7 +21,7 @@ lives_ok( roles => [qw( Role::Interface Role::Child )], ) ); - }, + }), 'Create a new class with several roles' ); diff --git a/t/030_roles/043_conflict_many_methods.t b/t/030_roles/043_conflict_many_methods.t index 785d48f..4572adf 100644 --- a/t/030_roles/043_conflict_many_methods.t +++ b/t/030_roles/043_conflict_many_methods.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Bomb; @@ -33,16 +33,16 @@ use Test::Exception; package PracticalJoke; use Moose; - ::throws_ok { + ::like ::exception { with 'Bomb', 'Spouse'; - } qr/Due to method name conflicts in roles 'Bomb' and 'Spouse', the methods 'explode' and 'fuse' must be implemented or excluded by 'PracticalJoke'/; + }, qr/Due to method name conflicts in roles 'Bomb' and 'Spouse', the methods 'explode' and 'fuse' must be implemented or excluded by 'PracticalJoke'/; - ::throws_ok { + ::like ::exception { with ( 'Bomb', 'Spouse', 'Caninish', 'Treeve', ); - } qr/Due to a method name conflict in roles 'Caninish' and 'Treeve', the method 'bark' must be implemented or excluded by 'PracticalJoke'/; + }, qr/Due to a method name conflict in roles 'Caninish' and 'Treeve', the method 'bark' must be implemented or excluded by 'PracticalJoke'/; } done_testing; diff --git a/t/030_roles/044_role_attrs.t b/t/030_roles/044_role_attrs.t index 5bdd14c..a5c4f6d 100644 --- a/t/030_roles/044_role_attrs.t +++ b/t/030_roles/044_role_attrs.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose (); use Moose::Meta::Role; diff --git a/t/030_roles/045_role_compose_requires.t b/t/030_roles/045_role_compose_requires.t index 75f2e3b..4ee7dd4 100644 --- a/t/030_roles/045_role_compose_requires.t +++ b/t/030_roles/045_role_compose_requires.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package My::Role1; @@ -54,11 +54,11 @@ use Test::Exception; # roles they consume. { local $TODO = "role attributes don't satisfy method requirements"; - lives_ok { package My::Test1; use Moose; with 'My::Role2'; } + ok ! exception { package My::Test1; use Moose; with 'My::Role2'; }, 'role2(provides attribute) consumes role1'; } -lives_ok { package My::Test2; use Moose; with 'My::Role3'; } +ok ! exception { package My::Test2; use Moose; with 'My::Role3'; }, 'role3(provides method) consumes role1'; # As I understand the design, Roles composed in the same with() statement @@ -66,81 +66,81 @@ lives_ok { package My::Test2; use Moose; with 'My::Role3'; } # assumption is false. -Vince Veselosky { local $TODO = "role attributes don't satisfy method requirements"; - lives_ok { package My::Test3; use Moose; with 'My::Role4', 'My::Role1'; } + ok ! exception { package My::Test3; use Moose; with 'My::Role4', 'My::Role1'; }, 'class consumes role4(provides attribute), role1'; } { local $TODO = "role attributes don't satisfy method requirements"; - lives_ok { package My::Test4; use Moose; with 'My::Role1', 'My::Role4'; } + ok ! exception { package My::Test4; use Moose; with 'My::Role1', 'My::Role4'; }, 'class consumes role1, role4(provides attribute)'; } -lives_ok { package My::Test5; use Moose; with 'My::Role5', 'My::Role1'; } +ok ! exception { package My::Test5; use Moose; with 'My::Role5', 'My::Role1'; }, 'class consumes role5(provides method), role1'; -lives_ok { package My::Test6; use Moose; with 'My::Role1', 'My::Role5'; } +ok ! exception { package My::Test6; use Moose; with 'My::Role1', 'My::Role5'; }, 'class consumes role1, role5(provides method)'; # Inherited methods/attributes should satisfy requires(), as long as # extends() comes first in code order. -lives_ok { +ok ! exception { package My::Test7; use Moose; extends 'My::Base1'; with 'My::Role1'; -} +}, 'class extends base1(provides attribute), consumes role1'; -lives_ok { +ok ! exception { package My::Test8; use Moose; extends 'My::Base2'; with 'My::Role1'; -} +}, 'class extends base2(provides method), consumes role1'; # Attributes/methods implemented in class should satisfy requires() -lives_ok { +ok ! exception { package My::Test9; use Moose; has 'test_output', is => 'rw'; with 'My::Role1'; -} +}, 'class provides attribute, consumes role1'; -lives_ok { +ok ! exception { package My::Test10; use Moose; sub test_output { } with 'My::Role1'; -} +}, 'class provides method, consumes role1'; # Roles composed in separate with() statements SHOULD demonstrate ordering # dependency. See comment with tests 3-6 above. -lives_ok { +ok ! exception { package My::Test11; use Moose; with 'My::Role4'; with 'My::Role1'; -} +}, 'class consumes role4(provides attribute); consumes role1'; -dies_ok { package My::Test12; use Moose; with 'My::Role1'; with 'My::Role4'; } +ok exception { package My::Test12; use Moose; with 'My::Role1'; with 'My::Role4'; }, 'class consumes role1; consumes role4(provides attribute)'; -lives_ok { +ok ! exception { package My::Test13; use Moose; with 'My::Role5'; with 'My::Role1'; -} +}, 'class consumes role5(provides method); consumes role1'; -dies_ok { package My::Test14; use Moose; with 'My::Role1'; with 'My::Role5'; } +ok exception { package My::Test14; use Moose; with 'My::Role1'; with 'My::Role5'; }, 'class consumes role1; consumes role5(provides method)'; done_testing; diff --git a/t/030_roles/047_role_attribute_conflict.t b/t/030_roles/047_role_attribute_conflict.t index 46b3296..355f1e7 100644 --- a/t/030_roles/047_role_attribute_conflict.t +++ b/t/030_roles/047_role_attribute_conflict.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package My::Role1; @@ -22,7 +22,7 @@ use Test::Exception; is => 'ro', ); - ::throws_ok { with 'My::Role1' } qr/attribute conflict.+My::Role2.+foo/, + ::like ::exception { with 'My::Role1' }, qr/attribute conflict.+My::Role2.+foo/, 'attribute conflict when composing one role into another'; } diff --git a/t/030_roles/048_method_modifiers.t b/t/030_roles/048_method_modifiers.t index 4bab997..fc5274b 100644 --- a/t/030_roles/048_method_modifiers.t +++ b/t/030_roles/048_method_modifiers.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; my $FooRole; { @@ -66,7 +66,7 @@ my $QuuxRole; package Quux::Role; use Moose::Role; { our $TODO; local $TODO = "can't handle regexes yet"; - ::lives_ok { + ::ok ! ::exception { after qr/foo|bar/ => sub { $QuuxRole++ } }; } diff --git a/t/040_type_constraints/001_util_type_constraints.t b/t/040_type_constraints/001_util_type_constraints.t index c7c611e..367d0b8 100644 --- a/t/040_type_constraints/001_util_type_constraints.t +++ b/t/040_type_constraints/001_util_type_constraints.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util (); @@ -118,7 +118,7 @@ is($string->validate(5), "This is not a string (5)", '... validated unsuccessfully (got error)'); -lives_ok { Moose::Meta::Attribute->new('bob', isa => 'Spong') } +ok ! exception { Moose::Meta::Attribute->new('bob', isa => 'Spong') }, 'meta-attr construction ok even when type constraint utils loaded first'; # Test type constraint predicate return values. @@ -130,9 +130,9 @@ foreach my $predicate (qw/equals is_subtype_of is_a_type_of/) { # Test adding things which don't look like types to the registry throws an exception my $r = Moose::Util::TypeConstraints->get_type_constraint_registry; -throws_ok {$r->add_type_constraint()} qr/not a valid type constraint/, '->add_type_constraint(undef) throws'; -throws_ok {$r->add_type_constraint('foo')} qr/not a valid type constraint/, '->add_type_constraint("foo") throws'; -throws_ok {$r->add_type_constraint(bless {}, 'SomeClass')} qr/not a valid type constraint/, '->add_type_constraint(SomeClass->new) throws'; +like exception {$r->add_type_constraint()}, qr/not a valid type constraint/, '->add_type_constraint(undef) throws'; +like exception {$r->add_type_constraint('foo')}, qr/not a valid type constraint/, '->add_type_constraint("foo") throws'; +like exception {$r->add_type_constraint(bless {}, 'SomeClass')}, qr/not a valid type constraint/, '->add_type_constraint(SomeClass->new) throws'; # Test some specific things that in the past did not work, # specifically weird variations on anon subtypes. @@ -186,7 +186,7 @@ throws_ok {$r->add_type_constraint(bless {}, 'SomeClass')} qr/not a valid type c } { - throws_ok { subtype 'Foo' } qr/cannot consist solely of a name/, + like exception { subtype 'Foo' }, qr/cannot consist solely of a name/, 'Cannot call subtype with a single string argument'; } diff --git a/t/040_type_constraints/002_util_type_constraints_export.t b/t/040_type_constraints/002_util_type_constraints_export.t index 2dff998..6755a40 100644 --- a/t/040_type_constraints/002_util_type_constraints_export.t +++ b/t/040_type_constraints/002_util_type_constraints_export.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Foo; diff --git a/t/040_type_constraints/003_util_std_type_constraints.t b/t/040_type_constraints/003_util_std_type_constraints.t index 36f85c1..1e6423e 100644 --- a/t/040_type_constraints/003_util_std_type_constraints.t +++ b/t/040_type_constraints/003_util_std_type_constraints.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util (); diff --git a/t/040_type_constraints/004_util_find_type_constraint.t b/t/040_type_constraints/004_util_find_type_constraint.t index 63c9d02..45c1352 100644 --- a/t/040_type_constraints/004_util_find_type_constraint.t +++ b/t/040_type_constraints/004_util_find_type_constraint.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); diff --git a/t/040_type_constraints/005_util_type_coercion.t b/t/040_type_constraints/005_util_type_coercion.t index 49f9069..c60cf5b 100644 --- a/t/040_type_constraints/005_util_type_coercion.t +++ b/t/040_type_constraints/005_util_type_coercion.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -40,13 +40,13 @@ ok(!Header({}), '... this did not pass the type test'); my $anon_type = subtype Object => where { $_->isa('HTTPHeader') }; -lives_ok { +ok ! exception { coerce $anon_type => from ArrayRef => via { HTTPHeader->new(array => $_[0]) } => from HashRef => via { HTTPHeader->new(hash => $_[0]) }; -} 'coercion of anonymous subtype succeeds'; +}, 'coercion of anonymous subtype succeeds'; foreach my $coercion ( find_type_constraint('Header')->coercion, diff --git a/t/040_type_constraints/006_util_type_reloading.t b/t/040_type_constraints/006_util_type_reloading.t index d1acfc2..b2d4b0e 100644 --- a/t/040_type_constraints/006_util_type_reloading.t +++ b/t/040_type_constraints/006_util_type_reloading.t @@ -6,7 +6,7 @@ use warnings; use lib 't/lib', 'lib'; use Test::More; -use Test::Exception; +use Test::Fatal; $SIG{__WARN__} = sub { 0 }; diff --git a/t/040_type_constraints/007_util_more_type_coercion.t b/t/040_type_constraints/007_util_more_type_coercion.t index c24d6bc..e8a1044 100644 --- a/t/040_type_constraints/007_util_more_type_coercion.t +++ b/t/040_type_constraints/007_util_more_type_coercion.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -37,9 +37,9 @@ use Test::Exception; # try with arrays - lives_ok { + ok ! exception { $engine->header([ 1, 2, 3 ]); - } '... type was coerced without incident'; + }, '... type was coerced without incident'; isa_ok($engine->header, 'HTTPHeader'); is_deeply( @@ -50,9 +50,9 @@ use Test::Exception; # try with hash - lives_ok { + ok ! exception { $engine->header({ one => 1, two => 2, three => 3 }); - } '... type was coerced without incident'; + }, '... type was coerced without incident'; isa_ok($engine->header, 'HTTPHeader'); is_deeply( @@ -61,13 +61,13 @@ use Test::Exception; '... got the right hash value of the header'); ok(!defined($engine->header->array), '... no array value set'); - dies_ok { + ok exception { $engine->header("Foo"); - } '... dies with the wrong type, even after coercion'; + }, '... dies with the wrong type, even after coercion'; - lives_ok { + ok ! exception { $engine->header(HTTPHeader->new); - } '... lives with the right type, even after coercion'; + }, '... lives with the right type, even after coercion'; } { @@ -106,13 +106,13 @@ use Test::Exception; ok(!defined($engine->header->array), '... no array value set'); } -dies_ok { +ok exception { Engine->new(header => 'Foo'); -} '... dies correctly with bad params'; +}, '... dies correctly with bad params'; -dies_ok { +ok exception { Engine->new(header => \(my $var)); -} '... dies correctly with bad params'; +}, '... dies correctly with bad params'; { my $tc = Moose::Util::TypeConstraints::find_type_constraint('HTTPHeader'); @@ -126,7 +126,7 @@ dies_ok { 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') } + like exception { $tc->assert_coerce('total garbage') }, qr/Validation failed for .HTTPHeader./, "assert_coerce throws if result is not acceptable"; } diff --git a/t/040_type_constraints/008_union_types.t b/t/040_type_constraints/008_union_types.t index 58e0b26..c3fd98e 100644 --- a/t/040_type_constraints/008_union_types.t +++ b/t/040_type_constraints/008_union_types.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); diff --git a/t/040_type_constraints/009_union_types_and_coercions.t b/t/040_type_constraints/009_union_types_and_coercions.t index e7071f2..a960ea4 100644 --- a/t/040_type_constraints/009_union_types_and_coercions.t +++ b/t/040_type_constraints/009_union_types_and_coercions.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Requires { 'IO::String' => '0.01', # skip all if not installed @@ -79,9 +79,9 @@ use Test::Requires { is($email->as_string, '... this is my body ...', '... got correct string'); - lives_ok { + ok ! exception { $email->raw_body('... this is the next body ...'); - } '... this will coerce correctly'; + }, '... this will coerce correctly'; isa_ok($email->raw_body, 'IO::String'); @@ -100,9 +100,9 @@ use Test::Requires { my $str2 = '... this is the next body (ref) ...'; - lives_ok { + ok ! exception { $email->raw_body(\$str2); - } '... this will coerce correctly'; + }, '... this will coerce correctly'; isa_ok($email->raw_body, 'IO::String'); @@ -122,9 +122,9 @@ use Test::Requires { my $io_str2 = IO::String->new('... this is the next body (IO::String) ...'); - lives_ok { + ok ! exception { $email->raw_body($io_str2); - } '... this will coerce correctly'; + }, '... this will coerce correctly'; isa_ok($email->raw_body, 'IO::String'); is($email->raw_body, $io_str2, '... and it is the one we expected'); @@ -175,14 +175,14 @@ use Test::Requires { { my $foo; - lives_ok { $foo = Foo->new( carray => 1 ) } + ok ! exception { $foo = Foo->new( carray => 1 ) }, 'Can pass non-ref value for carray'; is_deeply( $foo->carray, [1], 'carray was coerced to an array ref' ); - throws_ok { Foo->new( carray => {} ) } + like exception { Foo->new( carray => {} ) }, qr/\QValidation failed for 'Coerced|Coerced' with value \E(?!undef)/, 'Cannot pass a hash ref for carray attribute, and hash ref is not coerced to an undef'; } diff --git a/t/040_type_constraints/010_misc_type_tests.t b/t/040_type_constraints/010_misc_type_tests.t index 7b86046..2a8b22d 100644 --- a/t/040_type_constraints/010_misc_type_tests.t +++ b/t/040_type_constraints/010_misc_type_tests.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util qw(refaddr); BEGIN { @@ -13,9 +13,9 @@ BEGIN { # subtype 'aliasing' ... -lives_ok { +ok ! exception { subtype 'Numb3rs' => as 'Num'; -} '... create bare subtype fine'; +}, '... create bare subtype fine'; my $numb3rs = find_type_constraint('Numb3rs'); isa_ok($numb3rs, 'Moose::Meta::TypeConstraint'); diff --git a/t/040_type_constraints/011_container_type_constraint.t b/t/040_type_constraints/011_container_type_constraint.t index b349f93..a99e081 100644 --- a/t/040_type_constraints/011_container_type_constraint.t +++ b/t/040_type_constraints/011_container_type_constraint.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); diff --git a/t/040_type_constraints/012_container_type_coercion.t b/t/040_type_constraints/012_container_type_coercion.t index 9a4c98d..76a276f 100644 --- a/t/040_type_constraints/012_container_type_coercion.t +++ b/t/040_type_constraints/012_container_type_coercion.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); diff --git a/t/040_type_constraints/013_advanced_type_creation.t b/t/040_type_constraints/013_advanced_type_creation.t index 8de07c9..be145b4 100644 --- a/t/040_type_constraints/013_advanced_type_creation.t +++ b/t/040_type_constraints/013_advanced_type_creation.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); diff --git a/t/040_type_constraints/015_enum.t b/t/040_type_constraints/015_enum.t index 92c0062..ae6bef6 100644 --- a/t/040_type_constraints/015_enum.t +++ b/t/040_type_constraints/015_enum.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Scalar::Util (); @@ -63,19 +63,19 @@ ok( !$anon_enum->is_subtype_of('ThisTypeDoesNotExist'), 'enum not a subtype of n ok( !$anon_enum->is_a_type_of('ThisTypeDoesNotExist'), 'enum not type of nonexistant type'); # validation -throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'ZeroValues', values => []) } +like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'ZeroValues', values => []) }, qr/You must have at least two values to enumerate through/; -throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'OneValue', values => [ 'a' ]) } +like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'OneValue', values => [ 'a' ]) }, qr/You must have at least two values to enumerate through/; -throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'ReferenceInEnum', values => [ 'a', {} ]) } +like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'ReferenceInEnum', values => [ 'a', {} ]) }, qr/Enum values must be strings, not 'HASH\(0x\w+\)'/; -throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'UndefInEnum', values => [ 'a', undef ]) } +like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'UndefInEnum', values => [ 'a', undef ]) }, qr/Enum values must be strings, not undef/; -throws_ok { +like exception { package Foo; use Moose; use Moose::Util::TypeConstraints; @@ -85,7 +85,7 @@ throws_ok { isa => enum ['a', 'aa', 'aaa'], # should be parenthesized! default => 'aa', ); -} qr/enum called with an array reference and additional arguments\. Did you mean to parenthesize the enum call's parameters\?/; +}, qr/enum called with an array reference and additional arguments\. Did you mean to parenthesize the enum call's parameters\?/; done_testing; diff --git a/t/040_type_constraints/016_subtyping_parameterized_types.t b/t/040_type_constraints/016_subtyping_parameterized_types.t index 3c6971f..e88dd76 100644 --- a/t/040_type_constraints/016_subtyping_parameterized_types.t +++ b/t/040_type_constraints/016_subtyping_parameterized_types.t @@ -4,15 +4,15 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok("Moose::Util::TypeConstraints"); } -lives_ok { +ok ! exception { subtype 'MySpecialHash' => as 'HashRef[Int]'; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; { my $t = find_type_constraint('MySpecialHash'); @@ -37,14 +37,14 @@ lives_ok { ok( !$t->is_subtype_of("ThisTypeDoesNotExist"), "not a subtype of a non existant type" ); } -lives_ok { +ok ! exception { subtype 'MySpecialHashExtended' => as 'HashRef[Int]' => where { # all values are less then 10 (scalar grep { $_ < 10 } values %{$_}) ? 1 : undef }; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; { my $t = find_type_constraint('MySpecialHashExtended'); @@ -63,7 +63,7 @@ lives_ok { ok(!$t->check({ one => "ONE", two => "TWO" }), '... validated it correctly'); } -lives_ok { +ok ! exception { subtype 'MyNonSpecialHash' => as "HashRef" => where { keys %$_ == 3 }; @@ -114,10 +114,10 @@ lives_ok { ok $SubOfMyArrayRef->check([15,20,25]), '[15,20,25] is a bunch of big ints'; ok ! $SubOfMyArrayRef->check([15,5,25]), '[15,5,25] is NOT a bunch of big ints'; - throws_ok sub { + like exception { my $SubOfMyArrayRef = subtype 'SubSubOfMyArrayRef', as 'SubOfMyArrayRef[Str]'; - }, qr/Str is not a subtype of BiggerInt/, 'Failed to parameterize with a bad type parameter'; + },, qr/Str is not a subtype of BiggerInt/, 'Failed to parameterize with a bad type parameter'; } { diff --git a/t/040_type_constraints/017_subtyping_union_types.t b/t/040_type_constraints/017_subtyping_union_types.t index b76ae7c..12d8226 100644 --- a/t/040_type_constraints/017_subtyping_union_types.t +++ b/t/040_type_constraints/017_subtyping_union_types.t @@ -4,15 +4,15 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok("Moose::Util::TypeConstraints"); } -lives_ok { +ok ! exception { subtype 'MyCollections' => as 'ArrayRef | HashRef'; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; { my $t = find_type_constraint('MyCollections'); @@ -31,7 +31,7 @@ lives_ok { ok(!$t->check(1), '... validated it correctly'); } -lives_ok { +ok ! exception { subtype 'MyCollectionsExtended' => as 'ArrayRef|HashRef' => where { @@ -43,7 +43,7 @@ lives_ok { } 1; }; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; { my $t = find_type_constraint('MyCollectionsExtended'); diff --git a/t/040_type_constraints/018_custom_parameterized_types.t b/t/040_type_constraints/018_custom_parameterized_types.t index c4969e5..d1540c6 100644 --- a/t/040_type_constraints/018_custom_parameterized_types.t +++ b/t/040_type_constraints/018_custom_parameterized_types.t @@ -4,31 +4,31 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok("Moose::Util::TypeConstraints"); use_ok('Moose::Meta::TypeConstraint::Parameterized'); } -lives_ok { +ok ! exception { subtype 'AlphaKeyHash' => as 'HashRef' => where { # no keys match non-alpha (grep { /[^a-zA-Z]/ } keys %$_) == 0 }; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; -lives_ok { +ok ! exception { subtype 'Trihash' => as 'AlphaKeyHash' => where { keys(%$_) == 3 }; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; -lives_ok { +ok ! exception { subtype 'Noncon' => as 'Item'; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; { my $t = find_type_constraint('AlphaKeyHash'); @@ -68,20 +68,20 @@ ok($th->check({ one => 1, two => 0, three => 1 }), '... validated it correctly') ok(!$th->check({ one => 1, two => 2, three => 1 }), '... validated it correctly'); ok(!$th->check({foo1 => 1, bar2 => 0, baz3 => 1}), '... validated it correctly'); -dies_ok { +ok exception { Moose::Meta::TypeConstraint::Parameterized->new( name => 'Str[Int]', parent => find_type_constraint('Str'), type_parameter => find_type_constraint('Int'), ); -} 'non-containers cannot be parameterized'; +}, 'non-containers cannot be parameterized'; -dies_ok { +ok exception { Moose::Meta::TypeConstraint::Parameterized->new( name => 'Noncon[Int]', parent => find_type_constraint('Noncon'), type_parameter => find_type_constraint('Int'), ); -} 'non-containers cannot be parameterized'; +}, 'non-containers cannot be parameterized'; done_testing; diff --git a/t/040_type_constraints/019_coerced_parameterized_types.t b/t/040_type_constraints/019_coerced_parameterized_types.t index 84de514..fd2c29a 100644 --- a/t/040_type_constraints/019_coerced_parameterized_types.t +++ b/t/040_type_constraints/019_coerced_parameterized_types.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok("Moose::Util::TypeConstraints"); @@ -26,11 +26,11 @@ BEGIN { subtype 'MyList' => as 'Object' => where { $_->isa('MyList') }; -lives_ok { +ok ! exception { coerce 'ArrayRef' => from 'MyList' => via { [ $_->items ] } -} '... created the coercion okay'; +}, '... created the coercion okay'; my $mylist = Moose::Util::TypeConstraints::find_or_parse_type_constraint('MyList[Int]'); @@ -43,11 +43,11 @@ subtype 'EvenList' => as 'MyList' => where { $_->items % 2 == 0 }; # XXX: get this to work *without* the declaration. I suspect it'll be a new # method in Moose::Meta::TypeCoercion that will look at the parents of the # coerced type as well. but will that be too "action at a distance"-ey? -lives_ok { +ok ! exception { coerce 'ArrayRef' => from 'EvenList' => via { [ $_->items ] } -} '... created the coercion okay'; +}, '... created the coercion okay'; my $evenlist = Moose::Util::TypeConstraints::find_or_parse_type_constraint('EvenList[Int]'); diff --git a/t/040_type_constraints/020_class_type_constraint.t b/t/040_type_constraints/020_class_type_constraint.t index f91ddf5..420c3bd 100644 --- a/t/040_type_constraints/020_class_type_constraint.t +++ b/t/040_type_constraints/020_class_type_constraint.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -24,8 +24,8 @@ BEGIN { } -lives_ok { class_type 'Beep' } 'class_type keywork works'; -lives_ok { class_type('Boop', message { "${_} is not a Boop" }) } +ok ! exception { class_type 'Beep' }, 'class_type keywork works'; +ok ! exception { class_type('Boop', message { "${_} is not a Boop" }) }, 'class_type keywork works with message'; my $type = find_type_constraint("Foo"); diff --git a/t/040_type_constraints/021_maybe_type_constraint.t b/t/040_type_constraints/021_maybe_type_constraint.t index 4974e09..e301669 100644 --- a/t/040_type_constraints/021_maybe_type_constraint.t +++ b/t/040_type_constraints/021_maybe_type_constraint.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util::TypeConstraints; @@ -38,41 +38,41 @@ ok(!$type->check([]), '... checked type correctly (fail)'); has 'maybe_bar' => (is => 'rw', isa => maybe_type(class_type('Bar'))); } -lives_ok { +ok ! exception { Foo->new(arr => [], bar => Bar->new); -} '... Bar->new isa Bar'; +}, '... Bar->new isa Bar'; -dies_ok { +ok exception { Foo->new(arr => [], bar => undef); -} '... undef isnta Bar'; +}, '... undef isnta Bar'; -lives_ok { +ok ! exception { Foo->new(arr => [], maybe_bar => Bar->new); -} '... Bar->new isa maybe(Bar)'; +}, '... Bar->new isa maybe(Bar)'; -lives_ok { +ok ! exception { Foo->new(arr => [], maybe_bar => undef); -} '... undef isa maybe(Bar)'; +}, '... undef isa maybe(Bar)'; -dies_ok { +ok exception { Foo->new(arr => [], maybe_bar => 1); -} '... 1 isnta maybe(Bar)'; +}, '... 1 isnta maybe(Bar)'; -lives_ok { +ok ! exception { Foo->new(arr => []); -} '... it worked!'; +}, '... it worked!'; -lives_ok { +ok ! exception { Foo->new(arr => undef); -} '... it worked!'; +}, '... it worked!'; -dies_ok { +ok exception { Foo->new(arr => 100); -} '... failed the type check'; +}, '... failed the type check'; -dies_ok { +ok exception { Foo->new(arr => 'hello world'); -} '... failed the type check'; +}, '... failed the type check'; { @@ -121,14 +121,14 @@ ok sub {$obj->Maybe_Int(undef); 1}->() ok !$Maybe_Int->check("") => 'failed ("")'; -throws_ok sub { $obj->Maybe_Int("") }, +like exception { $obj->Maybe_Int("") },, qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("")'; ok !$Maybe_Int->check("a") => 'failed ("a")'; -throws_ok sub { $obj->Maybe_Int("a") }, +like exception { $obj->Maybe_Int("a") },, qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("a")'; diff --git a/t/040_type_constraints/022_custom_type_errors.t b/t/040_type_constraints/022_custom_type_errors.t index f570474..8a9023a 100644 --- a/t/040_type_constraints/022_custom_type_errors.t +++ b/t/040_type_constraints/022_custom_type_errors.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Animal; @@ -25,35 +25,35 @@ use Test::Exception; ); } -lives_ok { my $goat = Animal->new( leg_count => 4 ) } +ok ! exception { my $goat = Animal->new( leg_count => 4 ) }, '... no errors thrown, value is good'; -lives_ok { my $spider = Animal->new( leg_count => 8 ) } +ok ! exception { my $spider = Animal->new( leg_count => 8 ) }, '... no errors thrown, value is good'; -throws_ok { my $fern = Animal->new( leg_count => 0 ) } +like exception { my $fern = Animal->new( leg_count => 0 ) }, qr/This number \(0\) is not less than ten!/, 'gave custom supertype error message on new'; -throws_ok { my $centipede = Animal->new( leg_count => 30 ) } +like exception { my $centipede = Animal->new( leg_count => 30 ) }, qr/This number \(30\) is not less than ten!/, 'gave custom subtype error message on new'; my $chimera; -lives_ok { $chimera = Animal->new( leg_count => 4 ) } +ok ! exception { $chimera = Animal->new( leg_count => 4 ) }, '... no errors thrown, value is good'; -throws_ok { $chimera->leg_count(0) } +like exception { $chimera->leg_count(0) }, qr/This number \(0\) is not less than ten!/, 'gave custom supertype error message on set to 0'; -throws_ok { $chimera->leg_count(16) } +like exception { $chimera->leg_count(16) }, qr/This number \(16\) is not less than ten!/, 'gave custom subtype error message on set to 16'; my $gimp = eval { Animal->new() }; is( $@, '', '... no errors thrown, value is good' ); -throws_ok { $gimp->leg_count } +like exception { $gimp->leg_count }, qr/This number \(0\) is not less than ten!/, 'gave custom supertype error message on lazy set to 0'; diff --git a/t/040_type_constraints/023_types_and_undef.t b/t/040_type_constraints/023_types_and_undef.t index 1c2e7ee..b4501eb 100644 --- a/t/040_type_constraints/023_types_and_undef.t +++ b/t/040_type_constraints/023_types_and_undef.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -70,41 +70,41 @@ ok(String('Foo'), '... "Foo" is a String'); my $foo = Foo->new; -lives_ok { $foo->vUndef(undef) } '... undef is a Foo->Undef'; -dies_ok { $foo->vDefined(undef) } '... undef is NOT a Foo->Defined'; -dies_ok { $foo->vInt(undef) } '... undef is NOT a Foo->Int'; -dies_ok { $foo->vNumber(undef) } '... undef is NOT a Foo->Number'; -dies_ok { $foo->vStr(undef) } '... undef is NOT a Foo->Str'; -dies_ok { $foo->vString(undef) } '... undef is NOT a Foo->String'; - -dies_ok { $foo->vUndef(5) } '... 5 is NOT a Foo->Undef'; -lives_ok { $foo->vDefined(5) } '... 5 is a Foo->Defined'; -lives_ok { $foo->vInt(5) } '... 5 is a Foo->Int'; -lives_ok { $foo->vNumber(5) } '... 5 is a Foo->Number'; -lives_ok { $foo->vStr(5) } '... 5 is a Foo->Str'; -dies_ok { $foo->vString(5) } '... 5 is NOT a Foo->String'; - -dies_ok { $foo->vUndef(0.5) } '... 0.5 is NOT a Foo->Undef'; -lives_ok { $foo->vDefined(0.5) } '... 0.5 is a Foo->Defined'; -dies_ok { $foo->vInt(0.5) } '... 0.5 is NOT a Foo->Int'; -lives_ok { $foo->vNumber(0.5) } '... 0.5 is a Foo->Number'; -lives_ok { $foo->vStr(0.5) } '... 0.5 is a Foo->Str'; -dies_ok { $foo->vString(0.5) } '... 0.5 is NOT a Foo->String'; - -dies_ok { $foo->vUndef('Foo') } '... "Foo" is NOT a Foo->Undef'; -lives_ok { $foo->vDefined('Foo') } '... "Foo" is a Foo->Defined'; -dies_ok { $foo->vInt('Foo') } '... "Foo" is NOT a Foo->Int'; -dies_ok { $foo->vNumber('Foo') } '... "Foo" is NOT a Foo->Number'; -lives_ok { $foo->vStr('Foo') } '... "Foo" is a Foo->Str'; -lives_ok { $foo->vString('Foo') } '... "Foo" is a Foo->String'; +ok ! exception { $foo->vUndef(undef) }, '... undef is a Foo->Undef'; +ok exception { $foo->vDefined(undef) }, '... undef is NOT a Foo->Defined'; +ok exception { $foo->vInt(undef) }, '... undef is NOT a Foo->Int'; +ok exception { $foo->vNumber(undef) }, '... undef is NOT a Foo->Number'; +ok exception { $foo->vStr(undef) }, '... undef is NOT a Foo->Str'; +ok exception { $foo->vString(undef) }, '... undef is NOT a Foo->String'; + +ok exception { $foo->vUndef(5) }, '... 5 is NOT a Foo->Undef'; +ok ! exception { $foo->vDefined(5) }, '... 5 is a Foo->Defined'; +ok ! exception { $foo->vInt(5) }, '... 5 is a Foo->Int'; +ok ! exception { $foo->vNumber(5) }, '... 5 is a Foo->Number'; +ok ! exception { $foo->vStr(5) }, '... 5 is a Foo->Str'; +ok exception { $foo->vString(5) }, '... 5 is NOT a Foo->String'; + +ok exception { $foo->vUndef(0.5) }, '... 0.5 is NOT a Foo->Undef'; +ok ! exception { $foo->vDefined(0.5) }, '... 0.5 is a Foo->Defined'; +ok exception { $foo->vInt(0.5) }, '... 0.5 is NOT a Foo->Int'; +ok ! exception { $foo->vNumber(0.5) }, '... 0.5 is a Foo->Number'; +ok ! exception { $foo->vStr(0.5) }, '... 0.5 is a Foo->Str'; +ok exception { $foo->vString(0.5) }, '... 0.5 is NOT a Foo->String'; + +ok exception { $foo->vUndef('Foo') }, '... "Foo" is NOT a Foo->Undef'; +ok ! exception { $foo->vDefined('Foo') }, '... "Foo" is a Foo->Defined'; +ok exception { $foo->vInt('Foo') }, '... "Foo" is NOT a Foo->Int'; +ok exception { $foo->vNumber('Foo') }, '... "Foo" is NOT a Foo->Number'; +ok ! exception { $foo->vStr('Foo') }, '... "Foo" is a Foo->Str'; +ok ! exception { $foo->vString('Foo') }, '... "Foo" is a Foo->String'; # the lazy tests -lives_ok { $foo->v_lazy_Undef() } '... undef is a Foo->Undef'; -dies_ok { $foo->v_lazy_Defined() } '... undef is NOT a Foo->Defined'; -dies_ok { $foo->v_lazy_Int() } '... undef is NOT a Foo->Int'; -dies_ok { $foo->v_lazy_Number() } '... undef is NOT a Foo->Number'; -dies_ok { $foo->v_lazy_Str() } '... undef is NOT a Foo->Str'; -dies_ok { $foo->v_lazy_String() } '... undef is NOT a Foo->String'; +ok ! exception { $foo->v_lazy_Undef() }, '... undef is a Foo->Undef'; +ok exception { $foo->v_lazy_Defined() }, '... undef is NOT a Foo->Defined'; +ok exception { $foo->v_lazy_Int() }, '... undef is NOT a Foo->Int'; +ok exception { $foo->v_lazy_Number() }, '... undef is NOT a Foo->Number'; +ok exception { $foo->v_lazy_Str() }, '... undef is NOT a Foo->Str'; +ok exception { $foo->v_lazy_String() }, '... undef is NOT a Foo->String'; done_testing; diff --git a/t/040_type_constraints/024_role_type_constraint.t b/t/040_type_constraints/024_role_type_constraint.t index 163bfca..b048538 100644 --- a/t/040_type_constraints/024_role_type_constraint.t +++ b/t/040_type_constraints/024_role_type_constraint.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -32,7 +32,7 @@ BEGIN { } -lives_ok { role_type('Boop', message { "${_} is not a Boop" }) } +ok ! exception { role_type('Boop', message { "${_} is not a Boop" }) }, 'role_type keywork works with message'; my $type = find_type_constraint("Foo"); diff --git a/t/040_type_constraints/026_normalize_type_name.t b/t/040_type_constraints/026_normalize_type_name.t index 1644931..e539d79 100644 --- a/t/040_type_constraints/026_normalize_type_name.t +++ b/t/040_type_constraints/026_normalize_type_name.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); diff --git a/t/040_type_constraints/027_parameterize_from.t b/t/040_type_constraints/027_parameterize_from.t index beab5b8..f815745 100644 --- a/t/040_type_constraints/027_parameterize_from.t +++ b/t/040_type_constraints/027_parameterize_from.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -43,38 +43,38 @@ isa_ok $params, 'Test::Moose::Meta::TypeConstraint::Parameterizable' => # test parameterizable -lives_ok sub { +ok ! exception { $params->parameterizable( { a => 'Hello', b => 'World' } ); -} => 'No problem setting parameterizable'; +}, => 'No problem setting parameterizable'; is_deeply $params->parameterizable, { a => 'Hello', b => 'World' } => 'Got expected values'; # test parameterized -lives_ok sub { +ok ! exception { $params->parameterized( { a => 1, b => 2 } ); -} => 'No problem setting parameterized'; +}, => 'No problem setting parameterized'; is_deeply $params->parameterized, { a => 1, b => 2 } => 'Got expected values'; -throws_ok sub { +like exception { $params->parameterized( { a => 'Hello', b => 'World' } ); - }, qr/Attribute \(parameterized\) does not pass the type constraint/ => + },, qr/Attribute \(parameterized\) does not pass the type constraint/ => 'parameterized throws expected error'; # test from_parameterizable -lives_ok sub { +ok ! exception { $params->from_parameterizable( { a => 1, b => 2 } ); -} => 'No problem setting from_parameterizable'; +}, => 'No problem setting from_parameterizable'; is_deeply $params->from_parameterizable, { a => 1, b => 2 } => 'Got expected values'; -throws_ok sub { +like exception { $params->from_parameterizable( { a => 'Hello', b => 'World' } ); - }, + },, qr/Attribute \(from_parameterizable\) does not pass the type constraint/ => 'from_parameterizable throws expected error'; diff --git a/t/040_type_constraints/029_define_type_twice_throws.t b/t/040_type_constraints/029_define_type_twice_throws.t index cbec2e2..b093d12 100644 --- a/t/040_type_constraints/029_define_type_twice_throws.t +++ b/t/040_type_constraints/029_define_type_twice_throws.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -17,11 +17,11 @@ BEGIN { subtype 'MySubType' => as 'Int' => where { 1 }; } -throws_ok { +like exception { package Some::Other::Class; use Moose::Util::TypeConstraints; subtype 'MySubType' => as 'Int' => where { 1 }; -} qr/cannot be created again/, 'Trying to create same type twice throws'; +}, qr/cannot be created again/, 'Trying to create same type twice throws'; done_testing; diff --git a/t/040_type_constraints/030_class_subtypes.t b/t/040_type_constraints/030_class_subtypes.t index ec9a156..dd50b65 100644 --- a/t/040_type_constraints/030_class_subtypes.t +++ b/t/040_type_constraints/030_class_subtypes.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util::TypeConstraints; use Moose::Meta::TypeConstraint; @@ -98,11 +98,11 @@ like $isa_foo->get_message( Baz->new ), qr/^Validation failed for 'IsaFoo' with ); } -throws_ok { +like exception { Quux->new(age => 3) -} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/; +}, qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/; -lives_ok { +ok ! exception { Quux->new(age => (bless {}, 'Positive')); }; @@ -111,11 +111,11 @@ eval " use Moose; "; -throws_ok { +like exception { Quux->new(age => 3) -} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/; +}, qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/; -lives_ok { +ok ! exception { Quux->new(age => Positive->new) }; @@ -132,11 +132,11 @@ class_type 'Negative' => message { "$_ is not a Negative Nancy" }; ); } -throws_ok { +like exception { Quux::Ier->new(age => 3) -} qr/^Attribute \(age\) does not pass the type constraint because: 3 is not a Negative Nancy /; +}, qr/^Attribute \(age\) does not pass the type constraint because: 3 is not a Negative Nancy /; -lives_ok { +ok ! exception { Quux::Ier->new(age => (bless {}, 'Negative')) }; diff --git a/t/040_type_constraints/033_type_names.t b/t/040_type_constraints/033_type_names.t index 0579ebb..bf39ea7 100644 --- a/t/040_type_constraints/033_type_names.t +++ b/t/040_type_constraints/033_type_names.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::TypeConstraint; use Moose::Util::TypeConstraints; @@ -12,19 +12,19 @@ TODO: { local $TODO = 'type names are not validated in the TC metaclass'; - throws_ok { Moose::Meta::TypeConstraint->new( name => 'Foo-Bar' ) } + like exception { Moose::Meta::TypeConstraint->new( name => 'Foo-Bar' ) }, qr/contains invalid characters/, 'Type names cannot contain a dash'; } -lives_ok { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) } +ok ! exception { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) }, 'Type names can contain periods and colons'; -throws_ok { subtype 'Foo-Baz' => as 'Item' } +like exception { subtype 'Foo-Baz' => as 'Item' }, qr/contains invalid characters/, 'Type names cannot contain a dash (via subtype sugar)'; -lives_ok { subtype 'Foo.Bar::Baz' => as 'Item' } +ok ! exception { subtype 'Foo.Bar::Baz' => as 'Item' }, 'Type names can contain periods and colons (via subtype sugar)'; is( Moose::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[In-valid]'), diff --git a/t/040_type_constraints/034_duck_types.t b/t/040_type_constraints/034_duck_types.t index 5682793..838c2e8 100644 --- a/t/040_type_constraints/034_duck_types.t +++ b/t/040_type_constraints/034_duck_types.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -62,21 +62,21 @@ use Test::Exception; } # try giving it a duck -lives_ok { DucktypeTest->new( duck => Duck->new ) } 'the Duck lives okay'; +ok ! exception { DucktypeTest->new( duck => Duck->new ) }, 'the Duck lives okay'; # try giving it a swan which is like a duck, but not close enough -throws_ok { DucktypeTest->new( duck => Swan->new ) } +like exception { DucktypeTest->new( duck => Swan->new ) }, qr/Swan is missing methods 'quack'/, "the Swan doesn't quack"; # try giving it a rubber RubberDuckey -lives_ok { DucktypeTest->new( swan => Swan->new ) } 'but a Swan can honk'; +ok ! exception { DucktypeTest->new( swan => Swan->new ) }, 'but a Swan can honk'; # try giving it a rubber RubberDuckey -lives_ok { DucktypeTest->new( duck => RubberDuck->new ) } +ok ! exception { DucktypeTest->new( duck => RubberDuck->new ) }, 'the RubberDuck lives okay'; # try with the other constraint form -lives_ok { DucktypeTest->new( other_swan => Swan->new ) } 'but a Swan can honk'; +ok ! exception { DucktypeTest->new( other_swan => Swan->new ) }, 'but a Swan can honk'; done_testing; diff --git a/t/040_type_constraints/035_duck_type_handles.t b/t/040_type_constraints/035_duck_type_handles.t index 366ce2d..cc3c169 100644 --- a/t/040_type_constraints/035_duck_type_handles.t +++ b/t/040_type_constraints/035_duck_type_handles.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; my @phonograph; { diff --git a/t/040_type_constraints/036_match_type_operator.t b/t/040_type_constraints/036_match_type_operator.t index fd5cc88..02d92e0 100644 --- a/t/040_type_constraints/036_match_type_operator.t +++ b/t/040_type_constraints/036_match_type_operator.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util::TypeConstraints; @@ -87,9 +87,9 @@ is( is_acceptable_color( 'magenta' ), 'CMYK', '... got the right value'); is( is_acceptable_color( 'yellow' ), 'CMYK', '... got the right value'); is( is_acceptable_color( 'black' ), 'CMYK', '... got the right value'); -dies_ok { +ok exception { is_acceptable_color( 'orange' ) -} '... got the exception'; +}, '... got the exception'; ## using it in an OO context @@ -222,8 +222,8 @@ sub not_enough_matches { CodeRef => sub { $_->('Hello code ref world') }; } -throws_ok { +like exception { not_enough_matches( [] ) -} qr/No cases matched for /, '... not enough matches'; +}, qr/No cases matched for /, '... not enough matches'; done_testing; diff --git a/t/050_metaclasses/001_custom_attr_meta_with_roles.t b/t/050_metaclasses/001_custom_attr_meta_with_roles.t index a2d1495..78f93fa 100644 --- a/t/050_metaclasses/001_custom_attr_meta_with_roles.t +++ b/t/050_metaclasses/001_custom_attr_meta_with_roles.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { diff --git a/t/050_metaclasses/002_custom_attr_meta_as_role.t b/t/050_metaclasses/002_custom_attr_meta_as_role.t index 55ee9c6..e516060 100644 --- a/t/050_metaclasses/002_custom_attr_meta_as_role.t +++ b/t/050_metaclasses/002_custom_attr_meta_as_role.t @@ -4,19 +4,19 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; -lives_ok { +ok ! exception { package MooseX::Attribute::Test; use Moose::Role; -} 'creating custom attribute "metarole" is okay'; +}, 'creating custom attribute "metarole" is okay'; -lives_ok { +ok ! exception { package Moose::Meta::Attribute::Custom::Test; use Moose; extends 'Moose::Meta::Attribute'; with 'MooseX::Attribute::Test'; -} 'custom attribute metaclass extending role is okay'; +}, 'custom attribute metaclass extending role is okay'; done_testing; diff --git a/t/050_metaclasses/003_moose_w_metaclass.t b/t/050_metaclasses/003_moose_w_metaclass.t index 0749068..d6810c3 100644 --- a/t/050_metaclasses/003_moose_w_metaclass.t +++ b/t/050_metaclasses/003_moose_w_metaclass.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod diff --git a/t/050_metaclasses/004_moose_for_meta.t b/t/050_metaclasses/004_moose_for_meta.t index bd415ee..02cc1bc 100644 --- a/t/050_metaclasses/004_moose_for_meta.t +++ b/t/050_metaclasses/004_moose_for_meta.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod diff --git a/t/050_metaclasses/010_extending_and_embedding_back_compat.t b/t/050_metaclasses/010_extending_and_embedding_back_compat.t index e54fe03..31301e4 100644 --- a/t/050_metaclasses/010_extending_and_embedding_back_compat.t +++ b/t/050_metaclasses/010_extending_and_embedding_back_compat.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { diff --git a/t/050_metaclasses/012_moose_exporter.t b/t/050_metaclasses/012_moose_exporter.t index e37669d..f00e9a8 100644 --- a/t/050_metaclasses/012_moose_exporter.t +++ b/t/050_metaclasses/012_moose_exporter.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Requires { 'Test::Output' => '0.01', # skip all if not installed @@ -197,8 +197,9 @@ use Test::Requires { use Moose (); - ::dies_ok( - sub { + my $error; + ::ok($error = ::exception + { Moose::Exporter->setup_import_methods( also => [ 'Moose', 'MooseX::CircularAlso' ], ); @@ -207,7 +208,7 @@ use Test::Requires { ); ::like( - $@, + $error, qr/\QCircular reference in 'also' parameter to Moose::Exporter between MooseX::CircularAlso and MooseX::CircularAlso/, 'got the expected error from circular reference in also' ); @@ -218,8 +219,9 @@ use Test::Requires { use Moose (); - ::dies_ok( - sub { + my $error; + ::ok($error = ::exception + { Moose::Exporter->setup_import_methods( also => [ 'NoSuchThing' ], ); @@ -228,7 +230,7 @@ use Test::Requires { ); ::like( - $@, + $error, qr/\QPackage in also (NoSuchThing) does not seem to use Moose::Exporter (is it loaded?) at /, 'got the expected error from a reference in also to a package which is not loaded' ); @@ -239,8 +241,9 @@ use Test::Requires { use Moose (); - ::dies_ok( - sub { + my $error; + ::ok($error = ::exception + { Moose::Exporter->setup_import_methods( also => [ 'Moose::Meta::Method' ], ); @@ -249,7 +252,7 @@ use Test::Requires { ); ::like( - $@, + $error, qr/\QPackage in also (Moose::Meta::Method) does not seem to use Moose::Exporter at /, 'got the expected error from a reference in also to a package which does not use Moose::Exporter' ); diff --git a/t/050_metaclasses/013_metaclass_traits.t b/t/050_metaclasses/013_metaclass_traits.t index b47cea4..7823237 100644 --- a/t/050_metaclasses/013_metaclass_traits.t +++ b/t/050_metaclasses/013_metaclass_traits.t @@ -6,7 +6,7 @@ use warnings; use lib 't/lib', 'lib'; use Test::More; -use Test::Exception; +use Test::Fatal; { package My::SimpleTrait; @@ -167,9 +167,10 @@ is( Role::Foo->meta()->simple(), 5, { require Moose::Util::TypeConstraints; - dies_ok( sub { Moose::Util::TypeConstraints->import( -traits => 'My::SimpleTrait' ) }, - 'cannot provide -traits to an exporting module that does not init_meta' ); - like( $@, qr/does not have an init_meta/, + my $error; + ok($error = exception { Moose::Util::TypeConstraints->import( -traits => 'My::SimpleTrait' ) }, + 'cannot provide -traits to an exporting module that does not init_meta'); + like( $error, qr/does not have an init_meta/, '... and error provides a useful explanation' ); } @@ -198,10 +199,10 @@ is( Foo::Subclass->meta()->attr2(), 'something', has an_attr => ( is => 'ro' ); } -lives_ok { +ok ! exception { my $instance = Class::WithAlreadyPresentTrait->new( an_attr => 'value' ); is( $instance->an_attr, 'value', 'Can get value' ); -} +}, 'Can create instance and access attributes'; { @@ -215,10 +216,10 @@ lives_ok { has an_attr => ( is => 'ro' ); } -lives_ok { +ok ! exception { my $instance = Class::WhichLoadsATraitFromDisk->new( an_attr => 'value' ); is( $instance->an_attr, 'value', 'Can get value' ); -} +}, 'Can create instance and access attributes'; done_testing; diff --git a/t/050_metaclasses/014_goto_moose_import.t b/t/050_metaclasses/014_goto_moose_import.t index 06437ac..18d53fb 100644 --- a/t/050_metaclasses/014_goto_moose_import.t +++ b/t/050_metaclasses/014_goto_moose_import.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; # Some packages out in the wild cooperate with Moose by using goto # &Moose::import. we want to make sure it still works. @@ -31,8 +31,8 @@ use Test::Exception; MooseAlike1->import(); - ::lives_ok( sub { has( 'size', is => 'bare' ) }, - 'has was exported via MooseAlike1' ); + ::ok ! ::exception { has( 'size', is => 'bare' ) }, + 'has was exported via MooseAlike1'; MooseAlike1->unimport(); } @@ -68,8 +68,8 @@ isa_ok( Foo->meta(), 'Moose::Meta::Class' ); MooseAlike2->import(); - ::lives_ok( sub { has( 'size', is => 'bare' ) }, - 'has was exported via MooseAlike2' ); + ::ok ! ::exception { has( 'size', is => 'bare' ) }, + 'has was exported via MooseAlike2'; MooseAlike2->unimport(); } diff --git a/t/050_metaclasses/015_metarole.t b/t/050_metaclasses/015_metarole.t index 6d80c50..17dd7be 100644 --- a/t/050_metaclasses/015_metarole.t +++ b/t/050_metaclasses/015_metarole.t @@ -6,7 +6,7 @@ use warnings; use lib 't/lib', 'lib'; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util::MetaRole; @@ -580,10 +580,10 @@ use Moose::Util::MetaRole; } } -lives_ok { +ok ! exception { package UsesExportedMoose; ExportsMoose->import; -} 'import module which loads a role from disk during init_meta'; +}, 'import module which loads a role from disk during init_meta'; { package Foo::Meta::Role; diff --git a/t/050_metaclasses/017_use_base_of_moose.t b/t/050_metaclasses/017_use_base_of_moose.t index 5f7aac9..31c672f 100644 --- a/t/050_metaclasses/017_use_base_of_moose.t +++ b/t/050_metaclasses/017_use_base_of_moose.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package NoOpTrait; diff --git a/t/050_metaclasses/018_throw_error.t b/t/050_metaclasses/018_throw_error.t index 5988905..c706c9f 100644 --- a/t/050_metaclasses/018_throw_error.t +++ b/t/050_metaclasses/018_throw_error.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -119,7 +119,7 @@ sub create_error { ); use Moose; - ::dies_ok { extends 'Baz::Sub' } 'error_class is included in metaclass compatibility checks'; + ::ok ::exception { extends 'Baz::Sub' }, 'error_class is included in metaclass compatibility checks'; } { @@ -145,7 +145,7 @@ ok( Foo::Sub->meta->error_class->isa('Moose::Error::Croak'), package Foo::Sub::Sub; use Moose; - ::lives_ok { extends 'Foo::Sub' } 'error_class differs by role so incompat is handled'; + ::ok ! ::exception { extends 'Foo::Sub' }, 'error_class differs by role so incompat is handled'; Moose::Util::MetaRole::apply_metaroles( for => __PACKAGE__, diff --git a/t/050_metaclasses/019_create_anon_with_required_attr.t b/t/050_metaclasses/019_create_anon_with_required_attr.t index 70bddd6..61c9c75 100644 --- a/t/050_metaclasses/019_create_anon_with_required_attr.t +++ b/t/050_metaclasses/019_create_anon_with_required_attr.t @@ -7,7 +7,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package HasFoo; @@ -30,29 +30,29 @@ use Test::Exception; package main; my $anon; -lives_ok { +ok ! exception { $anon = My::Metaclass->create_anon_class( foo => 'this' ); -} 'create anon class with required attr'; +}, 'create anon class with required attr'; isa_ok( $anon, 'My::Metaclass' ); cmp_ok( $anon->foo, 'eq', 'this', 'foo is this' ); -dies_ok { +ok exception { $anon = My::Metaclass->create_anon_class(); -} 'failed to create anon class without required attr'; +}, 'failed to create anon class without required attr'; my $meta; -lives_ok { +ok ! exception { $meta = My::Metaclass->initialize( 'Class::Name1' => ( foo => 'that' ) ); -} 'initialize a class with required attr'; +}, 'initialize a class with required attr'; isa_ok( $meta, 'My::Metaclass' ); cmp_ok( $meta->foo, 'eq', 'that', 'foo is that' ); cmp_ok( $meta->name, 'eq', 'Class::Name1', 'for the correct class' ); -dies_ok { +ok exception { $meta = My::Metaclass->initialize( 'Class::Name2' ); -} 'failed to initialize a class without required attr'; +}, 'failed to initialize a class without required attr'; -lives_ok { +ok ! exception { eval qq{ package Class::Name3; use metaclass 'My::Metaclass' => ( @@ -61,28 +61,28 @@ lives_ok { use Moose; }; die $@ if $@; -} 'use metaclass with required attr'; +}, 'use metaclass with required attr'; $meta = Class::Name3->meta; isa_ok( $meta, 'My::Metaclass' ); cmp_ok( $meta->foo, 'eq', 'another', 'foo is another' ); cmp_ok( $meta->name, 'eq', 'Class::Name3', 'for the correct class' ); -dies_ok { +ok exception { eval qq{ package Class::Name4; use metaclass 'My::Metaclass'; use Moose; }; die $@ if $@; -} 'failed to use metaclass without required attr'; +}, 'failed to use metaclass without required attr'; # how do we pass a required attribute to -traits? -dies_ok { +ok exception { eval qq{ package Class::Name5; use Moose -traits => 'HasFoo'; }; die $@ if $@; -} 'failed to use trait without required attr'; +}, 'failed to use trait without required attr'; done_testing; diff --git a/t/050_metaclasses/021_export_with_prototype.t b/t/050_metaclasses/021_export_with_prototype.t index 6c8f5e2..c84f6d0 100644 --- a/t/050_metaclasses/021_export_with_prototype.t +++ b/t/050_metaclasses/021_export_with_prototype.t @@ -3,20 +3,20 @@ package MyExporter::User; use MyExporter; use Test::More; -use Test::Exception; +use Test::Fatal; -lives_and { +ok ! exception { with_prototype { my $caller = caller(0); is($caller, 'MyExporter', "With_caller prototype code gets called from MyMooseX"); }; -} "check function with prototype"; +}, "check function with prototype"; -lives_and { +ok ! exception { as_is_prototype { my $caller = caller(0); is($caller, 'MyExporter', "As-is prototype code gets called from MyMooseX"); }; -} "check function with prototype"; +}, "check function with prototype"; done_testing; diff --git a/t/050_metaclasses/041_moose_nonmoose_moose_chain_init_meta.t b/t/050_metaclasses/041_moose_nonmoose_moose_chain_init_meta.t index ed12d4c..5b24c44 100644 --- a/t/050_metaclasses/041_moose_nonmoose_moose_chain_init_meta.t +++ b/t/050_metaclasses/041_moose_nonmoose_moose_chain_init_meta.t @@ -15,10 +15,10 @@ use warnings; } use Test::More; -use Test::Exception; +use Test::Fatal; -lives_ok { +ok ! exception { Moose->init_meta(for_class => 'SomeClass'); -} 'Moose class => use base => Moose Class, then Moose->init_meta on middle class ok'; +}, 'Moose class => use base => Moose Class, then Moose->init_meta on middle class ok'; done_testing; diff --git a/t/050_metaclasses/050_metarole_backcompat.t b/t/050_metaclasses/050_metarole_backcompat.t index 2ded6e4..02cec56 100644 --- a/t/050_metaclasses/050_metarole_backcompat.t +++ b/t/050_metaclasses/050_metarole_backcompat.t @@ -9,7 +9,7 @@ use warnings; use lib 't/lib', 'lib'; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util::MetaRole; @@ -583,10 +583,10 @@ use Moose::Util::MetaRole; } } -lives_ok { +ok ! exception { package UsesExportedMoose; ExportsMoose->import; -} 'import module which loads a role from disk during init_meta'; +}, 'import module which loads a role from disk during init_meta'; { package Foo::Meta::Role; diff --git a/t/050_metaclasses/051_metarole_on_anon.t b/t/050_metaclasses/051_metarole_on_anon.t index 092a34b..2c36d41 100644 --- a/t/050_metaclasses/051_metarole_on_anon.t +++ b/t/050_metaclasses/051_metarole_on_anon.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose (); use Moose::Meta::Class; diff --git a/t/050_metaclasses/052_metaclass_compat.t b/t/050_metaclasses/052_metaclass_compat.t index f29db50..33ed309 100644 --- a/t/050_metaclasses/052_metaclass_compat.t +++ b/t/050_metaclasses/052_metaclass_compat.t @@ -3,7 +3,7 @@ use strict; use warnings; use lib 't/lib'; use Test::More; -use Test::Exception; +use Test::Fatal; our $called = 0; { @@ -74,16 +74,16 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') package Baz2; use Moose; my $meta = __PACKAGE__->meta; - ::lives_ok { $meta->superclasses('Foo2') } "can set superclasses once"; + ::ok ! ::exception { $meta->superclasses('Foo2') }, "can set superclasses once"; ::isa_ok($meta, Foo2->meta->meta->name); - ::lives_ok { $meta->superclasses('Bar2') } "can still set superclasses"; + ::ok ! ::exception { $meta->superclasses('Bar2') }, "can still set superclasses"; ::isa_ok($meta, Bar2->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo2::Role'], "still have the role attached"); ::ok(!$meta->is_immutable, "immutable superclass doesn't make this class immutable"); - ::lives_ok { $meta->make_immutable } "can still make immutable"; + ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; } { package Foo3::Role; @@ -97,19 +97,19 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') package Baz3; use Moose -traits => ['Foo3::Role']; my $meta = __PACKAGE__->meta; - ::lives_ok { $meta->superclasses('Foo2') } "can set superclasses once"; + ::ok ! ::exception { $meta->superclasses('Foo2') }, "can set superclasses once"; ::isa_ok($meta, Foo2->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo2::Role', 'Foo3::Role'], "reconciled roles correctly"); - ::lives_ok { $meta->superclasses('Bar3') } "can still set superclasses"; + ::ok ! ::exception { $meta->superclasses('Bar3') }, "can still set superclasses"; ::isa_ok($meta, Bar3->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo2::Role', 'Foo3::Role'], "roles still the same"); ::ok(!$meta->is_immutable, "immutable superclass doesn't make this class immutable"); - ::lives_ok { $meta->make_immutable } "can still make immutable"; + ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; } { package Quux3; @@ -119,19 +119,19 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') package Quuux3; use Moose -traits => ['Foo3::Role']; my $meta = __PACKAGE__->meta; - ::lives_ok { $meta->superclasses('Foo2') } "can set superclasses once"; + ::ok ! ::exception { $meta->superclasses('Foo2') }, "can set superclasses once"; ::isa_ok($meta, Foo2->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo2::Role', 'Foo3::Role'], "reconciled roles correctly"); - ::lives_ok { $meta->superclasses('Quux3') } "can still set superclasses"; + ::ok ! ::exception { $meta->superclasses('Quux3') }, "can still set superclasses"; ::isa_ok($meta, Quux3->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo2::Role', 'Foo3::Role'], "roles still the same"); ::ok(!$meta->is_immutable, "immutable superclass doesn't make this class immutable"); - ::lives_ok { $meta->make_immutable } "can still make immutable"; + ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; } { @@ -151,16 +151,16 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') package Baz4; use Moose; my $meta = __PACKAGE__->meta; - ::lives_ok { $meta->superclasses('Foo4') } "can set superclasses once"; + ::ok ! ::exception { $meta->superclasses('Foo4') }, "can set superclasses once"; ::isa_ok($meta, Foo4->meta->_get_mutable_metaclass_name); - ::lives_ok { $meta->superclasses('Bar4') } "can still set superclasses"; + ::ok ! ::exception { $meta->superclasses('Bar4') }, "can still set superclasses"; ::isa_ok($meta, Bar4->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo4::Role'], "still have the role attached"); ::ok(!$meta->is_immutable, "immutable superclass doesn't make this class immutable"); - ::lives_ok { $meta->make_immutable } "can still make immutable"; + ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; } { package Foo5::Role; @@ -174,19 +174,19 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') package Baz5; use Moose -traits => ['Foo5::Role']; my $meta = __PACKAGE__->meta; - ::lives_ok { $meta->superclasses('Foo4') } "can set superclasses once"; + ::ok ! ::exception { $meta->superclasses('Foo4') }, "can set superclasses once"; ::isa_ok($meta, Foo4->meta->_get_mutable_metaclass_name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo4::Role', 'Foo5::Role'], "reconciled roles correctly"); - ::lives_ok { $meta->superclasses('Bar5') } "can still set superclasses"; + ::ok ! ::exception { $meta->superclasses('Bar5') }, "can still set superclasses"; ::isa_ok($meta, Bar5->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo4::Role', 'Foo5::Role'], "roles still the same"); ::ok(!$meta->is_immutable, "immutable superclass doesn't make this class immutable"); - ::lives_ok { $meta->make_immutable } "can still make immutable"; + ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; } { package Quux5; @@ -196,19 +196,19 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') package Quuux5; use Moose -traits => ['Foo5::Role']; my $meta = __PACKAGE__->meta; - ::lives_ok { $meta->superclasses('Foo4') } "can set superclasses once"; + ::ok ! ::exception { $meta->superclasses('Foo4') }, "can set superclasses once"; ::isa_ok($meta, Foo4->meta->_get_mutable_metaclass_name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo4::Role', 'Foo5::Role'], "reconciled roles correctly"); - ::lives_ok { $meta->superclasses('Quux5') } "can still set superclasses"; + ::ok ! ::exception { $meta->superclasses('Quux5') }, "can still set superclasses"; ::isa_ok($meta, Quux5->meta->meta->name); ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], ['Foo4::Role', 'Foo5::Role'], "roles still the same"); ::ok(!$meta->is_immutable, "immutable superclass doesn't make this class immutable"); - ::lives_ok { $meta->make_immutable } "can still make immutable"; + ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; } { @@ -233,12 +233,12 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') push(@superclasses, 'Foo5::SuperClass::After::Attribute'); - ::lives_ok { + ::ok ! ::exception { extends @superclasses; - } 'MI extends after_generated_methods with metaclass roles'; - ::lives_ok { + }, 'MI extends after_generated_methods with metaclass roles'; + ::ok ! ::exception { extends reverse @superclasses; - } + }, 'MI extends after_generated_methods with metaclass roles (reverse)'; } @@ -268,13 +268,13 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') push(@superclasses, 'Foo6::SuperClass::After::Attribute'); - ::throws_ok { + ::like ::exception { extends @superclasses; - } qr/compat.*pristine/, + }, qr/compat.*pristine/, 'unsafe MI extends after_generated_methods with metaclass roles'; - ::throws_ok { + ::like ::exception { extends reverse @superclasses; - } qr/compat.*pristine/, + }, qr/compat.*pristine/, 'unsafe MI extends after_generated_methods with metaclass roles (reverse)'; } @@ -292,14 +292,14 @@ ok(Foo::Sub->meta->constructor_class->meta->can('does_role') package Bar7; # in an external file use Moose -traits => ['Bar7::Meta::Trait']; - ::lives_ok { extends 'Foo7' } "role reconciliation works"; + ::ok ! ::exception { extends 'Foo7' }, "role reconciliation works"; } { package Bar72; # in an external file use Moose -traits => ['Bar7::Meta::Trait2']; - ::lives_ok { extends 'Foo7' } "role reconciliation works"; + ::ok ! ::exception { extends 'Foo7' }, "role reconciliation works"; } done_testing; diff --git a/t/050_metaclasses/054_metaclass_compat_no_fixing_bug.t b/t/050_metaclasses/054_metaclass_compat_no_fixing_bug.t index 6190faa..29aca77 100644 --- a/t/050_metaclasses/054_metaclass_compat_no_fixing_bug.t +++ b/t/050_metaclasses/054_metaclass_compat_no_fixing_bug.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Foo::Meta::Constructor1; @@ -40,7 +40,7 @@ use Test::Exception; for => __PACKAGE__, class_metaroles => { constructor => ['Foo::Meta::Constructor2'] }, ); - ::lives_ok { extends 'Foo::Sub' } "doesn't try to fix if nothing is needed"; + ::ok ! ::exception { extends 'Foo::Sub' }, "doesn't try to fix if nothing is needed"; } done_testing; diff --git a/t/050_metaclasses/060_reinitialize.t b/t/050_metaclasses/060_reinitialize.t index bb35eb0..e4bb9a8 100644 --- a/t/050_metaclasses/060_reinitialize.t +++ b/t/050_metaclasses/060_reinitialize.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; use Test::Moose; -use Test::Exception; +use Test::Fatal; sub check_meta_sanity { my ($meta, $class) = @_; @@ -126,13 +126,13 @@ does_ok(Bar->meta->get_attribute('bar'), 'Foo::Role::Attribute'); BEGIN { extends 'Moose::Meta::Attribute' }; } -throws_ok { +like exception { Moose::Meta::Class->reinitialize( 'Bar', method_metaclass => 'Bar::Meta::Method', attribute_metaclass => 'Bar::Meta::Attribute', ); -} qr/compatible/; +}, qr/compatible/; { package Baz::Meta::Class; @@ -189,13 +189,13 @@ does_ok(Baz->meta->get_attribute('bar'), 'Foo::Role::Attribute'); extends 'Moose::Meta::Attribute'; } -throws_ok { +like exception { Moose::Meta::Class->reinitialize( 'Baz', method_metaclass => 'Baz::Meta::Method', attribute_metaclass => 'Baz::Meta::Attribute', ); -} qr/compatible/; +}, qr/compatible/; { package Quux; diff --git a/t/050_metaclasses/061_moose_exporter_trait_aliases.t b/t/050_metaclasses/061_moose_exporter_trait_aliases.t index e64c882..909f684 100644 --- a/t/050_metaclasses/061_moose_exporter_trait_aliases.t +++ b/t/050_metaclasses/061_moose_exporter_trait_aliases.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; use Test::Moose; -use Test::Exception; +use Test::Fatal; { package Attribute::Trait::Awesome; diff --git a/t/060_compat/001_module_refresh_compat.t b/t/060_compat/001_module_refresh_compat.t index 03553f9..7d23dea 100644 --- a/t/060_compat/001_module_refresh_compat.t +++ b/t/060_compat/001_module_refresh_compat.t @@ -6,7 +6,7 @@ use warnings; use lib 't/lib', 'lib'; use Test::More; -use Test::Exception; +use Test::Fatal; use File::Spec; use File::Temp 'tempdir'; @@ -28,9 +28,9 @@ do { is($_->meta->name, $_, '... initialized the meta correctly'); - lives_ok { + ok ! exception { Module::Refresh->new->refresh_module($_ . '.pm') - } '... successfully refreshed ' . $_; + }, '... successfully refreshed ' . $_; } foreach @modules; =pod @@ -79,9 +79,9 @@ ok(!TestBaz->isa('Foo'), '... TestBaz is not a Foo'); close FILE; } -lives_ok { +ok ! exception { Module::Refresh->new->refresh_module('TestBaz.pm') -} '... successfully refreshed ' . $test_module_file; +}, '... successfully refreshed ' . $test_module_file; is(TestBaz->meta->name, 'TestBaz', '... initialized the meta correctly'); ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well'); diff --git a/t/060_compat/002_moose_respects_base.t b/t/060_compat/002_moose_respects_base.t index 71789b3..5933dd0 100644 --- a/t/060_compat/002_moose_respects_base.t +++ b/t/060_compat/002_moose_respects_base.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod diff --git a/t/060_compat/003_foreign_inheritence.t b/t/060_compat/003_foreign_inheritence.t index 0fdcb9b..51e739d 100644 --- a/t/060_compat/003_foreign_inheritence.t +++ b/t/060_compat/003_foreign_inheritence.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -79,14 +79,14 @@ is( $foo_moose->no_moose, 'Elk', is( $foo_moose->moose, 'Foo', '... got the right value from the Foo::Moose method' ); -lives_ok { +ok ! exception { Old::Bucket::Nose->meta->make_immutable( debug => 0 ); -} +}, 'Immutability on Moose class extending Class::MOP class ok'; -lives_ok { +ok ! exception { SubClass2->meta->superclasses('MyBase'); -} +}, 'Can subclass the same non-Moose class twice with different metaclasses'; done_testing; diff --git a/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t b/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t index 78fe330..6fbd85b 100644 --- a/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t +++ b/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t @@ -22,10 +22,10 @@ use Class::MOP (); package SubSubClassUseBase; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends 'SubClassUseBase'; - } + }, 'Can extend non-Moose class with parent class that is a Moose class with a meta role'; } @@ -54,10 +54,10 @@ Class::MOP::remove_metaclass_by_name('SubClassUseBase'); package MultiParent1; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends qw( SubClassUseBase OtherSubClassUseBase ); - } + }, 'Can extend two non-Moose classes with parents that are different Moose metaclasses'; } @@ -74,10 +74,10 @@ Class::MOP::remove_metaclass_by_name($_) package MultiParent2; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends qw( OtherSubClassUseBase SubClassUseBase ); - } + }, 'Can extend two non-Moose classes with parents that are different Moose metaclasses (reverse order)'; } @@ -94,10 +94,10 @@ Class::MOP::remove_metaclass_by_name($_) package MultiParent3; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends qw( OtherClass SubClassUseBase ); - } + }, 'Can extend one Moose class and one non-Moose class'; } @@ -114,10 +114,10 @@ Class::MOP::remove_metaclass_by_name($_) package MultiParent4; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends qw( SubClassUseBase OtherClass ); - } + }, 'Can extend one non-Moose class and one Moose class'; } @@ -134,10 +134,10 @@ Class::MOP::remove_metaclass_by_name($_) package MultiChild1; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends 'MultiParent1'; - } + }, 'Can extend class that itself extends two non-Moose classes with Moose parents'; } @@ -154,10 +154,10 @@ Class::MOP::remove_metaclass_by_name($_) package MultiChild2; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends 'MultiParent2'; - } + }, 'Can extend class that itself extends two non-Moose classes with Moose parents (reverse order)'; } @@ -174,10 +174,10 @@ Class::MOP::remove_metaclass_by_name($_) package MultiChild3; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends 'MultiParent3'; - } + }, 'Can extend class that itself extends one Moose and one non-Moose parent'; } @@ -194,10 +194,10 @@ Class::MOP::remove_metaclass_by_name($_) package MultiChild4; use Moose; use Test::More; - use Test::Exception; - lives_ok { + use Test::Fatal; + ok ! exception { extends 'MultiParent4'; - } + }, 'Can extend class that itself extends one non-Moose and one Moose parent'; } diff --git a/t/060_compat/005_composite_metaroles.t b/t/060_compat/005_composite_metaroles.t index 570ce30..8a3392f 100755 --- a/t/060_compat/005_composite_metaroles.t +++ b/t/060_compat/005_composite_metaroles.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; { @@ -31,7 +31,7 @@ use Test::Moose; for => __PACKAGE__, class_metaroles => { class => ['Foo::Role', 'Bar::Role'] }, ); - ::lives_ok { extends 'Parent' }; + ::ok ! ::exception { extends 'Parent' }; } with_immutable { diff --git a/t/070_native_traits/010_trait_array.t b/t/070_native_traits/010_trait_array.t index 3f87d46..8b7c65d 100644 --- a/t/070_native_traits/010_trait_array.t +++ b/t/070_native_traits/010_trait_array.t @@ -9,7 +9,7 @@ use Moose (); use Moose::Util::TypeConstraints; use NoInlineAttribute; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; { @@ -137,19 +137,19 @@ sub run_tests { ok( !$obj->is_empty, 'values is not empty' ); is( $obj->count, 3, 'count returns 3' ); - throws_ok { $obj->count(22) } + like exception { $obj->count(22) }, qr/Cannot call count with any arguments/, 'throws an error when passing an argument passed to count'; - lives_ok { $obj->push( 1, 2, 3 ) } + ok ! exception { $obj->push( 1, 2, 3 ) }, 'pushed three new values and lived'; - lives_ok { $obj->push() } 'call to push without arguments lives'; + ok ! exception { $obj->push() }, 'call to push without arguments lives'; - lives_and { + ok ! exception { is( $obj->unshift( 101, 22 ), 8, 'unshift returns size of the new array' ); - } + }, 'unshifted two values and lived'; is_deeply( @@ -157,7 +157,7 @@ sub run_tests { 'unshift changed the value of the array in the object' ); - lives_ok { $obj->unshift() } + ok ! exception { $obj->unshift() }, 'call to unshift without arguments lives'; is( $obj->pop, 3, 'pop returns the last value in the array' ); @@ -167,13 +167,13 @@ sub run_tests { 'pop changed the value of the array in the object' ); - throws_ok { $obj->pop(42) } + like exception { $obj->pop(42) }, qr/Cannot call pop with any arguments/, 'call to pop with arguments dies'; is( $obj->shift, 101, 'shift returns the first value' ); - throws_ok { $obj->shift(42) } + like exception { $obj->shift(42) }, qr/Cannot call shift with any arguments/, 'call to shift with arguments dies'; @@ -187,7 +187,7 @@ sub run_tests { 'call to elements returns values as a list' ); - throws_ok { $obj->elements(22) } + like exception { $obj->elements(22) }, qr/Cannot call elements with any arguments/, 'throws an error when passing an argument passed to elements'; @@ -198,51 +198,51 @@ sub run_tests { is( $obj->get(2), 3, 'get values at index 2' ); is( $obj->get_curried, 2, 'get_curried returns value at index 1' ); - throws_ok { $obj->get() } + like exception { $obj->get() }, qr/Cannot call get without at least 1 argument/, 'throws an error when get is called without any arguments'; - throws_ok { $obj->get( {} ) } + like exception { $obj->get( {} ) }, qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument'; - throws_ok { $obj->get(2.2) } + like exception { $obj->get(2.2) }, qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument'; - throws_ok { $obj->get('foo') } + like exception { $obj->get('foo') }, qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument'; - throws_ok { $obj->get_curried(2) } + like exception { $obj->get_curried(2) }, qr/Cannot call get with more than 1 argument/, 'throws an error when get_curried is called with an argument'; - lives_and { + ok ! exception { is( $obj->set( 1, 100 ), 100, 'set returns new value' ); - } + }, 'set value at index 1 lives'; is( $obj->get(1), 100, 'get value at index 1 returns new value' ); - throws_ok { $obj->set( 1, 99, 42 ) } + like exception { $obj->set( 1, 99, 42 ) }, qr/Cannot call set with more than 2 arguments/, 'throws an error when set is called with three arguments'; - lives_ok { $obj->set_curried_1(99) } 'set_curried_1 lives'; + ok ! exception { $obj->set_curried_1(99) }, 'set_curried_1 lives'; is( $obj->get(1), 99, 'get value at index 1 returns new value' ); - throws_ok { $obj->set_curried_1( 99, 42 ) } + like exception { $obj->set_curried_1( 99, 42 ) }, qr/Cannot call set with more than 2 arguments/, 'throws an error when set_curried_1 is called with two arguments'; - lives_ok { $obj->set_curried_2 } 'set_curried_2 lives'; + ok ! exception { $obj->set_curried_2 }, 'set_curried_2 lives'; is( $obj->get(1), 98, 'get value at index 1 returns new value' ); - throws_ok { $obj->set_curried_2(42) } + like exception { $obj->set_curried_2(42) }, qr/Cannot call set with more than 2 arguments/, 'throws an error when set_curried_2 is called with one argument'; @@ -251,9 +251,9 @@ sub run_tests { 'accessor with one argument returns value at index 1' ); - lives_and { + ok ! exception { is( $obj->accessor( 1 => 97 ), 97, 'accessor returns new value' ); - } + }, 'accessor as writer lives'; is( @@ -261,7 +261,7 @@ sub run_tests { 'accessor set value at index 1' ); - throws_ok { $obj->accessor( 1, 96, 42 ) } + like exception { $obj->accessor( 1, 96, 42 ) }, qr/Cannot call accessor with more than 2 arguments/, 'throws an error when accessor is called with three arguments'; @@ -270,7 +270,7 @@ sub run_tests { 'accessor_curried_1 returns expected value when called with no arguments' ); - lives_ok { $obj->accessor_curried_1(95) } + ok ! exception { $obj->accessor_curried_1(95) }, 'accessor_curried_1 as writer lives'; is( @@ -278,11 +278,11 @@ sub run_tests { 'accessor_curried_1 set value at index 1' ); - throws_ok { $obj->accessor_curried_1( 96, 42 ) } + like exception { $obj->accessor_curried_1( 96, 42 ) }, qr/Cannot call accessor with more than 2 arguments/, 'throws an error when accessor_curried_1 is called with two arguments'; - lives_ok { $obj->accessor_curried_2 } + ok ! exception { $obj->accessor_curried_2 }, 'accessor_curried_2 as writer lives'; is( @@ -290,17 +290,17 @@ sub run_tests { 'accessor_curried_2 set value at index 1' ); - throws_ok { $obj->accessor_curried_2(42) } + like exception { $obj->accessor_curried_2(42) }, qr/Cannot call accessor with more than 2 arguments/, 'throws an error when accessor_curried_2 is called with one argument'; - lives_ok { $obj->clear } 'clear lives'; + ok ! exception { $obj->clear }, 'clear lives'; ok( $obj->is_empty, 'values is empty after call to clear' ); $obj->set( 0 => 42 ); - throws_ok { $obj->clear(50) } + like exception { $obj->clear(50) }, qr/Cannot call clear with any arguments/, 'throws an error when clear is called with an argument'; @@ -309,7 +309,7 @@ sub run_tests { 'values is not empty after failed call to clear' ); - throws_ok { $obj->is_empty(50) } + like exception { $obj->is_empty(50) }, qr/Cannot call is_empty with any arguments/, 'throws an error when is_empty is called with an argument'; @@ -319,9 +319,9 @@ sub run_tests { 'pushed 4 elements, got number of elements in the array back' ); - lives_and { + ok ! exception { is( $obj->delete(2), 10, 'delete returns deleted value' ); - } + }, 'delete lives'; is_deeply( @@ -329,39 +329,39 @@ sub run_tests { 'delete removed the specified element' ); - throws_ok { $obj->delete( 2, 3 ) } + like exception { $obj->delete( 2, 3 ) }, qr/Cannot call delete with more than 1 argument/, 'throws an error when delete is called with two arguments'; - lives_ok { $obj->delete_curried } 'delete_curried lives'; + ok ! exception { $obj->delete_curried }, 'delete_curried lives'; is_deeply( $obj->_values, [ 1, 42 ], 'delete removed the specified element' ); - throws_ok { $obj->delete_curried(2) } + like exception { $obj->delete_curried(2) }, qr/Cannot call delete with more than 1 argument/, 'throws an error when delete_curried is called with one argument'; - lives_ok { $obj->insert( 1, 21 ) } 'insert lives'; + ok ! exception { $obj->insert( 1, 21 ) }, 'insert lives'; is_deeply( $obj->_values, [ 1, 21, 42 ], 'insert added the specified element' ); - throws_ok { $obj->insert( 1, 22, 44 ) } + like exception { $obj->insert( 1, 22, 44 ) }, qr/Cannot call insert with more than 2 arguments/, 'throws an error when insert is called with three arguments'; - lives_and { + ok ! exception { is_deeply( [ $obj->splice( 1, 0, 2, 3 ) ], [], 'return value of splice is empty list when not removing elements' ); - } + }, 'splice lives'; is_deeply( @@ -369,13 +369,13 @@ sub run_tests { 'splice added the specified elements' ); - lives_and { + ok ! exception { is_deeply( [ $obj->splice( 1, 2, 99 ) ], [ 2, 3 ], 'splice returns list of removed values' ); - } + }, 'splice lives'; is_deeply( @@ -383,15 +383,15 @@ sub run_tests { 'splice added the specified elements' ); - throws_ok { $obj->splice() } + like exception { $obj->splice() }, qr/Cannot call splice without at least 1 argument/, 'throws an error when splice is called with no arguments'; - throws_ok { $obj->splice( 1, 'foo', ) } + like exception { $obj->splice( 1, 'foo', ) }, qr/The length argument passed to splice must be an integer/, 'throws an error when splice is called with an invalid length'; - lives_ok { $obj->splice_curried_1( 2, 101 ) } + ok ! exception { $obj->splice_curried_1( 2, 101 ) }, 'splice_curried_1 lives'; is_deeply( @@ -399,14 +399,14 @@ sub run_tests { 'splice added the specified elements' ); - lives_ok { $obj->splice_curried_2(102) } 'splice_curried_2 lives'; + ok ! exception { $obj->splice_curried_2(102) }, 'splice_curried_2 lives'; is_deeply( $obj->_values, [ 1, 102 ], 'splice added the specified elements' ); - lives_ok { $obj->splice_curried_all } 'splice_curried_all lives'; + ok ! exception { $obj->splice_curried_all }, 'splice_curried_all lives'; is_deeply( $obj->_values, [ 1, 3, 4, 5 ], @@ -437,13 +437,13 @@ sub run_tests { 'sort returns values sorted by provided function' ); - throws_ok { $obj->sort(1) } + like exception { $obj->sort(1) }, qr/The argument passed to sort must be a code reference/, 'throws an error when passing a non coderef to sort'; - throws_ok { + like exception { $obj->sort( sub { }, 27 ); - } + }, qr/Cannot call sort with more than 1 argument/, 'throws an error when passing two arguments to sort'; @@ -463,15 +463,15 @@ sub run_tests { 'sort_in_place with function sorts values' ); - throws_ok { + like exception { $obj->sort_in_place( 27 ); - } + }, qr/The argument passed to sort_in_place must be a code reference/, 'throws an error when passing a non coderef to sort_in_place'; - throws_ok { + like exception { $obj->sort_in_place( sub { }, 27 ); - } + }, qr/Cannot call sort_in_place with more than 1 argument/, 'throws an error when passing two arguments to sort_in_place'; @@ -484,7 +484,7 @@ sub run_tests { 'sort_in_place_curried sorts values' ); - throws_ok { $obj->sort_in_place_curried(27) } + like exception { $obj->sort_in_place_curried(27) }, qr/Cannot call sort_in_place with more than 1 argument/, 'throws an error when passing one argument passed to sort_in_place_curried'; @@ -496,17 +496,17 @@ sub run_tests { 'map returns the expected values' ); - throws_ok { $obj->map } + like exception { $obj->map }, qr/Cannot call map without at least 1 argument/, 'throws an error when passing no arguments to map'; - throws_ok { + like exception { $obj->map( sub { }, 2 ); - } + }, qr/Cannot call map with more than 1 argument/, 'throws an error when passing two arguments to map'; - throws_ok { $obj->map( {} ) } + like exception { $obj->map( {} ) }, qr/The argument passed to map must be a code reference/, 'throws an error when passing a non coderef to map'; @@ -518,9 +518,9 @@ sub run_tests { 'map_curried returns the expected values' ); - throws_ok { + like exception { $obj->map_curried( sub { } ); - } + }, qr/Cannot call map with more than 1 argument/, 'throws an error when passing one argument passed to map_curried'; @@ -532,17 +532,17 @@ sub run_tests { 'grep returns the expected values' ); - throws_ok { $obj->grep } + like exception { $obj->grep }, qr/Cannot call grep without at least 1 argument/, 'throws an error when passing no arguments to grep'; - throws_ok { + like exception { $obj->grep( sub { }, 2 ); - } + }, qr/Cannot call grep with more than 1 argument/, 'throws an error when passing two arguments to grep'; - throws_ok { $obj->grep( {} ) } + like exception { $obj->grep( {} ) }, qr/The argument passed to grep must be a code reference/, 'throws an error when passing a non coderef to grep'; @@ -559,9 +559,9 @@ sub run_tests { 'grep_curried returns the expected values' ); - throws_ok { + like exception { $obj->grep_curried( sub { } ); - } + }, qr/Cannot call grep with more than 1 argument/, 'throws an error when passing one argument passed to grep_curried'; @@ -573,17 +573,17 @@ sub run_tests { 'first returns expected value' ); - throws_ok { $obj->first } + like exception { $obj->first }, qr/Cannot call first without at least 1 argument/, 'throws an error when passing no arguments to first'; - throws_ok { + like exception { $obj->first( sub { }, 2 ); - } + }, qr/Cannot call first with more than 1 argument/, 'throws an error when passing two arguments to first'; - throws_ok { $obj->first( {} ) } + like exception { $obj->first( {} ) }, qr/The argument passed to first must be a code reference/, 'throws an error when passing a non coderef to first'; @@ -593,9 +593,9 @@ sub run_tests { 'first_curried returns expected value' ); - throws_ok { + like exception { $obj->first_curried( sub { } ); - } + }, qr/Cannot call first with more than 1 argument/, 'throws an error when passing one argument passed to first_curried'; @@ -611,15 +611,15 @@ sub run_tests { 'join returns expected result when joining with empty string' ); - throws_ok { $obj->join } + like exception { $obj->join }, qr/Cannot call join without at least 1 argument/, 'throws an error when passing no arguments to join'; - throws_ok { $obj->join( '-', 2 ) } + like exception { $obj->join( '-', 2 ) }, qr/Cannot call join with more than 1 argument/, 'throws an error when passing two arguments to join'; - throws_ok { $obj->join( {} ) } + like exception { $obj->join( {} ) }, qr/The argument passed to join must be a string/, 'throws an error when passing a non string to join'; @@ -629,7 +629,7 @@ sub run_tests { 'shuffle returns all values (cannot check for a random order)' ); - throws_ok { $obj->shuffle(2) } + like exception { $obj->shuffle(2) }, qr/Cannot call shuffle with any arguments/, 'throws an error when passing an argument passed to shuffle'; @@ -641,7 +641,7 @@ sub run_tests { 'uniq returns expected values (in original order)' ); - throws_ok { $obj->uniq(2) } + like exception { $obj->uniq(2) }, qr/Cannot call uniq with any arguments/, 'throws an error when passing an argument passed to uniq'; @@ -653,17 +653,17 @@ sub run_tests { 'reduce returns expected value' ); - throws_ok { $obj->reduce } + like exception { $obj->reduce }, qr/Cannot call reduce without at least 1 argument/, 'throws an error when passing no arguments to reduce'; - throws_ok { + like exception { $obj->reduce( sub { }, 2 ); - } + }, qr/Cannot call reduce with more than 1 argument/, 'throws an error when passing two arguments to reduce'; - throws_ok { $obj->reduce( {} ) } + like exception { $obj->reduce( {} ) }, qr/The argument passed to reduce must be a code reference/, 'throws an error when passing a non coderef to reduce'; @@ -673,9 +673,9 @@ sub run_tests { 'reduce_curried returns expected value' ); - throws_ok { + like exception { $obj->reduce_curried( sub { } ); - } + }, qr/Cannot call reduce with more than 1 argument/, 'throws an error when passing one argument passed to reduce_curried'; @@ -702,11 +702,11 @@ sub run_tests { 'natatime with function returns expected value' ); - throws_ok { $obj->natatime( {} ) } + like exception { $obj->natatime( {} ) }, qr/The n value passed to natatime must be an integer/, 'throws an error when passing a non integer to natatime'; - throws_ok { $obj->natatime( 2, {} ) } + like exception { $obj->natatime( 2, {} ) }, qr/The second argument passed to natatime must be a code reference/, 'throws an error when passing a non code ref to natatime'; @@ -731,7 +731,7 @@ sub run_tests { 'natatime_curried with function returns expected value' ); - throws_ok { $obj->natatime_curried( {} ) } + like exception { $obj->natatime_curried( {} ) }, qr/The second argument passed to natatime must be a code reference/, 'throws an error when passing a non code ref to natatime_curried'; diff --git a/t/070_native_traits/011_array_subtypes.t b/t/070_native_traits/011_array_subtypes.t index 5daa36a..65ba399 100644 --- a/t/070_native_traits/011_array_subtypes.t +++ b/t/070_native_traits/011_array_subtypes.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { use Moose::Util::TypeConstraints; @@ -75,7 +75,7 @@ my $foo = Foo->new; $foo->array_int( [] ); is_deeply( $foo->array_int, [], "array_int - correct contents" ); - dies_ok { $foo->push_array_int('foo') } + ok exception { $foo->push_array_int('foo') }, "array_int - can't push wrong type"; is_deeply( $foo->array_int, [], "array_int - correct contents" ); @@ -84,12 +84,12 @@ my $foo = Foo->new; } { - dies_ok { $foo->push_a1('foo') } "a1 - can't push onto undef"; + ok exception { $foo->push_a1('foo') }, "a1 - can't push onto undef"; $foo->a1( [] ); is_deeply( $foo->a1, [], "a1 - correct contents" ); - dies_ok { $foo->push_a1('foo') } "a1 - can't push wrong type"; + ok exception { $foo->push_a1('foo') }, "a1 - can't push wrong type"; is_deeply( $foo->a1, [], "a1 - correct contents" ); @@ -98,7 +98,7 @@ my $foo = Foo->new; } { - dies_ok { $foo->push_a2('foo') } "a2 - can't push onto undef"; + ok exception { $foo->push_a2('foo') }, "a2 - can't push onto undef"; $foo->a2( [] ); is_deeply( $foo->a2, [], "a2 - correct contents" ); @@ -106,20 +106,20 @@ my $foo = Foo->new; $foo->push_a2('foo'); is_deeply( $foo->a2, ['foo'], "a2 - correct contents" ); - dies_ok { $foo->push_a2('bar') } "a2 - can't push more than one element"; + ok exception { $foo->push_a2('bar') }, "a2 - can't push more than one element"; is_deeply( $foo->a2, ['foo'], "a2 - correct contents" ); } { - dies_ok { $foo->push_a3(1) } "a3 - can't push onto undef"; + ok exception { $foo->push_a3(1) }, "a3 - can't push onto undef"; $foo->a3( [] ); is_deeply( $foo->a3, [], "a3 - correct contents" ); - dies_ok { $foo->push_a3('foo') } "a3 - can't push non-int"; + ok exception { $foo->push_a3('foo') }, "a3 - can't push non-int"; - dies_ok { $foo->push_a3(100) } + ok exception { $foo->push_a3(100) }, "a3 - can't violate overall type constraint"; is_deeply( $foo->a3, [], "a3 - correct contents" ); @@ -127,7 +127,7 @@ my $foo = Foo->new; $foo->push_a3(1); is_deeply( $foo->a3, [1], "a3 - correct contents" ); - dies_ok { $foo->push_a3(100) } + ok exception { $foo->push_a3(100) }, "a3 - can't violate overall type constraint"; is_deeply( $foo->a3, [1], "a3 - correct contents" ); diff --git a/t/070_native_traits/012_array_trigger.t b/t/070_native_traits/012_array_trigger.t index a659025..151b900 100644 --- a/t/070_native_traits/012_array_trigger.t +++ b/t/070_native_traits/012_array_trigger.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Foo; diff --git a/t/070_native_traits/013_array_coerce.t b/t/070_native_traits/013_array_coerce.t index 26d1920..7b1d7d2 100644 --- a/t/070_native_traits/013_array_coerce.t +++ b/t/070_native_traits/013_array_coerce.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -150,7 +150,7 @@ TODO: { is( $bar->get_array(3)->thing, 'd', 'push coerces the array' ); - dies_ok { $bar->push_array('e') } + ok exception { $bar->push_array('e') }, 'the type constraint prohibits arrays of length 5'; } diff --git a/t/070_native_traits/020_trait_bool.t b/t/070_native_traits/020_trait_bool.t index 5443020..e49a25a 100644 --- a/t/070_native_traits/020_trait_bool.t +++ b/t/070_native_traits/020_trait_bool.t @@ -9,7 +9,7 @@ use Moose (); use Moose::Util::TypeConstraints; use NoInlineAttribute; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; { @@ -78,7 +78,7 @@ sub run_tests { ok( $obj->is_lit, 'set is_lit to 1 using ->illuminate' ); ok( !$obj->is_dark, 'check if is_dark does the right thing' ); - throws_ok { $obj->illuminate(1) } + like exception { $obj->illuminate(1) }, qr/Cannot call set with any arguments/, 'set throws an error when an argument is passed'; @@ -86,7 +86,7 @@ sub run_tests { ok( !$obj->is_lit, 'set is_lit to 0 using ->darken' ); ok( $obj->is_dark, 'check if is_dark does the right thing' ); - throws_ok { $obj->darken(1) } + like exception { $obj->darken(1) }, qr/Cannot call unset with any arguments/, 'unset throws an error when an argument is passed'; @@ -94,7 +94,7 @@ sub run_tests { ok( $obj->is_lit, 'toggle is_lit back to 1 using ->flip_switch' ); ok( !$obj->is_dark, 'check if is_dark does the right thing' ); - throws_ok { $obj->flip_switch(1) } + like exception { $obj->flip_switch(1) }, qr/Cannot call toggle with any arguments/, 'toggle throws an error when an argument is passed'; diff --git a/t/070_native_traits/030_trait_code.t b/t/070_native_traits/030_trait_code.t index 3f58b57..fa263f3 100644 --- a/t/070_native_traits/030_trait_code.t +++ b/t/070_native_traits/030_trait_code.t @@ -6,7 +6,7 @@ use lib 't/lib'; use Moose (); use NoInlineAttribute; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; { diff --git a/t/070_native_traits/040_trait_counter.t b/t/070_native_traits/040_trait_counter.t index ae7e816..ac98bc8 100644 --- a/t/070_native_traits/040_trait_counter.t +++ b/t/070_native_traits/040_trait_counter.t @@ -8,7 +8,7 @@ use lib 't/lib'; use Moose (); use Moose::Util::TypeConstraints; use NoInlineAttribute; -use Test::Exception; +use Test::Fatal; use Test::More; use Test::Moose; @@ -85,28 +85,28 @@ sub run_tests { is( $obj->inc_counter, 2, 'inc returns new value' ); is( $obj->counter, 2, '... got the incremented value (again)' ); - throws_ok { $obj->inc_counter( 1, 2 ) } + like exception { $obj->inc_counter( 1, 2 ) }, qr/Cannot call inc with more than 1 argument/, 'inc throws an error when two arguments are passed'; is( $obj->dec_counter, 1, 'dec returns new value' ); is( $obj->counter, 1, '... got the decremented value' ); - throws_ok { $obj->dec_counter( 1, 2 ) } + like exception { $obj->dec_counter( 1, 2 ) }, qr/Cannot call dec with more than 1 argument/, 'dec throws an error when two arguments are passed'; is( $obj->reset_counter, 0, 'reset returns new value' ); is( $obj->counter, 0, '... got the original value' ); - throws_ok { $obj->reset_counter(2) } + like exception { $obj->reset_counter(2) }, qr/Cannot call reset with any arguments/, 'reset throws an error when an argument is passed'; is( $obj->set_counter(5), 5, 'set returns new value' ); is( $obj->counter, 5, '... set the value' ); - throws_ok { $obj->set_counter( 1, 2 ) } + like exception { $obj->set_counter( 1, 2 ) }, qr/Cannot call set with more than 1 argument/, 'set throws an error when two arguments are passed'; diff --git a/t/070_native_traits/050_trait_hash.t b/t/070_native_traits/050_trait_hash.t index e9ea77c..8df19a0 100644 --- a/t/070_native_traits/050_trait_hash.t +++ b/t/070_native_traits/050_trait_hash.t @@ -8,7 +8,7 @@ use lib 't/lib'; use Moose (); use Moose::Util::TypeConstraints; use NoInlineAttribute; -use Test::Exception; +use Test::Fatal; use Test::More; use Test::Moose; @@ -88,13 +88,13 @@ sub run_tests { is_deeply( $obj->options, {}, '... no options yet' ); ok( !$obj->has_option('foo'), '... we have no foo option' ); - lives_and { + ok ! exception { is( $obj->set_option( foo => 'bar' ), 'bar', 'set return single new value in scalar context' ); - } + }, '... set the option okay'; ok( $obj->is_defined('foo'), '... foo is defined' ); @@ -104,9 +104,9 @@ sub run_tests { ok( $obj->has_option('foo'), '... we have a foo option' ); is_deeply( $obj->options, { foo => 'bar' }, '... got options now' ); - lives_ok { + ok ! exception { $obj->set_option( bar => 'baz' ); - } + }, '... set the option okay'; is( $obj->num_options, 2, '... we have 2 option(s)' ); @@ -127,9 +127,9 @@ sub run_tests { '... got last option in scalar context' ); - lives_ok { + ok ! exception { $obj->set_option( oink => "blah", xxy => "flop" ); - } + }, '... set the option okay'; is( $obj->num_options, 4, "4 options" ); @@ -138,19 +138,19 @@ sub run_tests { [qw(bar baz blah flop)], "get multiple options at once" ); - lives_and { + ok ! exception { is( scalar $obj->delete_option('bar'), 'baz', 'delete returns deleted value' ); - } + }, '... deleted the option okay'; - lives_ok { + ok ! exception { is_deeply( [ $obj->delete_option( 'oink', 'xxy' ) ], [ 'blah', 'flop' ], 'delete returns all deleted values in list context' ); - } + }, '... deleted multiple option okay'; is( $obj->num_options, 1, '... we have 1 option(s)' ); @@ -163,9 +163,9 @@ sub run_tests { is_deeply( $obj->options, {}, "... cleared options" ); - lives_ok { + ok ! exception { $obj->quantity(4); - } + }, '... options added okay with defaults'; is( $obj->quantity, 4, 'reader part of curried accessor works' ); @@ -175,19 +175,19 @@ sub run_tests { '... returns what we expect' ); - lives_ok { + ok ! exception { $class->new( options => { foo => 'BAR' } ); - } + }, '... good constructor params'; - dies_ok { + ok exception { $obj->set_option( bar => {} ); - } + }, '... could not add a hash ref where an string is expected'; - dies_ok { + ok exception { $class->new( options => { foo => [] } ); - } + }, '... bad constructor params'; is_deeply( diff --git a/t/070_native_traits/051_hash_subtypes.t b/t/070_native_traits/051_hash_subtypes.t index 8949a92..5d7e420 100644 --- a/t/070_native_traits/051_hash_subtypes.t +++ b/t/070_native_traits/051_hash_subtypes.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { use Moose::Util::TypeConstraints; @@ -66,7 +66,7 @@ my $foo = Foo->new; $foo->hash_int( {} ); is_deeply( $foo->hash_int, {}, "hash_int - correct contents" ); - dies_ok { $foo->set_hash_int( x => 'foo' ) } + ok exception { $foo->set_hash_int( x => 'foo' ) }, "hash_int - can't set wrong type"; is_deeply( $foo->hash_int, {}, "hash_int - correct contents" ); @@ -75,12 +75,12 @@ my $foo = Foo->new; } { - dies_ok { $foo->set_h1('foo') } "h1 - can't set onto undef"; + ok exception { $foo->set_h1('foo') }, "h1 - can't set onto undef"; $foo->h1( {} ); is_deeply( $foo->h1, {}, "h1 - correct contents" ); - dies_ok { $foo->set_h1( x => 'foo' ) } "h1 - can't set wrong type"; + ok exception { $foo->set_h1( x => 'foo' ) }, "h1 - can't set wrong type"; is_deeply( $foo->h1, {}, "h1 - correct contents" ); @@ -89,7 +89,7 @@ my $foo = Foo->new; } { - dies_ok { $foo->set_h2('foo') } "h2 - can't set onto undef"; + ok exception { $foo->set_h2('foo') }, "h2 - can't set onto undef"; $foo->h2( {} ); is_deeply( $foo->h2, {}, "h2 - correct contents" ); @@ -97,21 +97,21 @@ my $foo = Foo->new; $foo->set_h2( x => 'foo' ); is_deeply( $foo->h2, { x => 'foo' }, "h2 - correct contents" ); - dies_ok { $foo->set_h2( y => 'bar' ) } + ok exception { $foo->set_h2( y => 'bar' ) }, "h2 - can't set more than one element"; is_deeply( $foo->h2, { x => 'foo' }, "h2 - correct contents" ); } { - dies_ok { $foo->set_h3(1) } "h3 - can't set onto undef"; + ok exception { $foo->set_h3(1) }, "h3 - can't set onto undef"; $foo->h3( {} ); is_deeply( $foo->h3, {}, "h3 - correct contents" ); - dies_ok { $foo->set_h3( x => 'foo' ) } "h3 - can't set non-int"; + ok exception { $foo->set_h3( x => 'foo' ) }, "h3 - can't set non-int"; - dies_ok { $foo->set_h3( x => 100 ) } + ok exception { $foo->set_h3( x => 100 ) }, "h3 - can't violate overall type constraint"; is_deeply( $foo->h3, {}, "h3 - correct contents" ); @@ -119,7 +119,7 @@ my $foo = Foo->new; $foo->set_h3( x => 1 ); is_deeply( $foo->h3, { x => 1 }, "h3 - correct contents" ); - dies_ok { $foo->set_h3( x => 100 ) } + ok exception { $foo->set_h3( x => 100 ) }, "h3 - can't violate overall type constraint"; is_deeply( $foo->h3, { x => 1 }, "h3 - correct contents" ); diff --git a/t/070_native_traits/052_hash_trigger.t b/t/070_native_traits/052_hash_trigger.t index 26f343c..1136f24 100644 --- a/t/070_native_traits/052_hash_trigger.t +++ b/t/070_native_traits/052_hash_trigger.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { diff --git a/t/070_native_traits/053_hash_coerce.t b/t/070_native_traits/053_hash_coerce.t index f05b144..241c109 100644 --- a/t/070_native_traits/053_hash_coerce.t +++ b/t/070_native_traits/053_hash_coerce.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { diff --git a/t/070_native_traits/060_trait_number.t b/t/070_native_traits/060_trait_number.t index 6b24631..64d0b17 100644 --- a/t/070_native_traits/060_trait_number.t +++ b/t/070_native_traits/060_trait_number.t @@ -8,7 +8,7 @@ use lib 't/lib'; use Moose (); use Moose::Util::TypeConstraints; use NoInlineAttribute; -use Test::Exception; +use Test::Fatal; use Test::More; use Test::Moose; @@ -87,7 +87,7 @@ sub run_tests { is( $obj->integer, 15, 'Add ten for fithteen' ); - throws_ok { $obj->add( 10, 2 ) } + like exception { $obj->add( 10, 2 ) }, qr/Cannot call add with more than 1 argument/, 'add throws an error when 2 arguments are passed'; @@ -95,7 +95,7 @@ sub run_tests { is( $obj->integer, 12, 'Subtract three for 12' ); - throws_ok { $obj->sub( 10, 2 ) } + like exception { $obj->sub( 10, 2 ) }, qr/Cannot call sub with more than 1 argument/, 'sub throws an error when 2 arguments are passed'; @@ -103,7 +103,7 @@ sub run_tests { is( $obj->integer, 10, 'Set to ten' ); - throws_ok { $obj->set( 10, 2 ) } + like exception { $obj->set( 10, 2 ) }, qr/Cannot call set with more than 1 argument/, 'set throws an error when 2 arguments are passed'; @@ -111,7 +111,7 @@ sub run_tests { is( $obj->integer, 5, 'divide by 2' ); - throws_ok { $obj->div( 10, 2 ) } + like exception { $obj->div( 10, 2 ) }, qr/Cannot call div with more than 1 argument/, 'div throws an error when 2 arguments are passed'; @@ -119,7 +119,7 @@ sub run_tests { is( $obj->integer, 10, 'multiplied by 2' ); - throws_ok { $obj->mul( 10, 2 ) } + like exception { $obj->mul( 10, 2 ) }, qr/Cannot call mul with more than 1 argument/, 'mul throws an error when 2 arguments are passed'; @@ -127,7 +127,7 @@ sub run_tests { is( $obj->integer, 0, 'Mod by 2' ); - throws_ok { $obj->mod( 10, 2 ) } + like exception { $obj->mod( 10, 2 ) }, qr/Cannot call mod with more than 1 argument/, 'mod throws an error when 2 arguments are passed'; @@ -141,7 +141,7 @@ sub run_tests { is( $obj->abs, 1, 'abs returns new value' ); - throws_ok { $obj->abs(10) } + like exception { $obj->abs(10) }, qr/Cannot call abs with any arguments/, 'abs throws an error when an argument is passed'; diff --git a/t/070_native_traits/070_trait_string.t b/t/070_native_traits/070_trait_string.t index c6b9c63..e6ab822 100644 --- a/t/070_native_traits/070_trait_string.t +++ b/t/070_native_traits/070_trait_string.t @@ -9,7 +9,7 @@ use Moose (); use Moose::Util::TypeConstraints; use NoInlineAttribute; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; { @@ -92,28 +92,28 @@ sub run_tests { $obj->_string('a'); is( $obj->length, 1, 'length returns 1 for new string' ); - throws_ok { $obj->length(42) } + like exception { $obj->length(42) }, qr/Cannot call length with any arguments/, 'length throws an error when an argument is passed'; is( $obj->inc, 'b', 'inc returns new value' ); is( $obj->_string, 'b', 'a becomes b after inc' ); - throws_ok { $obj->inc(42) } + like exception { $obj->inc(42) }, qr/Cannot call inc with any arguments/, 'inc throws an error when an argument is passed'; is( $obj->append('foo'), 'bfoo', 'append returns new value' ); is( $obj->_string, 'bfoo', 'appended to the string' ); - throws_ok { $obj->append( 'foo', 2 ) } + like exception { $obj->append( 'foo', 2 ) }, qr/Cannot call append with more than 1 argument/, 'append throws an error when two arguments are passed'; $obj->append_curried; is( $obj->_string, 'bfoo!', 'append_curried appended to the string' ); - throws_ok { $obj->append_curried('foo') } + like exception { $obj->append_curried('foo') }, qr/Cannot call append with more than 1 argument/, 'append_curried throws an error when two arguments are passed'; @@ -127,14 +127,14 @@ sub run_tests { 'chomp is a no-op when string has no line ending' ); - throws_ok { $obj->chomp(42) } + like exception { $obj->chomp(42) }, qr/Cannot call chomp with any arguments/, 'chomp throws an error when an argument is passed'; is( $obj->chop, 'l', 'chop returns character removed' ); is( $obj->_string, 'has n', 'chopped string' ); - throws_ok { $obj->chop(42) } + like exception { $obj->chop(42) }, qr/Cannot call chop with any arguments/, 'chop throws an error when an argument is passed'; @@ -173,11 +173,11 @@ sub run_tests { is( $obj->_string, 'af', 'replace accepts an empty string as first argument' ); - throws_ok { $obj->replace( {}, 'x' ) } + like exception { $obj->replace( {}, 'x' ) }, qr/The first argument passed to replace must be a string or regexp reference/, 'replace throws an error when the first argument is not a string or regexp'; - throws_ok { $obj->replace( qr/x/, {} ) } + like exception { $obj->replace( qr/x/, {} ) }, qr/The second argument passed to replace must be a string or code reference/, 'replace throws an error when the first argument is not a string or regexp'; @@ -207,11 +207,11 @@ sub run_tests { 'match with empty string as argument returns true' ); - throws_ok { $obj->match } + like exception { $obj->match }, qr/Cannot call match without at least 1 argument/, 'match throws an error when no arguments are passed'; - throws_ok { $obj->match( {} ) } + like exception { $obj->match( {} ) }, qr/The argument passed to match must be a string or regexp reference/, 'match throws an error when an invalid argument is passed'; @@ -224,7 +224,7 @@ sub run_tests { $obj->clear; is( $obj->_string, q{}, 'clear' ); - throws_ok { $obj->clear(42) } + like exception { $obj->clear(42) }, qr/Cannot call clear with any arguments/, 'clear throws an error when an argument is passed'; @@ -258,23 +258,23 @@ sub run_tests { 'substr as setter with three arguments, replacment is empty string' ); - throws_ok { $obj->substr } + like exception { $obj->substr }, qr/Cannot call substr without at least 1 argument/, 'substr throws an error when no argumemts are passed'; - throws_ok { $obj->substr( 1, 2, 3, 4 ) } + like exception { $obj->substr( 1, 2, 3, 4 ) }, qr/Cannot call substr with more than 3 arguments/, 'substr throws an error when four argumemts are passed'; - throws_ok { $obj->substr( {} ) } + like exception { $obj->substr( {} ) }, qr/The first argument passed to substr must be an integer/, 'substr throws an error when first argument is not an integer'; - throws_ok { $obj->substr( 1, {} ) } + like exception { $obj->substr( 1, {} ) }, qr/The second argument passed to substr must be an integer/, 'substr throws an error when second argument is not an integer'; - throws_ok { $obj->substr( 1, 2, {} ) } + like exception { $obj->substr( 1, 2, {} ) }, qr/The third argument passed to substr must be a string/, 'substr throws an error when third argument is not a string'; diff --git a/t/070_native_traits/100_array_from_role.t b/t/070_native_traits/100_array_from_role.t index 7f76c1a..7d1805b 100644 --- a/t/070_native_traits/100_array_from_role.t +++ b/t/070_native_traits/100_array_from_role.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Foo; @@ -36,11 +36,11 @@ use Test::Exception; package Stuff; use Moose; - ::lives_ok{ with 'Stuffed::Role'; - } '... this should work correctly'; + ::ok ! ::exception { with 'Stuffed::Role'; + }, '... this should work correctly'; - ::lives_ok{ with 'Bulkie::Role'; - } '... this should work correctly'; + ::ok ! ::exception { with 'Bulkie::Role'; + }, '... this should work correctly'; } done_testing; diff --git a/t/070_native_traits/101_remove_attribute.t b/t/070_native_traits/101_remove_attribute.t index 5e9305d..7c59b18 100644 --- a/t/070_native_traits/101_remove_attribute.t +++ b/t/070_native_traits/101_remove_attribute.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package MyHomePage; @@ -33,9 +33,9 @@ can_ok( $page, $_ ) for qw[ reset_counter ]; -lives_ok { +ok ! exception { $page->meta->remove_attribute('counter'); -} +}, '... removed the counter attribute okay'; ok( !$page->meta->has_attribute('counter'), diff --git a/t/070_native_traits/103_custom_instance.t b/t/070_native_traits/103_custom_instance.t index 2830d83..4267baf 100644 --- a/t/070_native_traits/103_custom_instance.t +++ b/t/070_native_traits/103_custom_instance.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; { @@ -55,7 +55,7 @@ use Test::Moose; } ); - ::lives_ok { + ::ok ! ::exception { has array => ( traits => ['Array'], isa => 'ArrayRef', @@ -110,9 +110,9 @@ use Test::Moose; array_natatime_curried => [ natatime => 2 ], }, ); - } "native array trait inlines properly"; + }, "native array trait inlines properly"; - ::lives_ok { + ::ok ! ::exception { has bool => ( traits => ['Bool'], isa => 'Bool', @@ -124,9 +124,9 @@ use Test::Moose; bool_is_dark => 'not', }, ); - } "native bool trait inlines properly"; + }, "native bool trait inlines properly"; - ::lives_ok { + ::ok ! ::exception { has code => ( traits => ['Code'], isa => 'CodeRef', @@ -136,9 +136,9 @@ use Test::Moose; code_execute_method => 'execute_method', }, ); - } "native code trait inlines properly"; + }, "native code trait inlines properly"; - ::lives_ok { + ::ok ! ::exception { has counter => ( traits => ['Counter'], isa => 'Int', @@ -153,9 +153,9 @@ use Test::Moose; set_counter_42 => [ set => 42 ], }, ); - } "native counter trait inlines properly"; + }, "native counter trait inlines properly"; - ::lives_ok { + ::ok ! ::exception { has hash => ( traits => ['Hash'], isa => 'HashRef', @@ -175,9 +175,9 @@ use Test::Moose; hash_set_option => 'set', }, ); - } "native hash trait inlines properly"; + }, "native hash trait inlines properly"; - ::lives_ok { + ::ok ! ::exception { has number => ( traits => ['Number'], isa => 'Num', @@ -196,9 +196,9 @@ use Test::Moose; num_dec => [ sub => 1 ], }, ); - } "native number trait inlines properly"; + }, "native number trait inlines properly"; - ::lives_ok { + ::ok ! ::exception { has string => ( traits => ['String'], is => 'ro', @@ -224,7 +224,7 @@ use Test::Moose; string_substr_curried_3 => [ substr => ( 1, 3, 'ong' ) ], }, ); - } "native string trait inlines properly"; + }, "native string trait inlines properly"; } with_immutable { diff --git a/t/100_bugs/005_inline_reader_bug.t b/t/100_bugs/005_inline_reader_bug.t index b85925d..eeb5de7 100644 --- a/t/100_bugs/005_inline_reader_bug.t +++ b/t/100_bugs/005_inline_reader_bug.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -18,14 +18,14 @@ test makes sure it does not creep back in. package Foo; use Moose; - ::lives_ok { + ::ok ! ::exception { has 'bar' => ( is => 'ro', isa => 'Int', lazy => 1, default => 10, ); - } '... this didnt die'; + }, '... this didnt die'; } done_testing; diff --git a/t/100_bugs/006_handles_foreign_class_bug.t b/t/100_bugs/006_handles_foreign_class_bug.t index 82bad20..c910761 100644 --- a/t/100_bugs/006_handles_foreign_class_bug.t +++ b/t/100_bugs/006_handles_foreign_class_bug.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Foo; @@ -20,7 +20,7 @@ use Test::Exception; package Bar; use Moose; - ::lives_ok { + ::ok ! ::exception { has 'baz' => ( is => 'ro', isa => 'Foo', @@ -28,14 +28,14 @@ use Test::Exception; default => sub { Foo->new() }, handles => qr/^a$/, ); - } '... can create the attribute with delegations'; + }, '... can create the attribute with delegations'; } my $bar; -lives_ok { +ok ! exception { $bar = Bar->new; -} '... created the object ok'; +}, '... created the object ok'; isa_ok($bar, 'Bar'); is($bar->a, 'Foo::a', '... got the right delgated value'); @@ -46,7 +46,7 @@ $SIG{__WARN__} = sub { push @w, "@_" }; package Baz; use Moose; - ::lives_ok { + ::ok ! ::exception { has 'bar' => ( is => 'ro', isa => 'Foo', @@ -54,7 +54,7 @@ $SIG{__WARN__} = sub { push @w, "@_" }; default => sub { Foo->new() }, handles => qr/.*/, ); - } '... can create the attribute with delegations'; + }, '... can create the attribute with delegations'; } @@ -62,9 +62,9 @@ is(@w, 0, "no warnings"); my $baz; -lives_ok { +ok ! exception { $baz = Baz->new; -} '... created the object ok'; +}, '... created the object ok'; isa_ok($baz, 'Baz'); is($baz->a, 'Foo::a', '... got the right delgated value'); @@ -79,7 +79,7 @@ is($baz->a, 'Foo::a', '... got the right delgated value'); package Blart; use Moose; - ::lives_ok { + ::ok ! ::exception { has 'bar' => ( is => 'ro', isa => 'Foo', @@ -87,7 +87,7 @@ is($baz->a, 'Foo::a', '... got the right delgated value'); default => sub { Foo->new() }, handles => [qw(a new)], ); - } '... can create the attribute with delegations'; + }, '... can create the attribute with delegations'; } @@ -101,9 +101,9 @@ is($baz->a, 'Foo::a', '... got the right delgated value'); my $blart; -lives_ok { +ok ! exception { $blart = Blart->new; -} '... created the object ok'; +}, '... created the object ok'; isa_ok($blart, 'Blart'); is($blart->a, 'Foo::a', '... got the right delgated value'); diff --git a/t/100_bugs/011_DEMOLISH_eats_exceptions.t b/t/100_bugs/011_DEMOLISH_eats_exceptions.t index 4932fe2..23d7a9b 100644 --- a/t/100_bugs/011_DEMOLISH_eats_exceptions.t +++ b/t/100_bugs/011_DEMOLISH_eats_exceptions.t @@ -5,7 +5,7 @@ use warnings; use FindBin; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util::TypeConstraints; diff --git a/t/100_bugs/012_DEMOLISH_eats_mini.t b/t/100_bugs/012_DEMOLISH_eats_mini.t index 953e019..3e1caf6 100644 --- a/t/100_bugs/012_DEMOLISH_eats_mini.t +++ b/t/100_bugs/012_DEMOLISH_eats_mini.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { diff --git a/t/100_bugs/016_inheriting_from_roles.t b/t/100_bugs/016_inheriting_from_roles.t index c001dbb..eafc858 100644 --- a/t/100_bugs/016_inheriting_from_roles.t +++ b/t/100_bugs/016_inheriting_from_roles.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -15,9 +15,9 @@ use Test::Exception; package My::Class; use Moose; - ::throws_ok { + ::like ::exception { extends 'My::Role'; - } qr/You cannot inherit from a Moose Role \(My\:\:Role\)/, + }, qr/You cannot inherit from a Moose Role \(My\:\:Role\)/, '... this croaks correctly'; } diff --git a/t/100_bugs/017_type_constraint_messages.t b/t/100_bugs/017_type_constraint_messages.t index 526130d..a8fcf10 100644 --- a/t/100_bugs/017_type_constraint_messages.t +++ b/t/100_bugs/017_type_constraint_messages.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; # RT #37569 @@ -52,21 +52,21 @@ use Test::Exception; my $foo = Foo->new; my $obj = MyObject->new; -throws_ok { +like exception { $foo->ar( [] ); -} +}, qr/Attribute \(ar\) does not pass the type constraint because: ref: ARRAY/, '... got the right error message'; -throws_ok { +like exception { $foo->obj($foo); # Doh! -} +}, qr/Attribute \(obj\) does not pass the type constraint because: Well it is an object/, '... got the right error message'; -throws_ok { +like exception { $foo->nt($foo); # scalar -} +}, qr/Attribute \(nt\) does not pass the type constraint because: blessed/, '... got the right error message'; diff --git a/t/100_bugs/018_immutable_metaclass_does_role.t b/t/100_bugs/018_immutable_metaclass_does_role.t index 9a99477..2d71779 100644 --- a/t/100_bugs/018_immutable_metaclass_does_role.t +++ b/t/100_bugs/018_immutable_metaclass_does_role.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { @@ -41,9 +41,9 @@ is( $a->meta->foo, 'i am foo', '... foo method returns expected value' ); ok( MyClass->meta->meta->does_role('MyRole'), 'metaclass does MyRole' ); is( MyClass->meta->foo, 'i am foo', '... foo method returns expected value' ); -lives_ok { +ok ! exception { MyClass->meta->make_immutable; -} '... make MyClass immutable okay'; +}, '... make MyClass immutable okay'; is(MyClass->meta, $mc, '... these metas are still the same thing'); is(MyClass->meta->meta, $mc->meta, '... these meta-metas are the same thing'); @@ -53,9 +53,9 @@ is( $a->meta->foo, 'i am foo', '... foo method returns expected value' ); ok( MyClass->meta->meta->does_role('MyRole'), 'metaclass does MyRole' ); is( MyClass->meta->foo, 'i am foo', '... foo method returns expected value' ); -lives_ok { +ok ! exception { MyClass->meta->make_mutable; -} '... make MyClass mutable okay'; +}, '... make MyClass mutable okay'; is(MyClass->meta, $mc, '... these metas are still the same thing'); is(MyClass->meta->meta, $mc->meta, '... these meta-metas are the same thing'); @@ -65,9 +65,9 @@ is( $a->meta->foo, 'i am foo', '... foo method returns expected value' ); ok( MyClass->meta->meta->does_role('MyRole'), 'metaclass does MyRole' ); is( MyClass->meta->foo, 'i am foo', '... foo method returns expected value' ); -lives_ok { +ok ! exception { MyMetaclass->meta->make_immutable; -} '... make MyMetaclass immutable okay'; +}, '... make MyMetaclass immutable okay'; is(MyClass->meta, $mc, '... these metas are still the same thing'); is(MyClass->meta->meta, $mc->meta, '... these meta-metas are the same thing'); @@ -77,9 +77,9 @@ is( $a->meta->foo, 'i am foo', '... foo method returns expected value' ); ok( MyClass->meta->meta->does_role('MyRole'), 'metaclass does MyRole' ); is( MyClass->meta->foo, 'i am foo', '... foo method returns expected value' ); -lives_ok { +ok ! exception { MyClass->meta->make_immutable; -} '... make MyClass immutable (again) okay'; +}, '... make MyClass immutable (again) okay'; is(MyClass->meta, $mc, '... these metas are still the same thing'); is(MyClass->meta->meta, $mc->meta, '... these meta-metas are the same thing'); diff --git a/t/100_bugs/023_DEMOLISH_fails_without_metaclass.t b/t/100_bugs/023_DEMOLISH_fails_without_metaclass.t index a061244..8e5dfb6 100644 --- a/t/100_bugs/023_DEMOLISH_fails_without_metaclass.t +++ b/t/100_bugs/023_DEMOLISH_fails_without_metaclass.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package MyClass; @@ -21,7 +21,7 @@ Class::MOP::remove_metaclass_by_name('MyClass'); # The bug happened when DEMOLISHALL called # Class::MOP::class_of($object) and did not get a metaclass object # back. -lives_ok { $object->DESTROY } +ok ! exception { $object->DESTROY }, 'can call DESTROY on an object without a metaclass object in the CMOP cache'; @@ -30,7 +30,7 @@ Class::MOP::remove_metaclass_by_name('MyClass'); # The bug didn't manifest for immutable objects, but this test should # help us prevent it happening in the future. -lives_ok { $object->DESTROY } +ok ! exception { $object->DESTROY }, 'can call DESTROY on an object without a metaclass object in the CMOP cache (immutable version)'; done_testing; diff --git a/t/100_bugs/025_universal_methods_wrappable.t b/t/100_bugs/025_universal_methods_wrappable.t index 8eea71a..f44d3eb 100644 --- a/t/100_bugs/025_universal_methods_wrappable.t +++ b/t/100_bugs/025_universal_methods_wrappable.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::Exception; +use Test::Fatal; use Test::More; { @@ -22,7 +22,7 @@ use Test::More; local $TODO = 'UNIVERSAL methods should be wrappable'; - ::lives_ok { with 'FakeBar' } 'applied role'; + ::ok ! ::exception { with 'FakeBar' }, 'applied role'; my $foo = Foo->new; ::isa_ok $foo, 'Bar'; diff --git a/t/100_bugs/026_create_anon_recursion.t b/t/100_bugs/026_create_anon_recursion.t index 1756795..26933a8 100644 --- a/t/100_bugs/026_create_anon_recursion.t +++ b/t/100_bugs/026_create_anon_recursion.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Class; @@ -14,11 +14,11 @@ TODO: = 'Loading Moose::Meta::Class without loading Moose.pm causes weird problems'; my $meta; - lives_ok { + ok ! exception { $meta = Moose::Meta::Class->create_anon_class( superclasses => [ 'Moose::Object', ], ); - } + }, 'Class is created successfully'; } diff --git a/t/100_bugs/028_apply_role_to_one_instance_only.t b/t/100_bugs/028_apply_role_to_one_instance_only.t index be31007..4124237 100644 --- a/t/100_bugs/028_apply_role_to_one_instance_only.t +++ b/t/100_bugs/028_apply_role_to_one_instance_only.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package MyRole1; @@ -37,8 +37,8 @@ ok ((not $instance_with_role2->can('a_role_method')), ok (($instance_with_role1->does('MyRole1')), 'role was applied to the correct instance'); -lives_and { +ok ! exception { is $instance_with_role1->a_role_method, 'foo' -} 'instance has correct role method'; +}, 'instance has correct role method'; done_testing; diff --git a/t/100_bugs/029_instance_application_role_args.t b/t/100_bugs/029_instance_application_role_args.t index 9a3e238..8ab6d56 100644 --- a/t/100_bugs/029_instance_application_role_args.t +++ b/t/100_bugs/029_instance_application_role_args.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Point; diff --git a/t/100_bugs/030_coerce_without_coercion.t b/t/100_bugs/030_coerce_without_coercion.t index 7880688..120f763 100644 --- a/t/100_bugs/030_coerce_without_coercion.t +++ b/t/100_bugs/030_coerce_without_coercion.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Moose; { @@ -19,17 +19,17 @@ use Test::Moose; } with_immutable { - lives_ok { Foo->new( x => {} ) } + ok ! exception { Foo->new( x => {} ) }, 'Setting coerce => 1 without a coercion on the type does not cause an error in the constructor'; - lives_ok { Foo->new->x( {} ) } + ok ! exception { Foo->new->x( {} ) }, 'Setting coerce => 1 without a coercion on the type does not cause an error when setting the attribut'; - throws_ok { Foo->new( x => 42 ) } + like exception { Foo->new( x => 42 ) }, qr/\QAttribute (x) does not pass the type constraint because/, 'Attempting to provide an invalid value to the constructor for this attr still fails'; - throws_ok { Foo->new->x(42) } + like exception { Foo->new->x(42) }, qr/\QAttribute (x) does not pass the type constraint because/, 'Attempting to provide an invalid value to the accessor for this attr still fails'; } diff --git a/t/200_examples/001_example.t b/t/200_examples/001_example.t index 5984cc9..b7247d6 100644 --- a/t/200_examples/001_example.t +++ b/t/200_examples/001_example.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; ## Roles diff --git a/t/200_examples/002_example_Moose_POOP.t b/t/200_examples/002_example_Moose_POOP.t index b0227bd..d6a5485 100644 --- a/t/200_examples/002_example_Moose_POOP.t +++ b/t/200_examples/002_example_Moose_POOP.t @@ -10,7 +10,7 @@ use Test::Requires { 'DateTime::Format::MySQL' => '0.01', }; -use Test::Exception; +use Test::Fatal; BEGIN { # in case there are leftovers @@ -237,7 +237,7 @@ my $article_oid; my $article_ref; { my $article; - lives_ok { + ok ! exception { $article = Newswriter::Article->new( headline => 'Home Office Redecorated', summary => 'The home office was recently redecorated to match the new company colors', @@ -250,14 +250,14 @@ my $article_ref; status => 'pending' ); - } '... created my article successfully'; + }, '... created my article successfully'; isa_ok($article, 'Newswriter::Article'); isa_ok($article, 'MooseX::POOP::Object'); - lives_ok { + ok ! exception { $article->start_date(DateTime->new(year => 2006, month => 6, day => 10)); $article->end_date(DateTime->new(year => 2006, month => 6, day => 17)); - } '... add the article date-time stuff'; + }, '... add the article date-time stuff'; ## check some meta stuff @@ -300,7 +300,7 @@ my $article2_oid; my $article2_ref; { my $article2; - lives_ok { + ok ! exception { $article2 = Newswriter::Article->new( headline => 'Company wins Lottery', summary => 'An email was received today that informed the company we have won the lottery', @@ -313,7 +313,7 @@ my $article2_ref; status => 'posted' ); - } '... created my article successfully'; + }, '... created my article successfully'; isa_ok($article2, 'Newswriter::Article'); isa_ok($article2, 'MooseX::POOP::Object'); @@ -340,9 +340,9 @@ my $article2_ref; ## orig-article my $article; - lives_ok { + ok ! exception { $article = Newswriter::Article->new(oid => $article_oid); - } '... (re)-created my article successfully'; + }, '... (re)-created my article successfully'; isa_ok($article, 'Newswriter::Article'); isa_ok($article, 'MooseX::POOP::Object'); @@ -364,10 +364,10 @@ my $article2_ref; is($article->author->first_name, 'Truman', '... got the right author first name'); is($article->author->last_name, 'Capote', '... got the right author last name'); - lives_ok { + ok ! exception { $article->author->first_name('Dan'); $article->author->last_name('Rather'); - } '... changed the value ok'; + }, '... changed the value ok'; is($article->author->first_name, 'Dan', '... got the changed author first name'); is($article->author->last_name, 'Rather', '... got the changed author last name'); @@ -379,9 +379,9 @@ MooseX::POOP::Meta::Instance->_reload_db(); { my $article; - lives_ok { + ok ! exception { $article = Newswriter::Article->new(oid => $article_oid); - } '... (re)-created my article successfully'; + }, '... (re)-created my article successfully'; isa_ok($article, 'Newswriter::Article'); isa_ok($article, 'MooseX::POOP::Object'); @@ -406,9 +406,9 @@ MooseX::POOP::Meta::Instance->_reload_db(); is($article->status, 'pending', '... got the right status'); my $article2; - lives_ok { + ok ! exception { $article2 = Newswriter::Article->new(oid => $article2_oid); - } '... (re)-created my article successfully'; + }, '... (re)-created my article successfully'; isa_ok($article2, 'Newswriter::Article'); isa_ok($article2, 'MooseX::POOP::Object'); diff --git a/t/200_examples/003_example.t b/t/200_examples/003_example.t index a61ba35..2cf01c7 100644 --- a/t/200_examples/003_example.t +++ b/t/200_examples/003_example.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; sub U { my $f = shift; @@ -81,16 +81,16 @@ sub Y { package My::List1; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'List', 'List::Immutable'; - } '... successfully composed roles together'; + }, '... successfully composed roles together'; package My::List2; use Moose; - ::lives_ok { + ::ok ! ::exception { with 'List::Immutable', 'List'; - } '... successfully composed roles together'; + }, '... successfully composed roles together'; } diff --git a/t/200_examples/004_example_w_DCS.t b/t/200_examples/004_example_w_DCS.t index 671781c..2b1168f 100644 --- a/t/200_examples/004_example_w_DCS.t +++ b/t/200_examples/004_example_w_DCS.t @@ -18,7 +18,7 @@ use Test::Requires { 'Declare::Constraints::Simple' => '0.01', # skip all if not installed }; -use Test::Exception; +use Test::Fatal; { package Foo; @@ -58,35 +58,35 @@ my $hash_of_arrays_of_objs = { my $array_of_ints = [ 1 .. 10 ]; my $foo; -lives_ok { +ok ! exception { $foo = Foo->new( 'bar' => $hash_of_arrays_of_objs, 'baz' => $array_of_ints, ); -} '... construction succeeded'; +}, '... construction succeeded'; isa_ok($foo, 'Foo'); is_deeply($foo->bar, $hash_of_arrays_of_objs, '... got our value correctly'); is_deeply($foo->baz, $array_of_ints, '... got our value correctly'); -dies_ok { +ok exception { $foo->bar([]); -} '... validation failed correctly'; +}, '... validation failed correctly'; -dies_ok { +ok exception { $foo->bar({ foo => 3 }); -} '... validation failed correctly'; +}, '... validation failed correctly'; -dies_ok { +ok exception { $foo->bar({ foo => [ 1, 2, 3 ] }); -} '... validation failed correctly'; +}, '... validation failed correctly'; -dies_ok { +ok exception { $foo->baz([ "foo" ]); -} '... validation failed correctly'; +}, '... validation failed correctly'; -dies_ok { +ok exception { $foo->baz({}); -} '... validation failed correctly'; +}, '... validation failed correctly'; done_testing; diff --git a/t/200_examples/005_example_w_TestDeep.t b/t/200_examples/005_example_w_TestDeep.t index 676ae29..0e8f53d 100644 --- a/t/200_examples/005_example_w_TestDeep.t +++ b/t/200_examples/005_example_w_TestDeep.t @@ -19,7 +19,7 @@ use Test::Requires { 'Test::Deep' => '0.01', # skip all if not installed }; -use Test::Exception; +use Test::Fatal; { package Foo; @@ -58,19 +58,19 @@ my $array_of_hashes = [ ]; my $foo; -lives_ok { +ok ! exception { $foo = Foo->new('bar' => $array_of_hashes); -} '... construction succeeded'; +}, '... construction succeeded'; isa_ok($foo, 'Foo'); is_deeply($foo->bar, $array_of_hashes, '... got our value correctly'); -dies_ok { +ok exception { $foo->bar({}); -} '... validation failed correctly'; +}, '... validation failed correctly'; -dies_ok { +ok exception { $foo->bar([{ foo => 3 }]); -} '... validation failed correctly'; +}, '... validation failed correctly'; done_testing; diff --git a/t/200_examples/008_record_set_iterator.t b/t/200_examples/008_record_set_iterator.t index 61d4339..6f050c7 100644 --- a/t/200_examples/008_record_set_iterator.t +++ b/t/200_examples/008_record_set_iterator.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { diff --git a/t/300_immutable/001_immutable_moose.t b/t/300_immutable/001_immutable_moose.t index b969268..aa90d6d 100644 --- a/t/300_immutable/001_immutable_moose.t +++ b/t/300_immutable/001_immutable_moose.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Meta::Role; @@ -33,25 +33,25 @@ use Moose::Meta::Role; my $foo_role = Moose::Meta::Role->initialize('FooRole'); my $meta = Foo->meta; - lives_ok { Foo->new } "lazy_build works"; + ok ! exception { Foo->new }, "lazy_build works"; is( Foo->new->foos, 'many foos', "correct value for 'foos' before inlining constructor" ); is( Foo->new->bars, 'many bars', "correct value for 'bars' before inlining constructor" ); is( Foo->new->bazes, 'many bazes', "correct value for 'bazes' before inlining constructor" ); - lives_ok { $meta->make_immutable } "Foo is imutable"; - lives_ok { $meta->identifier } "->identifier on metaclass lives"; - dies_ok { $meta->add_role($foo_role) } "Add Role is locked"; - lives_ok { Foo->new } "Inlined constructor works with lazy_build"; + ok ! exception { $meta->make_immutable }, "Foo is imutable"; + ok ! exception { $meta->identifier }, "->identifier on metaclass lives"; + ok exception { $meta->add_role($foo_role) }, "Add Role is locked"; + ok ! exception { Foo->new }, "Inlined constructor works with lazy_build"; is( Foo->new->foos, 'many foos', "correct value for 'foos' after inlining constructor" ); is( Foo->new->bars, 'many bars', "correct value for 'bars' after inlining constructor" ); is( Foo->new->bazes, 'many bazes', "correct value for 'bazes' after inlining constructor" ); - lives_ok { $meta->make_mutable } "Foo is mutable"; - lives_ok { $meta->add_role($foo_role) } "Add Role is unlocked"; + ok ! exception { $meta->make_mutable }, "Foo is mutable"; + ok ! exception { $meta->add_role($foo_role) }, "Add Role is unlocked"; } @@ -73,10 +73,10 @@ use Moose::Meta::Role; sub BUILD { 'baz' } } -lives_ok { Bar->meta->make_immutable } +ok ! exception { Bar->meta->make_immutable }, 'Immutable meta with single BUILD'; -lives_ok { Baz->meta->make_immutable } +ok ! exception { Baz->meta->make_immutable }, 'Immutable meta with multiple BUILDs'; =pod diff --git a/t/300_immutable/002_apply_roles_to_immutable.t b/t/300_immutable/002_apply_roles_to_immutable.t index 57d0c7f..7739b24 100644 --- a/t/300_immutable/002_apply_roles_to_immutable.t +++ b/t/300_immutable/002_apply_roles_to_immutable.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -31,9 +31,9 @@ isa_ok($foo, 'Foo'); is($foo->baz, 'Foo::baz', '... got the right value'); -lives_ok { +ok ! exception { My::Role->meta->apply($foo) -} '... successfully applied the role to immutable instance'; +}, '... successfully applied the role to immutable instance'; is($foo->baz, 'My::Role::baz(Foo::baz)', '... got the right value'); diff --git a/t/300_immutable/003_immutable_meta_class.t b/t/300_immutable/003_immutable_meta_class.t index 1a1b662..ae5b844 100644 --- a/t/300_immutable/003_immutable_meta_class.t +++ b/t/300_immutable/003_immutable_meta_class.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -20,8 +20,8 @@ use Test::Exception; ); } -lives_ok { +ok ! exception { My::Meta->meta()->make_immutable(debug => 0) -} '... can make a meta class immutable'; +}, '... can make a meta class immutable'; done_testing; diff --git a/t/300_immutable/004_inlined_constructors_n_types.t b/t/300_immutable/004_inlined_constructors_n_types.t index 0c47a8c..c2e9fb3 100644 --- a/t/300_immutable/004_inlined_constructors_n_types.t +++ b/t/300_immutable/004_inlined_constructors_n_types.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -42,19 +42,19 @@ as with a Class::MOP::Attribute object. for (1..2) { my $is_immutable = Foo->meta->is_immutable; my $mutable_string = $is_immutable ? 'immutable' : 'mutable'; - lives_ok { + ok ! exception { my $f = Foo->new(foo => 10, bar => "Hello World", baz => 10, zot => 4); is($f->moo, 69, "Type coercion works as expected on default ($mutable_string)"); is($f->boo, 69, "Type coercion works as expected on builder ($mutable_string)"); - } "... this passes the constuctor correctly ($mutable_string)"; + }, "... this passes the constuctor correctly ($mutable_string)"; - lives_ok { + ok ! exception { Foo->new(foo => 10, bar => "Hello World", baz => 10, zot => "not an int"); - } "... the constructor doesn't care about 'zot' ($mutable_string)"; + }, "... the constructor doesn't care about 'zot' ($mutable_string)"; - dies_ok { + ok exception { Foo->new(foo => "Hello World", bar => 100, baz => "Hello World"); - } "... this fails the constuctor correctly ($mutable_string)"; + }, "... this fails the constuctor correctly ($mutable_string)"; Foo->meta->make_immutable(debug => 0) unless $is_immutable; } diff --git a/t/300_immutable/005_multiple_demolish_inline.t b/t/300_immutable/005_multiple_demolish_inline.t index d30a9c8..c6b5bdb 100644 --- a/t/300_immutable/005_multiple_demolish_inline.t +++ b/t/300_immutable/005_multiple_demolish_inline.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -26,20 +26,20 @@ use Test::Exception; sub DEMOLISH { } } -lives_ok { +ok ! exception { Bar->new(); -} 'Bar->new()'; +}, 'Bar->new()'; -lives_ok { +ok ! exception { Bar->meta->make_immutable; -} 'Bar->meta->make_immutable'; +}, 'Bar->meta->make_immutable'; is( Bar->meta->get_method('DESTROY')->package_name, 'Bar', 'Bar has a DESTROY method in the Bar class (not inherited)' ); -lives_ok { +ok ! exception { Foo->meta->make_immutable; -} 'Foo->meta->make_immutable'; +}, 'Foo->meta->make_immutable'; is( Foo->meta->get_method('DESTROY')->package_name, 'Foo', 'Foo has a DESTROY method in the Bar class (not inherited)' ); diff --git a/t/300_immutable/007_immutable_trigger_from_constructor.t b/t/300_immutable/007_immutable_trigger_from_constructor.t index bc86c1d..ee667b5 100644 --- a/t/300_immutable/007_immutable_trigger_from_constructor.t +++ b/t/300_immutable/007_immutable_trigger_from_constructor.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -33,6 +33,6 @@ like ($@, qr/^Pulling the Foo trigger/, "trigger from immutable constructor"); eval { AClass->new(baz => 'bar') }; like ($@, qr/^Pulling the Baz trigger/, "trigger from immutable constructor"); -lives_ok { AClass->new(bar => 'bar') } '... no triggers called'; +ok ! exception { AClass->new(bar => 'bar') }, '... no triggers called'; done_testing; diff --git a/t/300_immutable/008_immutable_constructor_error.t b/t/300_immutable/008_immutable_constructor_error.t index d5db002..e5d208b 100644 --- a/t/300_immutable/008_immutable_constructor_error.t +++ b/t/300_immutable/008_immutable_constructor_error.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod @@ -25,11 +25,11 @@ constructor. } my $scalar = 1; -throws_ok { Foo->new($scalar) } qr/\QSingle parameters to new() must be a HASH ref/, +like exception { Foo->new($scalar) }, qr/\QSingle parameters to new() must be a HASH ref/, 'Non-ref provided to immutable constructor gives useful error message'; -throws_ok { Foo->new(\$scalar) } qr/\QSingle parameters to new() must be a HASH ref/, +like exception { Foo->new(\$scalar) }, qr/\QSingle parameters to new() must be a HASH ref/, 'Scalar ref provided to immutable constructor gives useful error message'; -throws_ok { Foo->new(undef) } qr/\QSingle parameters to new() must be a HASH ref/, +like exception { Foo->new(undef) }, qr/\QSingle parameters to new() must be a HASH ref/, 'undef provided to immutable constructor gives useful error message'; done_testing; diff --git a/t/300_immutable/012_default_values.t b/t/300_immutable/012_default_values.t index ad4e611..2114f4a 100644 --- a/t/300_immutable/012_default_values.t +++ b/t/300_immutable/012_default_values.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -17,7 +17,7 @@ use Test::Exception; has 'buz' => ( is => 'rw', default => q{"'\\} ); has 'faz' => ( is => 'rw', default => qq{\0} ); - ::lives_ok { __PACKAGE__->meta->make_immutable } + ::ok ! ::exception { __PACKAGE__->meta->make_immutable }, 'no errors making a package immutable when it has default values that could break quoting'; } @@ -47,7 +47,7 @@ is( $foo->faz, qq{\0}, has 'buz' => ( is => 'rw', default => q{"'\\}, lazy => 1 ); has 'faz' => ( is => 'rw', default => qq{\0}, lazy => 1 ); - ::lives_ok { __PACKAGE__->meta->make_immutable } + ::ok ! ::exception { __PACKAGE__->meta->make_immutable }, 'no errors making a package immutable when it has lazy default values that could break quoting'; } diff --git a/t/400_moose_util/008_method_mod_args.t b/t/400_moose_util/008_method_mod_args.t index 5919287..be7b29f 100644 --- a/t/400_moose_util/008_method_mod_args.t +++ b/t/400_moose_util/008_method_mod_args.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Moose::Util qw( add_method_modifier ); my $COUNT = 0; @@ -14,13 +14,13 @@ my $COUNT = 0; sub bar { } } -lives_ok { +ok ! exception { add_method_modifier('Foo', 'before', [ ['foo', 'bar'], sub { $COUNT++ } ]); -} 'method modifier with an arrayref'; +}, 'method modifier with an arrayref'; -dies_ok { +ok exception { add_method_modifier('Foo', 'before', [ {'foo' => 'bar'}, sub { $COUNT++ } ]); -} 'method modifier with a hashref'; +}, 'method modifier with a hashref'; my $foo = Foo->new; $foo->foo; diff --git a/t/600_todo_tests/001_exception_reflects_failed_constraint.t b/t/600_todo_tests/001_exception_reflects_failed_constraint.t index c768b90..d6e0568 100644 --- a/t/600_todo_tests/001_exception_reflects_failed_constraint.t +++ b/t/600_todo_tests/001_exception_reflects_failed_constraint.t @@ -8,20 +8,20 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('Moose::Util::TypeConstraints'); } -lives_ok { +ok ! exception { subtype 'ParentConstraint' => as 'Str' => where {0}; -} 'specified parent type constraint'; +}, 'specified parent type constraint'; my $tc; -lives_ok { +ok ! exception { $tc = subtype 'ChildConstraint' => as 'ParentConstraint' => where {1}; -} 'specified child type constraint'; +}, 'specified child type constraint'; { my $errmsg = $tc->validate(); diff --git a/t/600_todo_tests/002_various_role_features.t b/t/600_todo_tests/002_various_role_features.t index 8b6bccc..992d1c8 100644 --- a/t/600_todo_tests/002_various_role_features.t +++ b/t/600_todo_tests/002_various_role_features.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; sub req_or_has ($$) { my ( $role, $method ) = @_; @@ -73,7 +73,7 @@ sub req_or_has ($$) { # this doesn't fail but it produces a requires in the role # the order doesn't matter has twist => ( is => "rw" ); - ::lives_ok { with qw(Dancer) }; + ::ok ! ::exception { with qw(Dancer) }; package Dancer::Something; use Moose; @@ -83,7 +83,7 @@ sub req_or_has ($$) { has twist => ( is => "rw" ); { - ::lives_ok { with qw(Dancer) }; + ::ok ! ::exception { with qw(Dancer) }; } package Dancer::80s; @@ -93,7 +93,7 @@ sub req_or_has ($$) { # but due to the deferrence logic that doesn't actually work { local our $TODO = "attribute accessor in role doesn't satisfy role requires"; - ::lives_ok { with qw(Dancer::Robot) }; + ::ok ! ::exception { with qw(Dancer::Robot) }; } package Foo; @@ -135,7 +135,7 @@ sub req_or_has ($$) { { local our $TODO = "attrs and methods from a role should clash"; - ::dies_ok { with qw(Tree Dog) } + ::ok ::exception { with qw(Tree Dog) }, } } diff --git a/t/600_todo_tests/005_moose_and_threads.t b/t/600_todo_tests/005_moose_and_threads.t index a0f7a81..67c4eb7 100644 --- a/t/600_todo_tests/005_moose_and_threads.t +++ b/t/600_todo_tests/005_moose_and_threads.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; =pod diff --git a/t/600_todo_tests/006_required_role_accessors.t b/t/600_todo_tests/006_required_role_accessors.t index fed49f8..153b32a 100644 --- a/t/600_todo_tests/006_required_role_accessors.t +++ b/t/600_todo_tests/006_required_role_accessors.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; { package Foo::API; @@ -24,7 +24,7 @@ use Test::Exception; package Foo::Class; use Moose; { our $TODO; local $TODO = "role accessors don't satisfy other role requires"; - ::lives_ok { with 'Foo' } 'requirements are satisfied properly'; + ::ok ! ::exception { with 'Foo' }, 'requirements are satisfied properly'; } } @@ -51,7 +51,7 @@ use Test::Exception; use Moose; { our $TODO; local $TODO = "role accessors don't satisfy other role requires"; - ::lives_ok { with qw(Bar Baz) } 'requirements are satisfied properly'; + ::ok ! ::exception { with qw(Bar Baz) }, 'requirements are satisfied properly'; } } diff --git a/t/600_todo_tests/007_application_metarole_compat.t b/t/600_todo_tests/007_application_metarole_compat.t index c254f51..81affc5 100644 --- a/t/600_todo_tests/007_application_metarole_compat.t +++ b/t/600_todo_tests/007_application_metarole_compat.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; BEGIN { { @@ -52,7 +52,7 @@ BEGIN { package Child; use Moose -traits => 'Bar'; { our $TODO; local $TODO = "no idea what's going on here"; - ::lives_ok { extends 'Parent' }; + ::ok ! ::exception { extends 'Parent' }; } }