From: Dave Rolsky Date: Thu, 28 Oct 2010 15:18:42 +0000 (-0500) Subject: Revert most of the conversion to Test::Fatal so we can redo it X-Git-Tag: 1.18~36 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=53a4d826caec4b82f5b23e0bc0a4e8e2f44243b9;p=gitmo%2FMoose.git Revert most of the conversion to Test::Fatal so we can redo it --- diff --git a/author/extract-inline-tests b/author/extract-inline-tests index 8cdb4cc..77fb246 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::Fatal;\n$1/; + $base =~ s/(\$\| = 1;)/use Test::Exception;\n$1/; return $base; } diff --git a/lib/Moose/Cookbook/Basics/Recipe1.pod b/lib/Moose/Cookbook/Basics/Recipe1.pod index 4fc7e0a..8fe4a8c 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' ); -ok exception { +dies_ok { $point->y('Foo'); -}, +} '... cannot assign a non-Int to y'; -ok exception { +dies_ok { 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 -ok ! exception { +lives_ok { Point->new( x => 0, y => 0 ); -}, +} '... can assign a 0 to x and y'; -ok exception { +dies_ok { Point->new( x => 10, y => 'Foo' ); -}, +} '... cannot assign a non-Int to y'; -ok exception { +dies_ok { 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' ); -ok exception { +dies_ok { Point3D->new( x => 10, y => 'Foo', z => 3 ); -}, +} '... cannot assign a non-Int to y'; -ok exception { +dies_ok { Point3D->new( x => 'Foo', y => 10, z => 3 ); -}, +} '... cannot assign a non-Int to x'; -ok exception { +dies_ok { Point3D->new( x => 0, y => 10, z => 'Bar' ); -}, +} '... cannot assign a non-Int to z'; -ok exception { +dies_ok { 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 9087d4e..9f1a4dd 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' ); - ok ! exception { + lives_ok { $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' ); - ok ! exception { + lives_ok { $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)' ); - ok ! exception { + lives_ok { $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' ); - ok ! exception { + lives_ok { $checking_account->withdraw(50); - }, + } '... withdrew from checking successfully'; is( $checking_account->balance, 50, '... got the right checkings balance after withdrawl' ); - ok exception { + dies_ok { $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 e7a2b5b..1028ecd 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'); -ok ! exception { +lives_ok { $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'); -ok ! exception { +lives_ok { $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'); -ok ! exception { +lives_ok { $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 -ok exception { +dies_ok { $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 ee11206..325b43b 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; -ok ! exception { +lives_ok { $ii = Company->new( { name => 'Infinity Interactive', @@ -351,7 +351,7 @@ ok ! exception { ] } ); -}, +} '... 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 -ok exception { +dies_ok { Address->new( street => {} ),; -}, +} '... we die correctly with bad args'; -ok exception { +dies_ok { Address->new( city => {} ),; -}, +} '... we die correctly with bad args'; -ok exception { +dies_ok { Address->new( state => 'British Columbia' ),; -}, +} '... we die correctly with bad args'; -ok ! exception { +lives_ok { Address->new( state => 'Connecticut' ),; -}, +} '... we live correctly with good args'; -ok exception { +dies_ok { Address->new( zip_code => 'AF5J6$' ),; -}, +} '... we die correctly with bad args'; -ok ! exception { +lives_ok { Address->new( zip_code => '06443' ),; -}, +} '... we live correctly with good args'; -ok exception { +dies_ok { Company->new(),; -}, +} '... we die correctly without good args'; -ok ! exception { +lives_ok { Company->new( name => 'Foo' ),; -}, +} '... we live correctly without good args'; -ok exception { +dies_ok { Company->new( name => 'Foo', employees => [ Person->new ] ),; -}, +} '... we die correctly with good args'; -ok ! exception { +lives_ok { 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 45de2c4..d901d57 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' ); - ok exception { + dies_ok { $r->headers('Foo'); - }, + } '... dies when it gets bad params'; } { is( $r->protocol, undef, '... got nothing by default' ); - ok ! exception { + lives_ok { $r->protocol('HTTP/1.0'); - }, + } '... set the protocol correctly'; is( $r->protocol, 'HTTP/1.0', '... got nothing by default' ); - ok exception { + dies_ok { $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 98cedad..91eaac3 100644 --- a/lib/Moose/Cookbook/Meta/Recipe6.pod +++ b/lib/Moose/Cookbook/Meta/Recipe6.pod @@ -149,12 +149,11 @@ it under the same terms as Perl itself. package main; -use Test::More; -use Test::Fatal; +use Test::Exception; my $user = MyApp::User->new( password => 'foo!' ); -like exception { $user->_reset_password }, +throws_ok { $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 2299375..b8130f9 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::Fatal; +use Test::Exception; { @@ -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'); -ok exception { +dies_ok { 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 04cbac7..ad09165 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::Fatal; +use Test::Exception; { @@ -14,7 +14,7 @@ use Test::Fatal; package Bar; use Moose; - ::ok ! ::exception { extends 'Foo' }, 'loaded Foo superclass correctly'; + ::lives_ok { extends 'Foo' } 'loaded Foo superclass correctly'; } { @@ -22,7 +22,7 @@ use Test::Fatal; package Baz; use Moose; - ::ok ! ::exception { extends 'Bar' }, 'loaded (inline) Bar superclass correctly'; + ::lives_ok { extends 'Bar' } 'loaded (inline) Bar superclass correctly'; } { @@ -30,7 +30,7 @@ use Test::Fatal; package Foo::Bar; use Moose; - ::ok ! ::exception { extends 'Foo', 'Bar' }, + ::lives_ok { extends 'Foo', 'Bar' } 'loaded Foo and (inline) Bar superclass correctly'; } @@ -39,7 +39,7 @@ use Test::Fatal; package Bling; use Moose; - ::like ::exception { extends 'No::Class' }, + ::throws_ok { 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::Fatal; package Tiger; use Moose; - ::ok ! ::exception { extends 'Foo', Affe => { -version => 13 } }, + ::lives_ok { extends 'Foo', Affe => { -version => 13 } } 'extends with version requirement'; } @@ -61,7 +61,7 @@ use Test::Fatal; package Birne; use Moose; - ::like ::exception { extends 'Foo', Affe => { -version => 42 } }, + ::throws_ok { 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 abb3f21..7ea63ea 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::Fatal; +use Test::Exception; { @@ -72,9 +72,9 @@ is($foo->baz(), 'Foo::baz', '... got the right value from &baz'); sub bling { 'Bling::bling' } - ::ok ::exception { + ::dies_ok { 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 4d0e032..eecd547 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::Fatal; +use Test::Exception; { @@ -77,9 +77,9 @@ is($foo->baz(), 'Foo::baz()', '... got the right value from &baz'); sub bling { 'Bling::bling' } - ::ok ::exception { + ::dies_ok { 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 404e20b..bc51d34 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::Fatal; +use Test::Exception; { @@ -69,17 +69,17 @@ is( $Cat::AFTER_BARK_COUNTER, 2, 'after modifier is called twice' ); package Dog::Role; use Moose::Role; - ::ok ::exception { + ::dies_ok { before qr/bark.*/ => sub {}; - }, '... this is not currently supported'; + } '... this is not currently supported'; - ::ok ::exception { + ::dies_ok { around qr/bark.*/ => sub {}; - }, '... this is not currently supported'; + } '... this is not currently supported'; - ::ok ::exception { + ::dies_ok { 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 e8ef84d..3e0997a 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::Fatal; +use Test::Exception; 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'); -ok ! exception { +lives_ok { $bar->foo('Foo'); -}, '... checked the type constraint correctly'; +} '... checked the type constraint correctly'; -ok exception { +dies_ok { $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 0ce5c44..b35cd7f 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::Fatal; +use Test::Exception; 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"); -ok ! exception { $foo->type_constrained(10.5) }, "Num type constraint for now.."; +lives_ok { $foo->type_constrained(10.5) } "Num type constraint for now.."; # try to rebless, except it will fail due to Child's stricter type constraint -like exception { Child->meta->rebless_instance($foo) }, +throws_ok { 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'; -like exception { Child->meta->rebless_instance($bar) }, +throws_ok { 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"); -like exception { $foo->type_constrained(10.5) }, +throws_ok { $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 825dfd7..1c8003b 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::Fatal; +use Test::Exception; { package Class; @@ -24,13 +24,13 @@ use Test::Fatal; my $new_class; -ok ! exception { +lives_ok { $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'; -like exception { +throws_ok { 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"; -ok exception { +dies_ok { 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 0c1c00f..4198721 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::Fatal; +use Test::Exception; -ok ! exception { +lives_ok { 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 79222d3..542c79c 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::Fatal; +use Test::Exception; # This tests the error handling in Moose::Object only @@ -13,12 +13,12 @@ use Test::Fatal; use Moose; } -like exception { Foo->new('bad') }, qr/^\QSingle parameters to new() must be a HASH ref/, +throws_ok { Foo->new('bad') } qr/^\QSingle parameters to new() must be a HASH ref/, 'A single non-hashref arg to a constructor throws an error'; -like exception { Foo->new(undef) }, qr/^\QSingle parameters to new() must be a HASH ref/, +throws_ok { Foo->new(undef) } qr/^\QSingle parameters to new() must be a HASH ref/, 'A single non-hashref arg to a constructor throws an error'; -like exception { Foo->does() }, qr/^\QYou must supply a role name to does()/, +throws_ok { 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 07b2b61..7c99849 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::Fatal; +use Test::Exception; use Test::More; use Test::Moose qw( with_immutable ); @@ -17,7 +17,7 @@ use Test::Requires { } with_immutable { - ok ! exception { + lives_and { 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 f4943c9..7a601a7 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::Fatal; +use Test::Exception; use Test::More; use Test::Requires { 'Test::Output' => '0.01', }; -# All tests are wrapped with exception{} because the stderr output tests will +# All tests are wrapped with lives_and because the stderr output tests will # otherwise eat exceptions, and the test just dies silently. { @@ -24,7 +24,7 @@ use Test::Requires { use Moose; - ::ok not ::exception( + ::lives_and( sub { ::stderr_like{ has foo => ( traits => ['String'], @@ -68,7 +68,7 @@ use Test::Requires { use Moose; - ::ok not ::exception( + ::lives_and( sub { ::stderr_is{ has foo => ( traits => ['String'], @@ -104,7 +104,7 @@ use Test::Requires { use Moose; - ::ok not ::exception( + ::lives_and( sub { ::stderr_is{ has foo => ( traits => ['String'], @@ -139,7 +139,7 @@ use Test::Requires { use Moose; - ::ok not ::exception( + ::lives_and( 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 d8dbb62..f51140b 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::Fatal; +use Test::Exception; { @@ -44,17 +44,17 @@ use Test::Fatal; can_ok($foo, 'get_foo'); is($foo->get_foo(), undef, '... got an undefined value'); - ok exception { + dies_ok { $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'); - ok exception { + dies_ok { $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 81d7950..f166150 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::Fatal; +use Test::Exception; 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'); - ok ! exception { + lives_ok { $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 - ok exception { + dies_ok { 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'); - ok ! exception { + lives_ok { $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'); - ok exception { + dies_ok { $foo->set_foo_required(); - }, '... set_foo_required died successfully with no value'; + } '... set_foo_required died successfully with no value'; - ok ! exception { + lives_ok { $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'); - ok ! exception { + lives_ok { $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'); - ok exception { + dies_ok { $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'); - ok ! exception { + lives_ok { $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 532b558..0603f95 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::Fatal; +use Test::Exception; use Scalar::Util 'isweak'; @@ -90,29 +90,29 @@ use Scalar::Util 'isweak'; can_ok($foo, 'foo'); is($foo->foo(), undef, '... got an unset value'); - ok ! exception { + lives_ok { $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 - ok exception { + dies_ok { 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'); - ok ! exception { + lives_ok { $foo->foo_required(100); - }, '... foo_required wrote successfully'; + } '... foo_required wrote successfully'; is($foo->foo_required(), 100, '... got the correct set value'); - ok ! exception { + lives_ok { $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'); - ok ! exception { + lives_ok { $foo->foo_int(100); - }, '... foo_int wrote successfully'; + } '... foo_int wrote successfully'; is($foo->foo_int(), 100, '... got the correct set value'); - ok exception { + dies_ok { $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'); - ok ! exception { + lives_ok { $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; - ok ! exception { + lives_ok { @list = $foo->foo_deref(); - }, "... doesn't deref undef value"; + } "... doesn't deref undef value"; is_deeply( \@list, [], "returns empty list in list context"); - ok ! exception { + lives_ok { $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" ); - ok exception { + dies_ok { $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; - ok ! exception { + lives_ok { %hash = $foo->foo_deref_hash(); - }, "... doesn't deref undef value"; + } "... doesn't deref undef value"; is_deeply( \%hash, {}, "returns empty list in list context"); - ok ! exception { + lives_ok { $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 8e6b458..b8ec580 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::Fatal; +use Test::Exception; { @@ -50,27 +50,27 @@ use Test::Fatal; my $baz = Baz->new; isa_ok($baz, 'Baz'); - ok ! exception { + lives_ok { $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'); - ok ! exception { + lives_ok { $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 - ok ! exception { + lives_ok { $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::Fatal; package Bling; use Moose; - ::ok ::exception { + ::dies_ok { has('bling' => (is => 'rw', trigger => 'Fail')); - }, '... a trigger must be a CODE ref'; + } '... a trigger must be a CODE ref'; - ::ok ::exception { + ::dies_ok { 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::Fatal; { my $blarg; - ok ! exception { $blarg = Blarg->new; }, 'Blarg->new() lives'; + lives_ok { $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::Fatal; 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'); - ok ! exception { $blarg = Blarg->new( map { $_ => "Yet another $_ value" } qw/foo bar baz/ ) }, '->new() with parameters'; + lives_ok { $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 61332a5..945717b 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::Fatal; +use Test::Exception; { @@ -46,25 +46,25 @@ isa_ok($foo, 'Foo::Class'); my $bar = Bar::Class->new; isa_ok($bar, 'Bar::Class'); -ok ! exception { +lives_ok { $foo->bar($bar); -}, '... bar passed the type constraint okay'; +} '... bar passed the type constraint okay'; -ok exception { +dies_ok { $foo->bar($foo); -}, '... foo did not pass the type constraint okay'; +} '... foo did not pass the type constraint okay'; -ok ! exception { +lives_ok { $foo->baz($bar); -}, '... baz passed the type constraint okay'; +} '... baz passed the type constraint okay'; -ok exception { +dies_ok { $foo->baz($foo); -}, '... foo did not pass the type constraint okay'; +} '... foo did not pass the type constraint okay'; -ok ! exception { +lives_ok { $bar->foo($foo); -}, '... foo passed the type constraint okay'; +} '... foo passed the type constraint okay'; @@ -76,9 +76,9 @@ ok ! exception { # if isa and does appear together, then see if Class->does(Role) # if it does not,.. we have a conflict... so we die loudly - ::ok ::exception { + ::dies_ok { 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 @@ ok ! exception { # if isa and does appear together, then see if Class->does(Role) # if it does not,.. we have a conflict... so we die loudly - ::ok ::exception { + ::dies_ok { 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 f226544..5df07cc 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::Fatal; +use Test::Exception; { @@ -44,25 +44,25 @@ use Test::Fatal; } #Yeah.. this doesn't work like this anymore, see below. (groditi) -#like exception { +#throws_ok { # 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'; -#like exception { +#throws_ok { # 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'; -ok ! exception { +lives_ok { Foo->new(bar => 10, baz => undef); -}, '... undef is a valid attribute value'; +} '... undef is a valid attribute value'; -ok ! exception { +lives_ok { Foo->new(bar => 10, boo => undef); -}, '... undef is a valid attribute value'; +} '... undef is a valid attribute value'; -like exception { +throws_ok { 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 c1f518e..58c1ec1 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::Fatal; +use Test::Exception; { @@ -53,9 +53,9 @@ use Test::Fatal; package Bar; use Moose; - ::ok ! ::exception { + ::lives_ok { 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::Fatal; package Another::Foo; use Moose; - ::ok ! ::exception { + ::lives_ok { has 'foo' => (metaclass => 'Foo'); - }, '... the attribute metaclass alias worked correctly'; + } '... the attribute metaclass alias worked correctly'; - ::ok ! ::exception { + ::lives_ok { 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 ac30ddc..f2ad610 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::Fatal; +use Test::Exception; { @@ -17,39 +17,39 @@ use Test::Fatal; my $foo = Foo->new; isa_ok($foo, 'Foo'); -ok ! exception { +lives_ok { $foo->bar([]) -}, '... set bar successfully with an ARRAY ref'; +} '... set bar successfully with an ARRAY ref'; -ok ! exception { +lives_ok { $foo->bar({}) -}, '... set bar successfully with a HASH ref'; +} '... set bar successfully with a HASH ref'; -ok exception { +dies_ok { $foo->bar(100) -}, '... couldnt set bar successfully with a number'; +} '... couldnt set bar successfully with a number'; -ok exception { +dies_ok { $foo->bar(sub {}) -}, '... couldnt set bar successfully with a CODE ref'; +} '... couldnt set bar successfully with a CODE ref'; # check the constructor -ok ! exception { +lives_ok { 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'; -ok ! exception { +lives_ok { 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'; -ok exception { +dies_ok { Foo->new(bar => 50) -}, '... didnt create a new Foo with bar as a number'; +} '... didnt create a new Foo with bar as a number'; -ok exception { +dies_ok { 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 @@ ok exception { my $bar = Bar->new; isa_ok($bar, 'Bar'); -ok ! exception { +lives_ok { $bar->baz('a string') -}, '... set baz successfully with a string'; +} '... set baz successfully with a string'; -ok ! exception { +lives_ok { $bar->baz(sub { 'a sub' }) -}, '... set baz successfully with a CODE ref'; +} '... set baz successfully with a CODE ref'; -ok exception { +dies_ok { $bar->baz(\(my $var1)) -}, '... couldnt set baz successfully with a SCALAR ref'; +} '... couldnt set baz successfully with a SCALAR ref'; -ok exception { +dies_ok { $bar->baz({}) -}, '... couldnt set bar successfully with a HASH ref'; +} '... couldnt set bar successfully with a HASH ref'; # check the constructor -ok ! exception { +lives_ok { 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'; -ok ! exception { +lives_ok { 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'; -ok exception { +dies_ok { 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'; -ok exception { +dies_ok { 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 3a35989..e745ebe 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::Fatal; +use Test::Exception; { @@ -59,138 +59,138 @@ use Test::Fatal; extends 'Foo'; - ::ok ! ::exception { + ::lives_ok { has '+bar' => (default => 'Bar::bar'); - }, '... we can change the default attribute option'; + } '... we can change the default attribute option'; - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { has '+foo' => (coerce => 1); - }, '... we can change/add coerce as an attribute option'; + } '... we can change/add coerce as an attribute option'; - ::ok ! ::exception { + ::lives_ok { has '+gorch' => (required => 1); - }, '... we can change/add required as an attribute option'; + } '... we can change/add required as an attribute option'; - ::ok ! ::exception { + ::lives_ok { has '+gloum' => (lazy => 1); - }, '... we can change/add lazy as an attribute option'; + } '... we can change/add lazy as an attribute option'; - ::ok ! ::exception { + ::lives_ok { has '+fleem' => (lazy_build => 1); - }, '... we can add lazy_build as an attribute option'; + } '... we can add lazy_build as an attribute option'; - ::ok ! ::exception { + ::lives_ok { has '+bunch_of_stuff' => (isa => 'ArrayRef[Int]'); - }, '... extend an attribute with parameterized type'; + } '... extend an attribute with parameterized type'; - ::ok ! ::exception { + ::lives_ok { has '+one_last_one' => (isa => subtype('Ref', where { blessed $_ eq 'CODE' })); - }, '... extend an attribute with anon-subtype'; + } '... extend an attribute with anon-subtype'; - ::ok ! ::exception { + ::lives_ok { has '+one_last_one' => (isa => 'Value'); - }, '... now can extend an attribute with a non-subtype'; + } '... now can extend an attribute with a non-subtype'; - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { has '+bling' => (handles => ['hello']); - }, '... we can add the handles attribute option'; + } '... we can add the handles attribute option'; # this one will *not* work here .... - ::ok ::exception { + ::dies_ok { has '+blang' => (handles => ['hello']); - }, '... we can not alter the handles attribute option'; - ::ok ! ::exception { + } '... we can not alter the handles attribute option'; + ::lives_ok { has '+fail' => (isa => 'Ref'); - }, '... can now create an attribute with an improper subtype relation'; - ::ok ::exception { + } '... can now create an attribute with an improper subtype relation'; + ::dies_ok { has '+other_fail' => (trigger => sub {}); - }, '... cannot create an attribute with an illegal option'; - ::like ::exception { + } '... cannot create an attribute with an illegal option'; + ::throws_ok { 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'); -ok ! exception { $foo->foo('FooString') }, '... assigned foo correctly'; +lives_ok { $foo->foo('FooString') } '... assigned foo correctly'; is($foo->foo, 'FooString', '... got the right value for foo'); -ok exception { $foo->foo([]) }, '... foo is not coercing (as expected)'; +dies_ok { $foo->foo([]) } '... foo is not coercing (as expected)'; is($foo->bar, 'Foo::bar', '... got the right default value'); -ok exception { $foo->bar(10) }, '... Foo::bar is a read/only attr'; +dies_ok { $foo->bar(10) } '... Foo::bar is a read/only attr'; is($foo->baz, undef, '... got the right undef default value'); { my $hash_ref = {}; - ok ! exception { $foo->baz($hash_ref) }, '... Foo::baz accepts hash refs'; + lives_ok { $foo->baz($hash_ref) } '... Foo::baz accepts hash refs'; is($foo->baz, $hash_ref, '... got the right value assigned to baz'); my $array_ref = []; - ok ! exception { $foo->baz($array_ref) }, '... Foo::baz accepts an array ref'; + lives_ok { $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); - ok ! exception { $foo->baz($scalar_ref) }, '... Foo::baz accepts scalar ref'; + lives_ok { $foo->baz($scalar_ref) } '... Foo::baz accepts scalar ref'; is($foo->baz, $scalar_ref, '... got the right value assigned to baz'); - ok ! exception { $foo->bunch_of_stuff([qw[one two three]]) }, '... Foo::bunch_of_stuff accepts an array of strings'; + lives_ok { $foo->bunch_of_stuff([qw[one two three]]) } '... Foo::bunch_of_stuff accepts an array of strings'; - ok ! exception { $foo->one_last_one(sub { 'Hello World'}) }, '... Foo::one_last_one accepts a code ref'; + lives_ok { $foo->one_last_one(sub { 'Hello World'}) } '... Foo::one_last_one accepts a code ref'; my $code_ref = sub { 1 }; - ok ! exception { $foo->baz($code_ref) }, '... Foo::baz accepts a code ref'; + lives_ok { $foo->baz($code_ref) } '... Foo::baz accepts a code ref'; is($foo->baz, $code_ref, '... got the right value assigned to baz'); } -ok exception { +dies_ok { 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'); -ok ! exception { $bar->foo('FooString') }, '... assigned foo correctly'; +lives_ok { $bar->foo('FooString') } '... assigned foo correctly'; is($bar->foo, 'FooString', '... got the right value for foo'); -ok ! exception { $bar->foo([]) }, '... assigned foo correctly'; +lives_ok { $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'); -ok exception { $bar->bar(10) }, '... Bar::bar is a read/only attr'; +dies_ok { $bar->bar(10) } '... Bar::bar is a read/only attr'; is($bar->baz, undef, '... got the right undef default value'); { my $hash_ref = {}; - ok exception { $bar->baz($hash_ref) }, '... Bar::baz does not accept hash refs'; + dies_ok { $bar->baz($hash_ref) } '... Bar::baz does not accept hash refs'; my $array_ref = []; - ok ! exception { $bar->baz($array_ref) }, '... Bar::baz can accept an array ref'; + lives_ok { $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); - ok exception { $bar->baz($scalar_ref) }, '... Bar::baz does not accept a scalar ref'; + dies_ok { $bar->baz($scalar_ref) } '... Bar::baz does not accept a scalar ref'; - 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'; + 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'; my $code_ref = sub { 1 }; - ok exception { $bar->baz($code_ref) }, '... Bar::baz does not accept a code ref'; + dies_ok { $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 c2f50b9..bcd4cc7 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::Fatal; +use Test::Exception; # ------------------------------------------------------------------- @@ -77,9 +77,9 @@ isa_ok($foo, 'Foo'); is($foo->bar, 25, '... got the right foo->bar'); -ok ! exception { +lives_ok { $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; - ::ok ::exception { + ::dies_ok { 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'); - ok ! exception { + lives_ok { $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'); - ok ! exception { + lives_ok { $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); - like exception { $i->foo_bar }, qr/is not defined/, + throws_ok { $i->foo_bar } qr/is not defined/, 'useful error from unblessed reference'; my $j = Bar->new(foo => []); - like exception { $j->foo_bar }, qr/is not an object \(got 'ARRAY/, + throws_ok { $j->foo_bar } qr/is not an object \(got 'ARRAY/, 'useful error from unblessed reference'; my $k = Bar->new(foo => "Foo"); - ok ! exception { $k->foo_baz }, "but not for class name"; + lives_ok { $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 b2f278b..18b8fc1 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::Fatal; +use Test::Exception; =pod @@ -94,41 +94,41 @@ do not fail at compile time. sub parent_method_1 { "parent_1" } ::can_ok('Parent', 'parent_method_1'); - ::ok ::exception { + ::dies_ok { has child_a => ( is => "ro", default => sub { ChildA->new }, handles => qr/.*/, ); - }, "all_methods requires explicit isa"; + } "all_methods requires explicit isa"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { has child_c => ( isa => "ChildC", is => "ro", default => sub { ChildC->new }, handles => qr/_la$/, ); - }, "can declare regex collector"; + } "can declare regex collector"; - ::ok ::exception { + ::dies_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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" ); - ::ok ! ::exception { + ::lives_ok { 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'); - ::ok ::exception { + ::dies_ok { 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'); - ::ok ! ::exception { + ::lives_ok { 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 dc827ff..7f855a3 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::Fatal; +use Test::Exception; { @@ -57,13 +57,13 @@ use Test::Fatal; my $test = Test::For::Lazy::TypeConstraint->new; isa_ok($test, 'Test::For::Lazy::TypeConstraint'); - ok exception { + dies_ok { $test->bad_lazy_attr; - }, '... this does not work'; + } '... this does not work'; - ok ! exception { + lives_ok { $test->good_lazy_attr; - }, '... this does not work'; + } '... this does not work'; } { @@ -118,9 +118,9 @@ use Test::Fatal; } - ok exception { + dies_ok { 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::Fatal; is($moose_obj->a_str( 'foobar' ), 'foobar', 'setter took string'); ok($moose_obj, 'this is a *not* a string'); - like exception { + throws_ok { $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::Fatal; has 'a_num' => ( isa => 'Int' , is => 'rw', default => 7.5 ); } - like exception { + throws_ok { 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 '; - ok ! exception { + lives_ok { OverloadBreaker->new(a_num => 5); - }, '... this works fine though'; + } '... this works fine though'; } @@ -192,9 +192,9 @@ use Test::Fatal; has 'foo' => ( required => 1, builder => 'build_foo', is => 'ro'); } - ok exception { + dies_ok { Test::Builder::Attribute::Broken->new; - }, '... no builder, wtf'; + } '... no builder, wtf'; } @@ -244,7 +244,7 @@ use Test::Fatal; ok(!$instance->_has_foo, "noo _foo value yet"); is($instance->foo, 'works', "foo builder works"); is($instance->_foo, 'works too', "foo builder works too"); - like exception { $instance->fool }, + throws_ok { $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::Fatal; use Moose; } -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'; +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(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; - ::like ::exception { has 'foo' => ( 'ro', isa => 'Str' ) }, + ::throws_ok { 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 42953be..fa78897 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::Fatal; +use Test::Exception; { @@ -15,14 +15,14 @@ use Test::Fatal; use Moose; use Moose::Util::TypeConstraints; - ::ok ! ::exception { + ::lives_ok { 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::Fatal; { my $autoderef = AutoDeref->new; - ok exception { + dies_ok { $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'; - ok ! exception { + lives_ok { $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 67f9100..fe61494 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::Fatal; +use Test::Exception; @@ -43,8 +43,8 @@ use Test::Fatal; my $r = Request->new; isa_ok($r, 'Request'); -ok ! exception { +lives_ok { $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/019_attribute_lazy_initializer.t b/t/020_attributes/019_attribute_lazy_initializer.t index 6c57598..3ac82d8 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::Fatal; +use Test::Exception; { @@ -143,8 +143,8 @@ use Test::Fatal; __PACKAGE__->meta->make_immutable; } -ok exception { +dies_ok { 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/021_method_generation_rules.t b/t/020_attributes/021_method_generation_rules.t index 3873713..646e572 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::Fatal; +use Test::Exception; =pod @@ -33,9 +33,9 @@ ok($class, "Can define attr with rw + writer"); $obj = $class->new(); can_ok($obj, qw/foo _foo/); -ok ! exception {$obj->_foo(1)}, "$class->_foo is writer"; +lives_ok {$obj->_foo(1)} "$class->_foo is writer"; is($obj->foo(), 1, "$class->foo is reader"); -ok exception {$obj->foo(2)}, "$class->foo is not writer"; # this should fail +dies_ok {$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/); -ok ! exception {$obj->_foo(1)}, "$class->_foo is writer"; +lives_ok {$obj->_foo(1)} "$class->_foo is writer"; is($obj->foo(), 1, "$class->foo is reader"); -ok exception {$obj->foo(1)}, "$class->foo is not writer"; +dies_ok {$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/); -ok ! exception {$obj->_foo(1)}, "$class->_foo is writer"; +lives_ok {$obj->_foo(1)} "$class->_foo is writer"; is($obj->_foo(), 1, "$class->foo is reader"); -ok exception { make_class('ro', 'accessor', "Test::Class::AccessorRO"); }, "Cant define attr with ro + accessor"; +dies_ok { 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 d806670..fdf6276 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::Fatal; +use Test::Exception; { package Foo; @@ -24,12 +24,12 @@ use Test::Fatal; extends 'Foo'; - ::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"; + ::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"; - ::like ::exception { has '+bar' => (clearer => 'quux') }, qr/illegal/, "can't override clearer"; - ::ok ! ::exception { has '+bar' => (predicate => 'has_bar') }, "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"; } { @@ -47,13 +47,13 @@ use Test::Fatal; package Bar; use Moose; - ::ok ! ::exception { + ::lives_ok { 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::Fatal; extends 'Bar'; - ::like ::exception { has '+bar' => (my_illegal_option => 'BAR') }, + ::throws_ok { has '+bar' => (my_illegal_option => 'BAR') } qr/illegal/, "can't override illegal attribute"; - ::ok ! ::exception { has '+baz' => (my_illegal_option => 'BAR') }, + ::lives_ok { 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 ab17444..ebcfd09 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::Fatal; +use Test::Exception; my $exception_regex = qr/You must provide a name for the attribute/; { package My::Role; use Moose::Role; - ::like ::exception { + ::throws_ok { has; - }, $exception_regex, 'has; fails'; + } $exception_regex, 'has; fails'; - ::like ::exception { + ::throws_ok { has undef; - }, $exception_regex, 'has undef; fails'; + } $exception_regex, 'has undef; fails'; - ::ok ! ::exception { + ::lives_ok { has "" => ( is => 'bare', ); - }, 'has ""; works now'; + } 'has ""; works now'; - ::ok ! ::exception { + ::lives_ok { has 0 => ( is => 'bare', ); - }, 'has 0; works now'; + } 'has 0; works now'; } { package My::Class; use Moose; - ::like ::exception { + ::throws_ok { has; - }, $exception_regex, 'has; fails'; + } $exception_regex, 'has; fails'; - ::like ::exception { + ::throws_ok { has undef; - }, $exception_regex, 'has undef; fails'; + } $exception_regex, 'has undef; fails'; - ::ok ! ::exception { + ::lives_ok { has "" => ( is => 'bare', ); - }, 'has ""; works now'; + } 'has ""; works now'; - ::ok ! ::exception { + ::lives_ok { has 0 => ( is => 'bare', ); - }, 'has 0; works now'; + } 'has 0; works now'; } done_testing; diff --git a/t/020_attributes/028_no_slot_access.t b/t/020_attributes/028_no_slot_access.t index acd7e05..d9a5eca 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::Fatal; + use Test::Exception; Moose::Util::MetaRole::apply_metaroles( for => __PACKAGE__, class_metaroles => { instance => ['MooseX::SomeAwesomeDBFields'] }, ); - ok ! exception { + lives_ok { has lazy_attr => ( is => 'ro', isa => 'Bool', lazy => 1, default => sub {0}, ); - }, + } "Adding lazy accessor does not use inline_slot_access"; - ok ! exception { + lives_ok { has rw_attr => ( is => 'rw', ); - }, + } "Adding read-write accessor does not use inline_slot_access"; - ok ! exception { __PACKAGE__->meta->make_immutable; }, + lives_ok { __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 4bd9f38..b13a594 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::Fatal; +use Test::Exception; -ok ! exception { +lives_ok { package My::Class; use Moose; @@ -44,9 +44,9 @@ ok ! exception { auto_deref => 1, ); -}, 'class definition'; +} 'class definition'; -ok ! exception { +lives_ok { my $o = My::Class->new(); is_deeply [scalar $o->s_rw], [undef], 'uninitialized scalar attribute/rw in scalar context'; @@ -65,6 +65,6 @@ ok ! exception { 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/030_roles/001_meta_role.t b/t/030_roles/001_meta_role.t index 568307f..2a040f3 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::Fatal; +use Test::Exception; 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'); -ok ! exception { +lives_ok { $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' ); -ok ! exception { +lives_ok { $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' ); -ok ! exception { +lives_ok { $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" }; -ok ! exception { +lives_ok { $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 ebccefc..778cd5d 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::Fatal; +use Test::Exception; =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" }; - ::ok ::exception { extends() }, '... extends() is not supported'; - ::ok ::exception { augment() }, '... augment() is not supported'; - ::ok ::exception { inner() }, '... inner() is not supported'; + ::dies_ok { extends() } '... extends() is not supported'; + ::dies_ok { augment() } '... augment() is not supported'; + ::dies_ok { 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 b31caf1..e58c0e2 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::Fatal; +use Test::Exception; { package FooRole; @@ -46,11 +46,11 @@ use Test::Fatal; extends 'BarClass'; - ::like ::exception { with 'FooRole' => { -version => 42 } }, + ::throws_ok { with 'FooRole' => { -version => 42 } } qr/FooRole version 42 required--this is only version 23/, 'applying role with unsatisfied version requirement'; - ::ok ! ::exception { with 'FooRole' => { -version => 13 } }, + ::lives_ok { 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' ); -ok exception { +dies_ok { $foo_class_meta->does_role(); -}, +} '... does_role requires a role name'; -ok exception { +dies_ok { $foo_class_meta->add_role(); -}, +} '... apply_role requires a role'; -ok exception { +dies_ok { $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' ); - ok exception { + dies_ok { $foo->baz(1); - }, + } '... baz is a read-only accessor'; - ok exception { + dies_ok { $foo->bar(1); - }, + } '... bar is a read-write accessor with a type constraint'; my $foo2 = FooClass->new(); isa_ok( $foo2, 'FooClass' ); - ok ! exception { + lives_ok { $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 8249c27..b2c58f4 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::Fatal; +use Test::Exception; { @@ -27,7 +27,7 @@ is_deeply( package Foo::Class; use Moose; - ::ok ::exception { with('Foo::Role') }, + ::dies_ok { with('Foo::Role') } '... no foo method implemented by Foo::Class'; } @@ -37,9 +37,9 @@ is_deeply( package Bar::Class; use Moose; - ::ok ::exception { with('Foo::Class') }, + ::dies_ok { with('Foo::Class') } '... cannot consume a class, it must be a role'; - ::ok ! ::exception { with('Foo::Role') }, + ::lives_ok { 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; - ::ok ! ::exception { with('Foo::Role') }, + ::lives_ok { 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; - ::ok ! ::exception { with('Foo::Role') }, + ::lives_ok { with('Foo::Role') } '... no foo method implemented by Baz::Role'; } @@ -85,7 +85,7 @@ is_deeply( package Baz::Class; use Moose; - ::ok ::exception { with('Baz::Role') }, + ::dies_ok { with('Baz::Role') } '... no foo method implemented by Baz::Class2'; } @@ -95,7 +95,7 @@ is_deeply( package Baz::Class2; use Moose; - ::ok ! ::exception { with('Baz::Role') }, + ::lives_ok { 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; - ::like ::exception { with('Quux::Role') }, + ::throws_ok { 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 { } - ::like ::exception { with('Quux::Role') }, + ::throws_ok { 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' ); - ::like ::exception { with('Quux::Role') }, + ::throws_ok { 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' ); - ::like ::exception { with('Quux::Role') }, + ::throws_ok { 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 e9ed296..b06628d 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::Fatal; +use Test::Exception; =pod @@ -32,16 +32,16 @@ Mutually recursive roles. package My::Test1; use Moose; - ::ok ! ::exception { + ::lives_ok { with 'Role::Foo', 'Role::Bar'; - }, '... our mutually recursive roles combine okay'; + } '... our mutually recursive roles combine okay'; package My::Test2; use Moose; - ::ok ! ::exception { + ::lives_ok { 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; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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,34 @@ Role attribute conflicts package My::Test7; use Moose; - ::like ::exception { + ::throws_ok { with 'Role::Boo', 'Role::Boo::Hoo'; }, qr/We have encountered an attribute conflict.+ghost/, - '... role attrs conflict and method was required'; package My::Test8; use Moose; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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'); - ::like ::exception { + ::throws_ok { 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 +274,34 @@ Role override method conflicts extends 'My::Test::Base'; - ::ok ! ::exception { + ::lives_ok { with 'Role::Truth'; - }, '... composed the role with override okay'; + } '... composed the role with override okay'; package My::Test12; use Moose; extends 'My::Test::Base'; - ::ok ! ::exception { + ::lives_ok { with 'Role::Plot'; - }, '... composed the role with override okay'; + } '... composed the role with override okay'; package My::Test13; use Moose; - ::ok ::exception { + ::dies_ok { 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'; - ::like ::exception { + ::throws_ok { 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 +327,9 @@ is(My::Test14->twist(), 'My::Test::Base::twist', '... got the right method retur package Role::Reality; use Moose::Role; - ::like ::exception { + ::throws_ok { 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 +360,9 @@ is(Role::Reality->meta->get_method('twist')->(), package Conflicts; use Moose; - ::like ::exception { + ::throws_ok { 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 +417,108 @@ Now I have to decide actually what happens, and how to fix it. package My::Test15; use Moose; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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 bc2bfca..1d80e84 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::Fatal; +use Test::Exception; =pod @@ -53,28 +53,28 @@ the roles into the same class package My::Test1; use Moose; - ::ok ! ::exception { + ::lives_ok { with 'Molecule::Organic'; - }, '... adding the role (w/ excluded roles) okay'; + } '... adding the role (w/ excluded roles) okay'; package My::Test2; use Moose; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { with 'Molecule::Organic'; - }, '... adding the role (w/ excluded roles) okay'; + } '... adding the role (w/ excluded roles) okay'; - ::like ::exception { + ::throws_ok { 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'; - ::like ::exception { + ::throws_ok { 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 6da415f..bdbcf45 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::Fatal; +use Test::Exception; =pod @@ -35,9 +35,9 @@ not remove the requirement) use warnings; use Moose::Role; - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { 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' }; - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { 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' }; - ::ok ! ::exception { + ::lives_ok { 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' }; - ::ok ! ::exception { + ::lives_ok { 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'); - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { 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'); - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { 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 ok exception {} here, too, but putting it into a + # technically we could run lives_ok 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'; - ::ok ! ::exception { + ::lives_ok { 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 ok exception {} here, too, but putting it into a + # technically we could run lives_ok 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'; - ::ok ! ::exception { + ::lives_ok { 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 7f3636a..aff9bd9 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::Fatal; +use Test::Exception; =pod @@ -33,9 +33,9 @@ a conflict) package My::Test::Class1; use Moose; - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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 522630c..4a4fde0 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::Fatal; +use Test::Exception; { @@ -30,9 +30,9 @@ use Test::Fatal; package SubAB; use Moose; - ::ok ! ::exception { + ::lives_ok { 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::Fatal; can_ok( $i, "foo" ); my $foo_rv; - ok ! exception { + lives_ok { $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::Fatal; package SubBB; use Moose; - ::ok ! ::exception { + ::lives_ok { with "SubBA"; - }, '... composed the role successfully'; + } '... composed the role successfully'; } ok( SubBB->does("SubBA"), "BB does SubBA" ); @@ -107,20 +107,20 @@ use Test::Fatal; can_ok( $i, "foo" ); my $foo_rv; - ok ! exception { + lives_ok { $foo_rv = $i->foo - }, '... called foo successfully'; + } '... called foo successfully'; is( $foo_rv, "RootB::foo", "foo rv" ); is( $i->counter, 1, "after hook called" ); - ok ! exception { $i->foo }, '... called foo successfully (again)'; + lives_ok { $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; - #ok ! exception { + #lives_ok { # $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::Fatal; with "RootC"; - ::ok ::exception { + ::dies_ok { 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 096868a..300a39f 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::Fatal; +use Test::Exception; { @@ -22,9 +22,9 @@ use Test::Fatal; package Role::C; use Moose::Role; - ::ok ! ::exception { + ::lives_ok { 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::Fatal; package Class::A; use Moose; - ::ok ! ::exception { + ::lives_ok { 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; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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'); { - ok ! exception { + lives_ok { 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 8e3083e..fa74523 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::Fatal; +use Test::Exception; { @@ -58,20 +58,20 @@ ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is requ package My::Foo::Class; use Moose; - ::ok ! ::exception { + ::lives_ok { 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; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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 9b6ef04..6487561 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::Fatal; +use Test::Exception; { @@ -20,16 +20,16 @@ use Test::Fatal; package My::Class; use Moose; - ::ok ! ::exception { + ::lives_ok { with 'My::Role' => { -alias => { bar => 'role_bar' } }; - }, '... this succeeds'; + } '... this succeeds'; package My::Class::Failure; use Moose; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { with 'My::Role' => { -alias => { bar => 'role_bar' } }; - }, '... this succeeds'; + } '... this succeeds'; sub bar { 'My::OtherRole::bar' } package My::OtherRole::Failure; use Moose::Role; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::like ::exception { + ::throws_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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; - ::ok ! ::exception { + ::lives_ok { 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,12 +170,14 @@ ok(My::Foo::AliasOnly->meta->has_method('foo_foo'), '.. and the aliased foo_foo package Role::Bar; use Moose::Role; - ::ok ! ::exception { + use Test::Exception; + + lives_ok { with 'Role::Foo' => { -alias => { x1 => 'foo_x1' }, -excludes => ['y1'], }; - }, + } 'Compose Role::Foo into Role::Bar with alias and exclude'; sub x1 {} @@ -192,12 +194,14 @@ ok(My::Foo::AliasOnly->meta->has_method('foo_foo'), '.. and the aliased foo_foo package Role::Baz; use Moose::Role; - ::ok ! ::exception { + use Test::Exception; + + lives_ok { 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 4dd460c..1bba604 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::Fatal; +use Test::Exception; { @@ -45,12 +45,12 @@ use Test::Fatal; package My::Class; use Moose; - ::ok ! ::exception { + ::lives_ok { 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 cfcbcba..865e252 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::Fatal; +use Test::Exception; 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'); -ok exception { +dies_ok { $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'); -ok ! exception { +lives_ok { $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 906da55..ec4e657 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::Fatal; +use Test::Exception; use Scalar::Util 'blessed'; @@ -39,9 +39,9 @@ isa_ok($foo, 'Foo'); ok(!$bar->can( 'talk' ), "... the role is not composed yet"); -ok exception { +dies_ok { $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'); -ok ! exception { +lives_ok { $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 452bebc..16bc2e7 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::Fatal; +use Test::Exception; =pod @@ -29,9 +29,9 @@ on role attributes works right. with 'Foo::Role'; - ::ok ! ::exception { + ::lives_ok { 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'; - ::ok ! ::exception { + ::lives_ok { 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"); -like exception { $bar->foo("baz") }, qr/^Attribute \(foo\) does not pass the type constraint because: Validation failed for 'Int' with value baz at /; +throws_ok { $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'; - ::ok ! ::exception { + ::lives_ok { 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"); -like exception { $baz->baz("zonk") }, qr/^Attribute \(baz\) does not pass the type constraint because: Validation failed for 'ClassName\|Int' with value zonk at /; +throws_ok { $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 }; - ::ok ! ::exception { + ::lives_ok { 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"); -like exception { $quux->quux("quux") }, qr/^Attribute \(quux\) does not pass the type constraint because: Validation failed for 'ArrayRef\|Positive' with value quux at /; +throws_ok { $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"); -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 /; +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 /; 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'; - ::ok ! ::exception { + ::lives_ok { has '+err1' => (isa => 'Defined'); - }, "can get less specific in the subclass"; + } "can get less specific in the subclass"; - ::ok ! ::exception { + ::lives_ok { has '+err2' => (isa => 'Bool'); - }, "or change the type completely"; + } "or change the type completely"; - ::ok ! ::exception { + ::lives_ok { 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'; - ::like ::exception { + ::throws_ok { 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 df0edb8..0ca57ed 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::Fatal; +use Test::Exception; { @@ -26,9 +26,9 @@ use Test::Fatal; is($foo->bar, 'BAR', '... got the expect value'); ok(!$foo->can('baz'), '... no baz method though'); - ok ! exception { + lives_ok { 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::Fatal; is($foo->bar, 'BAR', '... got the expect value'); ok(!$foo->can('baz'), '... no baz method though'); - ok ! exception { + lives_ok { 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::Fatal; is($foo->bar, 'BAR', '... got the expect value'); ok(!$foo->can('baz'), '... no baz method though'); - ok ! exception { + lives_ok { 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 5800e5e..1362868 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::Fatal; +use Test::Exception; use Moose::Meta::Role::Application::RoleSummation; use Moose::Meta::Role::Composite; @@ -48,9 +48,9 @@ use Moose::Meta::Role::Composite; Role::Baz ); - ok ! exception { + lives_ok { 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 ffd8441..322cd0a 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::Fatal; +use Test::Exception; 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 -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -42,7 +42,7 @@ ok exception { ] ) ); -}, '... this fails as expected'; +} '... this fails as expected'; # test no conflicts { @@ -56,9 +56,9 @@ ok exception { is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - ok ! exception { + lives_ok { 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 @@ ok exception { is($c->name, 'Role::Bar|Role::ExcludesFoo', '... got the composite role name'); - ok ! exception { + lives_ok { 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 -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -92,10 +92,10 @@ ok exception { ) ); -}, '... this fails as expected'; +} '... this fails as expected'; # test conflict with an "inherited" exclusion of an "inherited" role -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -104,6 +104,6 @@ ok exception { ] ) ); -}, '... 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 04f6140..e3f1beb 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::Fatal; +use Test::Exception; 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'); - ok ! exception { + lives_ok { 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'); - ok ! exception { + lives_ok { 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'); - ok ! exception { + lives_ok { 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'); - ok ! exception { + lives_ok { 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 570eb4e..b8f8af0 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::Fatal; +use Test::Exception; 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'); - ok ! exception { + lives_ok { 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 -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -64,10 +64,10 @@ ok exception { ] ) ); -}, '... this fails as expected'; +} '... this fails as expected'; # test complex conflict -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -78,10 +78,10 @@ ok exception { ] ) ); -}, '... this fails as expected'; +} '... this fails as expected'; # test simple conflict -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -90,6 +90,6 @@ ok exception { ] ) ); -}, '... 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 e03eec2..5183245 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::Fatal; +use Test::Exception; 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'); - ok ! exception { + lives_ok { 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'); - ok ! exception { + lives_ok { 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'); - ok ! exception { + lives_ok { 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'); - ok ! exception { + lives_ok { 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 cc5008d..4c428f2 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::Fatal; +use Test::Exception; 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'); - ok ! exception { + lives_ok { 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 -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -69,10 +69,10 @@ ok exception { ] ) ); -}, '... this fails as expected'; +} '... this fails as expected'; # test simple overrides w/ conflicts -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -81,11 +81,11 @@ ok exception { ] ) ); -}, '... this fails as expected'; +} '... this fails as expected'; # test simple overrides w/ conflicts -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -95,11 +95,11 @@ ok exception { ] ) ); -}, '... this fails as expected'; +} '... this fails as expected'; # test simple overrides w/ conflicts -ok exception { +dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( Moose::Meta::Role::Composite->new( roles => [ @@ -109,6 +109,6 @@ ok exception { ] ) ); -}, '... 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 bd043b9..5df6523 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::Fatal; +use Test::Exception; 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'); - ok ! exception { + lives_ok { 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 4ca7341..10d698c 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::Fatal; +use Test::Exception; 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. -ok (! exception ( +lives_ok( sub { my $builder_meta = Moose::Meta::Class->create( 'YATTA' => ( @@ -21,7 +21,7 @@ ok (! exception ( 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 4572adf..785d48f 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::Fatal; +use Test::Exception; { package Bomb; @@ -33,16 +33,16 @@ use Test::Fatal; package PracticalJoke; use Moose; - ::like ::exception { + ::throws_ok { 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'/; - ::like ::exception { + ::throws_ok { 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/045_role_compose_requires.t b/t/030_roles/045_role_compose_requires.t index 4ee7dd4..75f2e3b 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::Fatal; +use Test::Exception; { package My::Role1; @@ -54,11 +54,11 @@ use Test::Fatal; # roles they consume. { local $TODO = "role attributes don't satisfy method requirements"; - ok ! exception { package My::Test1; use Moose; with 'My::Role2'; }, + lives_ok { package My::Test1; use Moose; with 'My::Role2'; } 'role2(provides attribute) consumes role1'; } -ok ! exception { package My::Test2; use Moose; with 'My::Role3'; }, +lives_ok { 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 @@ ok ! exception { package My::Test2; use Moose; with 'My::Role3'; }, # assumption is false. -Vince Veselosky { local $TODO = "role attributes don't satisfy method requirements"; - ok ! exception { package My::Test3; use Moose; with 'My::Role4', 'My::Role1'; }, + lives_ok { 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"; - ok ! exception { package My::Test4; use Moose; with 'My::Role1', 'My::Role4'; }, + lives_ok { package My::Test4; use Moose; with 'My::Role1', 'My::Role4'; } 'class consumes role1, role4(provides attribute)'; } -ok ! exception { package My::Test5; use Moose; with 'My::Role5', 'My::Role1'; }, +lives_ok { package My::Test5; use Moose; with 'My::Role5', 'My::Role1'; } 'class consumes role5(provides method), role1'; -ok ! exception { package My::Test6; use Moose; with 'My::Role1', 'My::Role5'; }, +lives_ok { 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. -ok ! exception { +lives_ok { package My::Test7; use Moose; extends 'My::Base1'; with 'My::Role1'; -}, +} 'class extends base1(provides attribute), consumes role1'; -ok ! exception { +lives_ok { 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() -ok ! exception { +lives_ok { package My::Test9; use Moose; has 'test_output', is => 'rw'; with 'My::Role1'; -}, +} 'class provides attribute, consumes role1'; -ok ! exception { +lives_ok { 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. -ok ! exception { +lives_ok { package My::Test11; use Moose; with 'My::Role4'; with 'My::Role1'; -}, +} 'class consumes role4(provides attribute); consumes role1'; -ok exception { package My::Test12; use Moose; with 'My::Role1'; with 'My::Role4'; }, +dies_ok { package My::Test12; use Moose; with 'My::Role1'; with 'My::Role4'; } 'class consumes role1; consumes role4(provides attribute)'; -ok ! exception { +lives_ok { package My::Test13; use Moose; with 'My::Role5'; with 'My::Role1'; -}, +} 'class consumes role5(provides method); consumes role1'; -ok exception { package My::Test14; use Moose; with 'My::Role1'; with 'My::Role5'; }, +dies_ok { 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 355f1e7..46b3296 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::Fatal; +use Test::Exception; { package My::Role1; @@ -22,7 +22,7 @@ use Test::Fatal; is => 'ro', ); - ::like ::exception { with 'My::Role1' }, qr/attribute conflict.+My::Role2.+foo/, + ::throws_ok { 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 fc5274b..4bab997 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::Fatal; +use Test::Exception; my $FooRole; { @@ -66,7 +66,7 @@ my $QuuxRole; package Quux::Role; use Moose::Role; { our $TODO; local $TODO = "can't handle regexes yet"; - ::ok ! ::exception { + ::lives_ok { 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 367d0b8..c7c611e 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::Fatal; +use Test::Exception; use Scalar::Util (); @@ -118,7 +118,7 @@ is($string->validate(5), "This is not a string (5)", '... validated unsuccessfully (got error)'); -ok ! exception { Moose::Meta::Attribute->new('bob', isa => 'Spong') }, +lives_ok { 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; -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'; +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'; # Test some specific things that in the past did not work, # specifically weird variations on anon subtypes. @@ -186,7 +186,7 @@ like exception {$r->add_type_constraint(bless {}, 'SomeClass')}, qr/not a valid } { - like exception { subtype 'Foo' }, qr/cannot consist solely of a name/, + throws_ok { subtype 'Foo' } qr/cannot consist solely of a name/, 'Cannot call subtype with a single string argument'; } diff --git a/t/040_type_constraints/005_util_type_coercion.t b/t/040_type_constraints/005_util_type_coercion.t index c60cf5b..49f9069 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::Fatal; +use Test::Exception; 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') }; -ok ! exception { +lives_ok { 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/007_util_more_type_coercion.t b/t/040_type_constraints/007_util_more_type_coercion.t index e8a1044..c24d6bc 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::Fatal; +use Test::Exception; { @@ -37,9 +37,9 @@ use Test::Fatal; # try with arrays - ok ! exception { + lives_ok { $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::Fatal; # try with hash - ok ! exception { + lives_ok { $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::Fatal; '... got the right hash value of the header'); ok(!defined($engine->header->array), '... no array value set'); - ok exception { + dies_ok { $engine->header("Foo"); - }, '... dies with the wrong type, even after coercion'; + } '... dies with the wrong type, even after coercion'; - ok ! exception { + lives_ok { $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::Fatal; ok(!defined($engine->header->array), '... no array value set'); } -ok exception { +dies_ok { Engine->new(header => 'Foo'); -}, '... dies correctly with bad params'; +} '... dies correctly with bad params'; -ok exception { +dies_ok { 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 @@ ok exception { isa_ok($from_href, 'HTTPHeader', 'assert_coerce from href to HTTPHeader'); is_deeply($from_href->hash, { a => 1 }, '...and has the right guts'); - like exception { $tc->assert_coerce('total garbage') }, + throws_ok { $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/009_union_types_and_coercions.t b/t/040_type_constraints/009_union_types_and_coercions.t index a960ea4..e7071f2 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::Fatal; +use Test::Exception; 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'); - ok ! exception { + lives_ok { $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) ...'; - ok ! exception { + lives_ok { $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) ...'); - ok ! exception { + lives_ok { $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; - ok ! exception { $foo = Foo->new( carray => 1 ) }, + lives_ok { $foo = Foo->new( carray => 1 ) } 'Can pass non-ref value for carray'; is_deeply( $foo->carray, [1], 'carray was coerced to an array ref' ); - like exception { Foo->new( carray => {} ) }, + throws_ok { 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 2a8b22d..7b86046 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::Fatal; +use Test::Exception; use Scalar::Util qw(refaddr); BEGIN { @@ -13,9 +13,9 @@ BEGIN { # subtype 'aliasing' ... -ok ! exception { +lives_ok { 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/015_enum.t b/t/040_type_constraints/015_enum.t index ae6bef6..92c0062 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::Fatal; +use Test::Exception; 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 -like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'ZeroValues', values => []) }, +throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'ZeroValues', values => []) } qr/You must have at least two values to enumerate through/; -like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'OneValue', values => [ 'a' ]) }, +throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'OneValue', values => [ 'a' ]) } qr/You must have at least two values to enumerate through/; -like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'ReferenceInEnum', values => [ 'a', {} ]) }, +throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'ReferenceInEnum', values => [ 'a', {} ]) } qr/Enum values must be strings, not 'HASH\(0x\w+\)'/; -like exception { Moose::Meta::TypeConstraint::Enum->new(name => 'UndefInEnum', values => [ 'a', undef ]) }, +throws_ok { Moose::Meta::TypeConstraint::Enum->new(name => 'UndefInEnum', values => [ 'a', undef ]) } qr/Enum values must be strings, not undef/; -like exception { +throws_ok { package Foo; use Moose; use Moose::Util::TypeConstraints; @@ -85,7 +85,7 @@ like exception { 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 e88dd76..3c6971f 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::Fatal; +use Test::Exception; BEGIN { use_ok("Moose::Util::TypeConstraints"); } -ok ! exception { +lives_ok { 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 @@ ok ! exception { ok( !$t->is_subtype_of("ThisTypeDoesNotExist"), "not a subtype of a non existant type" ); } -ok ! exception { +lives_ok { 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 @@ ok ! exception { ok(!$t->check({ one => "ONE", two => "TWO" }), '... validated it correctly'); } -ok ! exception { +lives_ok { subtype 'MyNonSpecialHash' => as "HashRef" => where { keys %$_ == 3 }; @@ -114,10 +114,10 @@ ok ! exception { 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'; - like exception { + throws_ok sub { 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 12d8226..b76ae7c 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::Fatal; +use Test::Exception; BEGIN { use_ok("Moose::Util::TypeConstraints"); } -ok ! exception { +lives_ok { 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 @@ ok ! exception { ok(!$t->check(1), '... validated it correctly'); } -ok ! exception { +lives_ok { subtype 'MyCollectionsExtended' => as 'ArrayRef|HashRef' => where { @@ -43,7 +43,7 @@ ok ! exception { } 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 d1540c6..c4969e5 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::Fatal; +use Test::Exception; BEGIN { use_ok("Moose::Util::TypeConstraints"); use_ok('Moose::Meta::TypeConstraint::Parameterized'); } -ok ! exception { +lives_ok { 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'; -ok ! exception { +lives_ok { subtype 'Trihash' => as 'AlphaKeyHash' => where { keys(%$_) == 3 }; -}, '... created the subtype special okay'; +} '... created the subtype special okay'; -ok ! exception { +lives_ok { 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'); -ok exception { +dies_ok { 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'; -ok exception { +dies_ok { 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 fd2c29a..84de514 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::Fatal; +use Test::Exception; BEGIN { use_ok("Moose::Util::TypeConstraints"); @@ -26,11 +26,11 @@ BEGIN { subtype 'MyList' => as 'Object' => where { $_->isa('MyList') }; -ok ! exception { +lives_ok { 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? -ok ! exception { +lives_ok { 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 420c3bd..f91ddf5 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::Fatal; +use Test::Exception; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -24,8 +24,8 @@ BEGIN { } -ok ! exception { class_type 'Beep' }, 'class_type keywork works'; -ok ! exception { class_type('Boop', message { "${_} is not a Boop" }) }, +lives_ok { class_type 'Beep' } 'class_type keywork works'; +lives_ok { 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 e301669..4974e09 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::Fatal; +use Test::Exception; 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'))); } -ok ! exception { +lives_ok { Foo->new(arr => [], bar => Bar->new); -}, '... Bar->new isa Bar'; +} '... Bar->new isa Bar'; -ok exception { +dies_ok { Foo->new(arr => [], bar => undef); -}, '... undef isnta Bar'; +} '... undef isnta Bar'; -ok ! exception { +lives_ok { Foo->new(arr => [], maybe_bar => Bar->new); -}, '... Bar->new isa maybe(Bar)'; +} '... Bar->new isa maybe(Bar)'; -ok ! exception { +lives_ok { Foo->new(arr => [], maybe_bar => undef); -}, '... undef isa maybe(Bar)'; +} '... undef isa maybe(Bar)'; -ok exception { +dies_ok { Foo->new(arr => [], maybe_bar => 1); -}, '... 1 isnta maybe(Bar)'; +} '... 1 isnta maybe(Bar)'; -ok ! exception { +lives_ok { Foo->new(arr => []); -}, '... it worked!'; +} '... it worked!'; -ok ! exception { +lives_ok { Foo->new(arr => undef); -}, '... it worked!'; +} '... it worked!'; -ok exception { +dies_ok { Foo->new(arr => 100); -}, '... failed the type check'; +} '... failed the type check'; -ok exception { +dies_ok { 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 ("")'; -like exception { $obj->Maybe_Int("") },, +throws_ok sub { $obj->Maybe_Int("") }, qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("")'; ok !$Maybe_Int->check("a") => 'failed ("a")'; -like exception { $obj->Maybe_Int("a") },, +throws_ok sub { $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 8a9023a..f570474 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::Fatal; +use Test::Exception; { package Animal; @@ -25,35 +25,35 @@ use Test::Fatal; ); } -ok ! exception { my $goat = Animal->new( leg_count => 4 ) }, +lives_ok { my $goat = Animal->new( leg_count => 4 ) } '... no errors thrown, value is good'; -ok ! exception { my $spider = Animal->new( leg_count => 8 ) }, +lives_ok { my $spider = Animal->new( leg_count => 8 ) } '... no errors thrown, value is good'; -like exception { my $fern = Animal->new( leg_count => 0 ) }, +throws_ok { my $fern = Animal->new( leg_count => 0 ) } qr/This number \(0\) is not less than ten!/, 'gave custom supertype error message on new'; -like exception { my $centipede = Animal->new( leg_count => 30 ) }, +throws_ok { 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; -ok ! exception { $chimera = Animal->new( leg_count => 4 ) }, +lives_ok { $chimera = Animal->new( leg_count => 4 ) } '... no errors thrown, value is good'; -like exception { $chimera->leg_count(0) }, +throws_ok { $chimera->leg_count(0) } qr/This number \(0\) is not less than ten!/, 'gave custom supertype error message on set to 0'; -like exception { $chimera->leg_count(16) }, +throws_ok { $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' ); -like exception { $gimp->leg_count }, +throws_ok { $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 b4501eb..1c2e7ee 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::Fatal; +use Test::Exception; { @@ -70,41 +70,41 @@ ok(String('Foo'), '... "Foo" is a String'); my $foo = Foo->new; -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'; +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'; # the lazy tests -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'; +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'; 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 b048538..163bfca 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::Fatal; +use Test::Exception; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -32,7 +32,7 @@ BEGIN { } -ok ! exception { role_type('Boop', message { "${_} is not a Boop" }) }, +lives_ok { 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/027_parameterize_from.t b/t/040_type_constraints/027_parameterize_from.t index f815745..beab5b8 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::Fatal; +use Test::Exception; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -43,38 +43,38 @@ isa_ok $params, 'Test::Moose::Meta::TypeConstraint::Parameterizable' => # test parameterizable -ok ! exception { +lives_ok sub { $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 -ok ! exception { +lives_ok sub { $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'; -like exception { +throws_ok sub { $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 -ok ! exception { +lives_ok sub { $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'; -like exception { +throws_ok sub { $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 b093d12..cbec2e2 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::Fatal; +use Test::Exception; BEGIN { use_ok('Moose::Util::TypeConstraints'); @@ -17,11 +17,11 @@ BEGIN { subtype 'MySubType' => as 'Int' => where { 1 }; } -like exception { +throws_ok { 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 dd50b65..ec9a156 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::Fatal; +use Test::Exception; 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 ); } -like exception { +throws_ok { 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\)/; -ok ! exception { +lives_ok { Quux->new(age => (bless {}, 'Positive')); }; @@ -111,11 +111,11 @@ eval " use Moose; "; -like exception { +throws_ok { 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\)/; -ok ! exception { +lives_ok { Quux->new(age => Positive->new) }; @@ -132,11 +132,11 @@ class_type 'Negative' => message { "$_ is not a Negative Nancy" }; ); } -like exception { +throws_ok { 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 /; -ok ! exception { +lives_ok { 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 dafade2..a55cf04 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::Fatal; +use Test::Exception; use Moose::Meta::TypeConstraint; use Moose::Util::TypeConstraints; @@ -29,14 +29,14 @@ TODO: } } -ok ! exception { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) }, +lives_ok { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) } 'Type names can contain periods and colons'; -like exception { subtype 'Foo-Baz' => as 'Item' }, +throws_ok { subtype 'Foo-Baz' => as 'Item' } qr/contains invalid characters/, 'Type names cannot contain a dash (via subtype sugar)'; -ok ! exception { subtype 'Foo.Bar::Baz' => as 'Item' }, +lives_ok { 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 838c2e8..5682793 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::Fatal; +use Test::Exception; { @@ -62,21 +62,21 @@ use Test::Fatal; } # try giving it a duck -ok ! exception { DucktypeTest->new( duck => Duck->new ) }, 'the Duck lives okay'; +lives_ok { DucktypeTest->new( duck => Duck->new ) } 'the Duck lives okay'; # try giving it a swan which is like a duck, but not close enough -like exception { DucktypeTest->new( duck => Swan->new ) }, +throws_ok { DucktypeTest->new( duck => Swan->new ) } qr/Swan is missing methods 'quack'/, "the Swan doesn't quack"; # try giving it a rubber RubberDuckey -ok ! exception { DucktypeTest->new( swan => Swan->new ) }, 'but a Swan can honk'; +lives_ok { DucktypeTest->new( swan => Swan->new ) } 'but a Swan can honk'; # try giving it a rubber RubberDuckey -ok ! exception { DucktypeTest->new( duck => RubberDuck->new ) }, +lives_ok { DucktypeTest->new( duck => RubberDuck->new ) } 'the RubberDuck lives okay'; # try with the other constraint form -ok ! exception { DucktypeTest->new( other_swan => Swan->new ) }, 'but a Swan can honk'; +lives_ok { DucktypeTest->new( other_swan => Swan->new ) } 'but a Swan can honk'; done_testing; diff --git a/t/040_type_constraints/036_match_type_operator.t b/t/040_type_constraints/036_match_type_operator.t index 02d92e0..fd5cc88 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::Fatal; +use Test::Exception; 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'); -ok exception { +dies_ok { 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') }; } -like exception { +throws_ok { 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/002_custom_attr_meta_as_role.t b/t/050_metaclasses/002_custom_attr_meta_as_role.t index e516060..55ee9c6 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::Fatal; +use Test::Exception; -ok ! exception { +lives_ok { package MooseX::Attribute::Test; use Moose::Role; -}, 'creating custom attribute "metarole" is okay'; +} 'creating custom attribute "metarole" is okay'; -ok ! exception { +lives_ok { 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/012_moose_exporter.t b/t/050_metaclasses/012_moose_exporter.t index f00e9a8..e37669d 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::Fatal; +use Test::Exception; use Test::Requires { 'Test::Output' => '0.01', # skip all if not installed @@ -197,9 +197,8 @@ use Test::Requires { use Moose (); - my $error; - ::ok($error = ::exception - { + ::dies_ok( + sub { Moose::Exporter->setup_import_methods( also => [ 'Moose', 'MooseX::CircularAlso' ], ); @@ -208,7 +207,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' ); @@ -219,9 +218,8 @@ use Test::Requires { use Moose (); - my $error; - ::ok($error = ::exception - { + ::dies_ok( + sub { Moose::Exporter->setup_import_methods( also => [ 'NoSuchThing' ], ); @@ -230,7 +228,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' ); @@ -241,9 +239,8 @@ use Test::Requires { use Moose (); - my $error; - ::ok($error = ::exception - { + ::dies_ok( + sub { Moose::Exporter->setup_import_methods( also => [ 'Moose::Meta::Method' ], ); @@ -252,7 +249,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 7823237..b47cea4 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::Fatal; +use Test::Exception; { package My::SimpleTrait; @@ -167,10 +167,9 @@ is( Role::Foo->meta()->simple(), 5, { require Moose::Util::TypeConstraints; - 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/, + 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/, '... and error provides a useful explanation' ); } @@ -199,10 +198,10 @@ is( Foo::Subclass->meta()->attr2(), 'something', has an_attr => ( is => 'ro' ); } -ok ! exception { +lives_ok { my $instance = Class::WithAlreadyPresentTrait->new( an_attr => 'value' ); is( $instance->an_attr, 'value', 'Can get value' ); -}, +} 'Can create instance and access attributes'; { @@ -216,10 +215,10 @@ ok ! exception { has an_attr => ( is => 'ro' ); } -ok ! exception { +lives_ok { 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 18d53fb..06437ac 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::Fatal; +use Test::Exception; # 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::Fatal; MooseAlike1->import(); - ::ok ! ::exception { has( 'size', is => 'bare' ) }, - 'has was exported via MooseAlike1'; + ::lives_ok( sub { has( 'size', is => 'bare' ) }, + 'has was exported via MooseAlike1' ); MooseAlike1->unimport(); } @@ -68,8 +68,8 @@ isa_ok( Foo->meta(), 'Moose::Meta::Class' ); MooseAlike2->import(); - ::ok ! ::exception { has( 'size', is => 'bare' ) }, - 'has was exported via MooseAlike2'; + ::lives_ok( sub { 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 17dd7be..6d80c50 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::Fatal; +use Test::Exception; use Moose::Util::MetaRole; @@ -580,10 +580,10 @@ use Moose::Util::MetaRole; } } -ok ! exception { +lives_ok { 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/018_throw_error.t b/t/050_metaclasses/018_throw_error.t index c706c9f..5988905 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::Fatal; +use Test::Exception; { @@ -119,7 +119,7 @@ sub create_error { ); use Moose; - ::ok ::exception { extends 'Baz::Sub' }, 'error_class is included in metaclass compatibility checks'; + ::dies_ok { 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; - ::ok ! ::exception { extends 'Foo::Sub' }, 'error_class differs by role so incompat is handled'; + ::lives_ok { 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 61c9c75..70bddd6 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::Fatal; +use Test::Exception; { package HasFoo; @@ -30,29 +30,29 @@ use Test::Fatal; package main; my $anon; -ok ! exception { +lives_ok { $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' ); -ok exception { +dies_ok { $anon = My::Metaclass->create_anon_class(); -}, 'failed to create anon class without required attr'; +} 'failed to create anon class without required attr'; my $meta; -ok ! exception { +lives_ok { $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' ); -ok exception { +dies_ok { $meta = My::Metaclass->initialize( 'Class::Name2' ); -}, 'failed to initialize a class without required attr'; +} 'failed to initialize a class without required attr'; -ok ! exception { +lives_ok { eval qq{ package Class::Name3; use metaclass 'My::Metaclass' => ( @@ -61,28 +61,28 @@ ok ! exception { 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' ); -ok exception { +dies_ok { 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? -ok exception { +dies_ok { 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 c84f6d0..6c8f5e2 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::Fatal; +use Test::Exception; -ok ! exception { +lives_and { 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"; -ok ! exception { +lives_and { 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 5b24c44..ed12d4c 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::Fatal; +use Test::Exception; -ok ! exception { +lives_ok { 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 02cec56..2ded6e4 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::Fatal; +use Test::Exception; use Moose::Util::MetaRole; @@ -583,10 +583,10 @@ use Moose::Util::MetaRole; } } -ok ! exception { +lives_ok { 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/052_metaclass_compat.t b/t/050_metaclasses/052_metaclass_compat.t index 33ed309..f29db50 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::Fatal; +use Test::Exception; 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; - ::ok ! ::exception { $meta->superclasses('Foo2') }, "can set superclasses once"; + ::lives_ok { $meta->superclasses('Foo2') } "can set superclasses once"; ::isa_ok($meta, Foo2->meta->meta->name); - ::ok ! ::exception { $meta->superclasses('Bar2') }, "can still set superclasses"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; + ::lives_ok { $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; - ::ok ! ::exception { $meta->superclasses('Foo2') }, "can set superclasses once"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->superclasses('Bar3') }, "can still set superclasses"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; + ::lives_ok { $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; - ::ok ! ::exception { $meta->superclasses('Foo2') }, "can set superclasses once"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->superclasses('Quux3') }, "can still set superclasses"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; + ::lives_ok { $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; - ::ok ! ::exception { $meta->superclasses('Foo4') }, "can set superclasses once"; + ::lives_ok { $meta->superclasses('Foo4') } "can set superclasses once"; ::isa_ok($meta, Foo4->meta->_get_mutable_metaclass_name); - ::ok ! ::exception { $meta->superclasses('Bar4') }, "can still set superclasses"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; + ::lives_ok { $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; - ::ok ! ::exception { $meta->superclasses('Foo4') }, "can set superclasses once"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->superclasses('Bar5') }, "can still set superclasses"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; + ::lives_ok { $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; - ::ok ! ::exception { $meta->superclasses('Foo4') }, "can set superclasses once"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->superclasses('Quux5') }, "can still set superclasses"; + ::lives_ok { $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"); - ::ok ! ::exception { $meta->make_immutable }, "can still make immutable"; + ::lives_ok { $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'); - ::ok ! ::exception { + ::lives_ok { extends @superclasses; - }, 'MI extends after_generated_methods with metaclass roles'; - ::ok ! ::exception { + } 'MI extends after_generated_methods with metaclass roles'; + ::lives_ok { 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'); - ::like ::exception { + ::throws_ok { extends @superclasses; - }, qr/compat.*pristine/, + } qr/compat.*pristine/, 'unsafe MI extends after_generated_methods with metaclass roles'; - ::like ::exception { + ::throws_ok { 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']; - ::ok ! ::exception { extends 'Foo7' }, "role reconciliation works"; + ::lives_ok { extends 'Foo7' } "role reconciliation works"; } { package Bar72; # in an external file use Moose -traits => ['Bar7::Meta::Trait2']; - ::ok ! ::exception { extends 'Foo7' }, "role reconciliation works"; + ::lives_ok { 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 29aca77..6190faa 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::Fatal; +use Test::Exception; { package Foo::Meta::Constructor1; @@ -40,7 +40,7 @@ use Test::Fatal; for => __PACKAGE__, class_metaroles => { constructor => ['Foo::Meta::Constructor2'] }, ); - ::ok ! ::exception { extends 'Foo::Sub' }, "doesn't try to fix if nothing is needed"; + ::lives_ok { 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 e4bb9a8..bb35eb0 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::Fatal; +use Test::Exception; 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' }; } -like exception { +throws_ok { 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'; } -like exception { +throws_ok { 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/060_compat/001_module_refresh_compat.t b/t/060_compat/001_module_refresh_compat.t index 7d23dea..03553f9 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::Fatal; +use Test::Exception; use File::Spec; use File::Temp 'tempdir'; @@ -28,9 +28,9 @@ do { is($_->meta->name, $_, '... initialized the meta correctly'); - ok ! exception { + lives_ok { 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; } -ok ! exception { +lives_ok { 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/003_foreign_inheritence.t b/t/060_compat/003_foreign_inheritence.t index 51e739d..0fdcb9b 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::Fatal; +use Test::Exception; { @@ -79,14 +79,14 @@ is( $foo_moose->no_moose, 'Elk', is( $foo_moose->moose, 'Foo', '... got the right value from the Foo::Moose method' ); -ok ! exception { +lives_ok { Old::Bucket::Nose->meta->make_immutable( debug => 0 ); -}, +} 'Immutability on Moose class extending Class::MOP class ok'; -ok ! exception { +lives_ok { 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 6fbd85b..78fe330 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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::Fatal; - ok ! exception { + use Test::Exception; + lives_ok { 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 8a3392f..570ce30 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::Fatal; +use Test::Exception; use Test::Moose; { @@ -31,7 +31,7 @@ use Test::Moose; for => __PACKAGE__, class_metaroles => { class => ['Foo::Role', 'Bar::Role'] }, ); - ::ok ! ::exception { extends 'Parent' }; + ::lives_ok { 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 8b7c65d..3f87d46 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::Fatal; +use Test::Exception; 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' ); - like exception { $obj->count(22) }, + throws_ok { $obj->count(22) } qr/Cannot call count with any arguments/, 'throws an error when passing an argument passed to count'; - ok ! exception { $obj->push( 1, 2, 3 ) }, + lives_ok { $obj->push( 1, 2, 3 ) } 'pushed three new values and lived'; - ok ! exception { $obj->push() }, 'call to push without arguments lives'; + lives_ok { $obj->push() } 'call to push without arguments lives'; - ok ! exception { + lives_and { 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' ); - ok ! exception { $obj->unshift() }, + lives_ok { $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' ); - like exception { $obj->pop(42) }, + throws_ok { $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' ); - like exception { $obj->shift(42) }, + throws_ok { $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' ); - like exception { $obj->elements(22) }, + throws_ok { $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' ); - like exception { $obj->get() }, + throws_ok { $obj->get() } qr/Cannot call get without at least 1 argument/, 'throws an error when get is called without any arguments'; - like exception { $obj->get( {} ) }, + throws_ok { $obj->get( {} ) } qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument'; - like exception { $obj->get(2.2) }, + throws_ok { $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'; - like exception { $obj->get('foo') }, + throws_ok { $obj->get('foo') } qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument'; - like exception { $obj->get_curried(2) }, + throws_ok { $obj->get_curried(2) } qr/Cannot call get with more than 1 argument/, 'throws an error when get_curried is called with an argument'; - ok ! exception { + lives_and { 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' ); - like exception { $obj->set( 1, 99, 42 ) }, + throws_ok { $obj->set( 1, 99, 42 ) } qr/Cannot call set with more than 2 arguments/, 'throws an error when set is called with three arguments'; - ok ! exception { $obj->set_curried_1(99) }, 'set_curried_1 lives'; + lives_ok { $obj->set_curried_1(99) } 'set_curried_1 lives'; is( $obj->get(1), 99, 'get value at index 1 returns new value' ); - like exception { $obj->set_curried_1( 99, 42 ) }, + throws_ok { $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'; - ok ! exception { $obj->set_curried_2 }, 'set_curried_2 lives'; + lives_ok { $obj->set_curried_2 } 'set_curried_2 lives'; is( $obj->get(1), 98, 'get value at index 1 returns new value' ); - like exception { $obj->set_curried_2(42) }, + throws_ok { $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' ); - ok ! exception { + lives_and { 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' ); - like exception { $obj->accessor( 1, 96, 42 ) }, + throws_ok { $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' ); - ok ! exception { $obj->accessor_curried_1(95) }, + lives_ok { $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' ); - like exception { $obj->accessor_curried_1( 96, 42 ) }, + throws_ok { $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'; - ok ! exception { $obj->accessor_curried_2 }, + lives_ok { $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' ); - like exception { $obj->accessor_curried_2(42) }, + throws_ok { $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'; - ok ! exception { $obj->clear }, 'clear lives'; + lives_ok { $obj->clear } 'clear lives'; ok( $obj->is_empty, 'values is empty after call to clear' ); $obj->set( 0 => 42 ); - like exception { $obj->clear(50) }, + throws_ok { $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' ); - like exception { $obj->is_empty(50) }, + throws_ok { $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' ); - ok ! exception { + lives_and { 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' ); - like exception { $obj->delete( 2, 3 ) }, + throws_ok { $obj->delete( 2, 3 ) } qr/Cannot call delete with more than 1 argument/, 'throws an error when delete is called with two arguments'; - ok ! exception { $obj->delete_curried }, 'delete_curried lives'; + lives_ok { $obj->delete_curried } 'delete_curried lives'; is_deeply( $obj->_values, [ 1, 42 ], 'delete removed the specified element' ); - like exception { $obj->delete_curried(2) }, + throws_ok { $obj->delete_curried(2) } qr/Cannot call delete with more than 1 argument/, 'throws an error when delete_curried is called with one argument'; - ok ! exception { $obj->insert( 1, 21 ) }, 'insert lives'; + lives_ok { $obj->insert( 1, 21 ) } 'insert lives'; is_deeply( $obj->_values, [ 1, 21, 42 ], 'insert added the specified element' ); - like exception { $obj->insert( 1, 22, 44 ) }, + throws_ok { $obj->insert( 1, 22, 44 ) } qr/Cannot call insert with more than 2 arguments/, 'throws an error when insert is called with three arguments'; - ok ! exception { + lives_and { 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' ); - ok ! exception { + lives_and { 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' ); - like exception { $obj->splice() }, + throws_ok { $obj->splice() } qr/Cannot call splice without at least 1 argument/, 'throws an error when splice is called with no arguments'; - like exception { $obj->splice( 1, 'foo', ) }, + throws_ok { $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'; - ok ! exception { $obj->splice_curried_1( 2, 101 ) }, + lives_ok { $obj->splice_curried_1( 2, 101 ) } 'splice_curried_1 lives'; is_deeply( @@ -399,14 +399,14 @@ sub run_tests { 'splice added the specified elements' ); - ok ! exception { $obj->splice_curried_2(102) }, 'splice_curried_2 lives'; + lives_ok { $obj->splice_curried_2(102) } 'splice_curried_2 lives'; is_deeply( $obj->_values, [ 1, 102 ], 'splice added the specified elements' ); - ok ! exception { $obj->splice_curried_all }, 'splice_curried_all lives'; + lives_ok { $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' ); - like exception { $obj->sort(1) }, + throws_ok { $obj->sort(1) } qr/The argument passed to sort must be a code reference/, 'throws an error when passing a non coderef to sort'; - like exception { + throws_ok { $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' ); - like exception { + throws_ok { $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'; - like exception { + throws_ok { $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' ); - like exception { $obj->sort_in_place_curried(27) }, + throws_ok { $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' ); - like exception { $obj->map }, + throws_ok { $obj->map } qr/Cannot call map without at least 1 argument/, 'throws an error when passing no arguments to map'; - like exception { + throws_ok { $obj->map( sub { }, 2 ); - }, + } qr/Cannot call map with more than 1 argument/, 'throws an error when passing two arguments to map'; - like exception { $obj->map( {} ) }, + throws_ok { $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' ); - like exception { + throws_ok { $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' ); - like exception { $obj->grep }, + throws_ok { $obj->grep } qr/Cannot call grep without at least 1 argument/, 'throws an error when passing no arguments to grep'; - like exception { + throws_ok { $obj->grep( sub { }, 2 ); - }, + } qr/Cannot call grep with more than 1 argument/, 'throws an error when passing two arguments to grep'; - like exception { $obj->grep( {} ) }, + throws_ok { $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' ); - like exception { + throws_ok { $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' ); - like exception { $obj->first }, + throws_ok { $obj->first } qr/Cannot call first without at least 1 argument/, 'throws an error when passing no arguments to first'; - like exception { + throws_ok { $obj->first( sub { }, 2 ); - }, + } qr/Cannot call first with more than 1 argument/, 'throws an error when passing two arguments to first'; - like exception { $obj->first( {} ) }, + throws_ok { $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' ); - like exception { + throws_ok { $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' ); - like exception { $obj->join }, + throws_ok { $obj->join } qr/Cannot call join without at least 1 argument/, 'throws an error when passing no arguments to join'; - like exception { $obj->join( '-', 2 ) }, + throws_ok { $obj->join( '-', 2 ) } qr/Cannot call join with more than 1 argument/, 'throws an error when passing two arguments to join'; - like exception { $obj->join( {} ) }, + throws_ok { $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)' ); - like exception { $obj->shuffle(2) }, + throws_ok { $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)' ); - like exception { $obj->uniq(2) }, + throws_ok { $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' ); - like exception { $obj->reduce }, + throws_ok { $obj->reduce } qr/Cannot call reduce without at least 1 argument/, 'throws an error when passing no arguments to reduce'; - like exception { + throws_ok { $obj->reduce( sub { }, 2 ); - }, + } qr/Cannot call reduce with more than 1 argument/, 'throws an error when passing two arguments to reduce'; - like exception { $obj->reduce( {} ) }, + throws_ok { $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' ); - like exception { + throws_ok { $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' ); - like exception { $obj->natatime( {} ) }, + throws_ok { $obj->natatime( {} ) } qr/The n value passed to natatime must be an integer/, 'throws an error when passing a non integer to natatime'; - like exception { $obj->natatime( 2, {} ) }, + throws_ok { $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' ); - like exception { $obj->natatime_curried( {} ) }, + throws_ok { $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 65ba399..5daa36a 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::Fatal; +use Test::Exception; { use Moose::Util::TypeConstraints; @@ -75,7 +75,7 @@ my $foo = Foo->new; $foo->array_int( [] ); is_deeply( $foo->array_int, [], "array_int - correct contents" ); - ok exception { $foo->push_array_int('foo') }, + dies_ok { $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; } { - ok exception { $foo->push_a1('foo') }, "a1 - can't push onto undef"; + dies_ok { $foo->push_a1('foo') } "a1 - can't push onto undef"; $foo->a1( [] ); is_deeply( $foo->a1, [], "a1 - correct contents" ); - ok exception { $foo->push_a1('foo') }, "a1 - can't push wrong type"; + dies_ok { $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; } { - ok exception { $foo->push_a2('foo') }, "a2 - can't push onto undef"; + dies_ok { $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" ); - ok exception { $foo->push_a2('bar') }, "a2 - can't push more than one element"; + dies_ok { $foo->push_a2('bar') } "a2 - can't push more than one element"; is_deeply( $foo->a2, ['foo'], "a2 - correct contents" ); } { - ok exception { $foo->push_a3(1) }, "a3 - can't push onto undef"; + dies_ok { $foo->push_a3(1) } "a3 - can't push onto undef"; $foo->a3( [] ); is_deeply( $foo->a3, [], "a3 - correct contents" ); - ok exception { $foo->push_a3('foo') }, "a3 - can't push non-int"; + dies_ok { $foo->push_a3('foo') } "a3 - can't push non-int"; - ok exception { $foo->push_a3(100) }, + dies_ok { $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" ); - ok exception { $foo->push_a3(100) }, + dies_ok { $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/013_array_coerce.t b/t/070_native_traits/013_array_coerce.t index ef2f85f..8145157 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::Fatal; +use Test::Exception; { diff --git a/t/070_native_traits/020_trait_bool.t b/t/070_native_traits/020_trait_bool.t index e49a25a..5443020 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::Fatal; +use Test::Exception; 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' ); - like exception { $obj->illuminate(1) }, + throws_ok { $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' ); - like exception { $obj->darken(1) }, + throws_ok { $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' ); - like exception { $obj->flip_switch(1) }, + throws_ok { $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/040_trait_counter.t b/t/070_native_traits/040_trait_counter.t index ac98bc8..ae7e816 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::Fatal; +use Test::Exception; 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)' ); - like exception { $obj->inc_counter( 1, 2 ) }, + throws_ok { $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' ); - like exception { $obj->dec_counter( 1, 2 ) }, + throws_ok { $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' ); - like exception { $obj->reset_counter(2) }, + throws_ok { $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' ); - like exception { $obj->set_counter( 1, 2 ) }, + throws_ok { $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 8df19a0..e9ea77c 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::Fatal; +use Test::Exception; 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' ); - ok ! exception { + lives_and { 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' ); - ok ! exception { + lives_ok { $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' ); - ok ! exception { + lives_ok { $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" ); - ok ! exception { + lives_and { is( scalar $obj->delete_option('bar'), 'baz', 'delete returns deleted value' ); - }, + } '... deleted the option okay'; - ok ! exception { + lives_ok { 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" ); - ok ! exception { + lives_ok { $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' ); - ok ! exception { + lives_ok { $class->new( options => { foo => 'BAR' } ); - }, + } '... good constructor params'; - ok exception { + dies_ok { $obj->set_option( bar => {} ); - }, + } '... could not add a hash ref where an string is expected'; - ok exception { + dies_ok { $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 5d7e420..8949a92 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::Fatal; +use Test::Exception; { use Moose::Util::TypeConstraints; @@ -66,7 +66,7 @@ my $foo = Foo->new; $foo->hash_int( {} ); is_deeply( $foo->hash_int, {}, "hash_int - correct contents" ); - ok exception { $foo->set_hash_int( x => 'foo' ) }, + dies_ok { $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; } { - ok exception { $foo->set_h1('foo') }, "h1 - can't set onto undef"; + dies_ok { $foo->set_h1('foo') } "h1 - can't set onto undef"; $foo->h1( {} ); is_deeply( $foo->h1, {}, "h1 - correct contents" ); - ok exception { $foo->set_h1( x => 'foo' ) }, "h1 - can't set wrong type"; + dies_ok { $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; } { - ok exception { $foo->set_h2('foo') }, "h2 - can't set onto undef"; + dies_ok { $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" ); - ok exception { $foo->set_h2( y => 'bar' ) }, + dies_ok { $foo->set_h2( y => 'bar' ) } "h2 - can't set more than one element"; is_deeply( $foo->h2, { x => 'foo' }, "h2 - correct contents" ); } { - ok exception { $foo->set_h3(1) }, "h3 - can't set onto undef"; + dies_ok { $foo->set_h3(1) } "h3 - can't set onto undef"; $foo->h3( {} ); is_deeply( $foo->h3, {}, "h3 - correct contents" ); - ok exception { $foo->set_h3( x => 'foo' ) }, "h3 - can't set non-int"; + dies_ok { $foo->set_h3( x => 'foo' ) } "h3 - can't set non-int"; - ok exception { $foo->set_h3( x => 100 ) }, + dies_ok { $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" ); - ok exception { $foo->set_h3( x => 100 ) }, + dies_ok { $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/060_trait_number.t b/t/070_native_traits/060_trait_number.t index 64d0b17..6b24631 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::Fatal; +use Test::Exception; use Test::More; use Test::Moose; @@ -87,7 +87,7 @@ sub run_tests { is( $obj->integer, 15, 'Add ten for fithteen' ); - like exception { $obj->add( 10, 2 ) }, + throws_ok { $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' ); - like exception { $obj->sub( 10, 2 ) }, + throws_ok { $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' ); - like exception { $obj->set( 10, 2 ) }, + throws_ok { $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' ); - like exception { $obj->div( 10, 2 ) }, + throws_ok { $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' ); - like exception { $obj->mul( 10, 2 ) }, + throws_ok { $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' ); - like exception { $obj->mod( 10, 2 ) }, + throws_ok { $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' ); - like exception { $obj->abs(10) }, + throws_ok { $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 e6ab822..c6b9c63 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::Fatal; +use Test::Exception; use Test::Moose; { @@ -92,28 +92,28 @@ sub run_tests { $obj->_string('a'); is( $obj->length, 1, 'length returns 1 for new string' ); - like exception { $obj->length(42) }, + throws_ok { $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' ); - like exception { $obj->inc(42) }, + throws_ok { $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' ); - like exception { $obj->append( 'foo', 2 ) }, + throws_ok { $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' ); - like exception { $obj->append_curried('foo') }, + throws_ok { $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' ); - like exception { $obj->chomp(42) }, + throws_ok { $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' ); - like exception { $obj->chop(42) }, + throws_ok { $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' ); - like exception { $obj->replace( {}, 'x' ) }, + throws_ok { $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'; - like exception { $obj->replace( qr/x/, {} ) }, + throws_ok { $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' ); - like exception { $obj->match }, + throws_ok { $obj->match } qr/Cannot call match without at least 1 argument/, 'match throws an error when no arguments are passed'; - like exception { $obj->match( {} ) }, + throws_ok { $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' ); - like exception { $obj->clear(42) }, + throws_ok { $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' ); - like exception { $obj->substr }, + throws_ok { $obj->substr } qr/Cannot call substr without at least 1 argument/, 'substr throws an error when no argumemts are passed'; - like exception { $obj->substr( 1, 2, 3, 4 ) }, + throws_ok { $obj->substr( 1, 2, 3, 4 ) } qr/Cannot call substr with more than 3 arguments/, 'substr throws an error when four argumemts are passed'; - like exception { $obj->substr( {} ) }, + throws_ok { $obj->substr( {} ) } qr/The first argument passed to substr must be an integer/, 'substr throws an error when first argument is not an integer'; - like exception { $obj->substr( 1, {} ) }, + throws_ok { $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'; - like exception { $obj->substr( 1, 2, {} ) }, + throws_ok { $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 7d1805b..7f76c1a 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::Fatal; +use Test::Exception; { package Foo; @@ -36,11 +36,11 @@ use Test::Fatal; package Stuff; use Moose; - ::ok ! ::exception { with 'Stuffed::Role'; - }, '... this should work correctly'; + ::lives_ok{ with 'Stuffed::Role'; + } '... this should work correctly'; - ::ok ! ::exception { with 'Bulkie::Role'; - }, '... this should work correctly'; + ::lives_ok{ 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 7c59b18..5e9305d 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::Fatal; +use Test::Exception; { package MyHomePage; @@ -33,9 +33,9 @@ can_ok( $page, $_ ) for qw[ reset_counter ]; -ok ! exception { +lives_ok { $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 4267baf..2830d83 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::Fatal; +use Test::Exception; use Test::Moose; { @@ -55,7 +55,7 @@ use Test::Moose; } ); - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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"; - ::ok ! ::exception { + ::lives_ok { 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 eeb5de7..b85925d 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::Fatal; +use Test::Exception; =pod @@ -18,14 +18,14 @@ test makes sure it does not creep back in. package Foo; use Moose; - ::ok ! ::exception { + ::lives_ok { 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 c910761..82bad20 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::Fatal; +use Test::Exception; { package Foo; @@ -20,7 +20,7 @@ use Test::Fatal; package Bar; use Moose; - ::ok ! ::exception { + ::lives_ok { has 'baz' => ( is => 'ro', isa => 'Foo', @@ -28,14 +28,14 @@ use Test::Fatal; default => sub { Foo->new() }, handles => qr/^a$/, ); - }, '... can create the attribute with delegations'; + } '... can create the attribute with delegations'; } my $bar; -ok ! exception { +lives_ok { $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; - ::ok ! ::exception { + ::lives_ok { 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; -ok ! exception { +lives_ok { $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; - ::ok ! ::exception { + ::lives_ok { 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; -ok ! exception { +lives_ok { $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/012_DEMOLISH_eats_mini.t b/t/100_bugs/012_DEMOLISH_eats_mini.t index 3e1caf6..953e019 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::Fatal; +use Test::Exception; { diff --git a/t/100_bugs/016_inheriting_from_roles.t b/t/100_bugs/016_inheriting_from_roles.t index eafc858..c001dbb 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::Fatal; +use Test::Exception; { @@ -15,9 +15,9 @@ use Test::Fatal; package My::Class; use Moose; - ::like ::exception { + ::throws_ok { 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 a8fcf10..526130d 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::Fatal; +use Test::Exception; # RT #37569 @@ -52,21 +52,21 @@ use Test::Fatal; my $foo = Foo->new; my $obj = MyObject->new; -like exception { +throws_ok { $foo->ar( [] ); -}, +} qr/Attribute \(ar\) does not pass the type constraint because: ref: ARRAY/, '... got the right error message'; -like exception { +throws_ok { $foo->obj($foo); # Doh! -}, +} qr/Attribute \(obj\) does not pass the type constraint because: Well it is an object/, '... got the right error message'; -like exception { +throws_ok { $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 2d71779..9a99477 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::Fatal; +use Test::Exception; 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' ); -ok ! exception { +lives_ok { 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' ); -ok ! exception { +lives_ok { 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' ); -ok ! exception { +lives_ok { 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' ); -ok ! exception { +lives_ok { 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 8e5dfb6..a061244 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::Fatal; +use Test::Exception; { 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. -ok ! exception { $object->DESTROY }, +lives_ok { $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. -ok ! exception { $object->DESTROY }, +lives_ok { $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 f44d3eb..8eea71a 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::Fatal; +use Test::Exception; use Test::More; { @@ -22,7 +22,7 @@ use Test::More; local $TODO = 'UNIVERSAL methods should be wrappable'; - ::ok ! ::exception { with 'FakeBar' }, 'applied role'; + ::lives_ok { 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 26933a8..1756795 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::Fatal; +use Test::Exception; use Moose::Meta::Class; @@ -14,11 +14,11 @@ TODO: = 'Loading Moose::Meta::Class without loading Moose.pm causes weird problems'; my $meta; - ok ! exception { + lives_ok { $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 4124237..be31007 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::Fatal; +use Test::Exception; { 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'); -ok ! exception { +lives_and { 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/030_coerce_without_coercion.t b/t/100_bugs/030_coerce_without_coercion.t index 120f763..7880688 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::Fatal; +use Test::Exception; use Test::Moose; { @@ -19,17 +19,17 @@ use Test::Moose; } with_immutable { - ok ! exception { Foo->new( x => {} ) }, + lives_ok { Foo->new( x => {} ) } 'Setting coerce => 1 without a coercion on the type does not cause an error in the constructor'; - ok ! exception { Foo->new->x( {} ) }, + lives_ok { Foo->new->x( {} ) } 'Setting coerce => 1 without a coercion on the type does not cause an error when setting the attribut'; - like exception { Foo->new( x => 42 ) }, + throws_ok { 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'; - like exception { Foo->new->x(42) }, + throws_ok { 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/002_example_Moose_POOP.t b/t/200_examples/002_example_Moose_POOP.t index d6a5485..b0227bd 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::Fatal; +use Test::Exception; BEGIN { # in case there are leftovers @@ -237,7 +237,7 @@ my $article_oid; my $article_ref; { my $article; - ok ! exception { + lives_ok { $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'); - ok ! exception { + lives_ok { $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; - ok ! exception { + lives_ok { $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; - ok ! exception { + lives_ok { $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'); - ok ! exception { + lives_ok { $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; - ok ! exception { + lives_ok { $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; - ok ! exception { + lives_ok { $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 2cf01c7..a61ba35 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::Fatal; +use Test::Exception; sub U { my $f = shift; @@ -81,16 +81,16 @@ sub Y { package My::List1; use Moose; - ::ok ! ::exception { + ::lives_ok { with 'List', 'List::Immutable'; - }, '... successfully composed roles together'; + } '... successfully composed roles together'; package My::List2; use Moose; - ::ok ! ::exception { + ::lives_ok { 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 2b1168f..671781c 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::Fatal; +use Test::Exception; { package Foo; @@ -58,35 +58,35 @@ my $hash_of_arrays_of_objs = { my $array_of_ints = [ 1 .. 10 ]; my $foo; -ok ! exception { +lives_ok { $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'); -ok exception { +dies_ok { $foo->bar([]); -}, '... validation failed correctly'; +} '... validation failed correctly'; -ok exception { +dies_ok { $foo->bar({ foo => 3 }); -}, '... validation failed correctly'; +} '... validation failed correctly'; -ok exception { +dies_ok { $foo->bar({ foo => [ 1, 2, 3 ] }); -}, '... validation failed correctly'; +} '... validation failed correctly'; -ok exception { +dies_ok { $foo->baz([ "foo" ]); -}, '... validation failed correctly'; +} '... validation failed correctly'; -ok exception { +dies_ok { $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 0e8f53d..676ae29 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::Fatal; +use Test::Exception; { package Foo; @@ -58,19 +58,19 @@ my $array_of_hashes = [ ]; my $foo; -ok ! exception { +lives_ok { $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'); -ok exception { +dies_ok { $foo->bar({}); -}, '... validation failed correctly'; +} '... validation failed correctly'; -ok exception { +dies_ok { $foo->bar([{ foo => 3 }]); -}, '... validation failed correctly'; +} '... validation failed correctly'; done_testing; diff --git a/t/300_immutable/001_immutable_moose.t b/t/300_immutable/001_immutable_moose.t index aa90d6d..b969268 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::Fatal; +use Test::Exception; use Moose::Meta::Role; @@ -33,25 +33,25 @@ use Moose::Meta::Role; my $foo_role = Moose::Meta::Role->initialize('FooRole'); my $meta = Foo->meta; - ok ! exception { Foo->new }, "lazy_build works"; + lives_ok { 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" ); - 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"; + 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"; 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" ); - ok ! exception { $meta->make_mutable }, "Foo is mutable"; - ok ! exception { $meta->add_role($foo_role) }, "Add Role is unlocked"; + lives_ok { $meta->make_mutable } "Foo is mutable"; + lives_ok { $meta->add_role($foo_role) } "Add Role is unlocked"; } @@ -73,10 +73,10 @@ use Moose::Meta::Role; sub BUILD { 'baz' } } -ok ! exception { Bar->meta->make_immutable }, +lives_ok { Bar->meta->make_immutable } 'Immutable meta with single BUILD'; -ok ! exception { Baz->meta->make_immutable }, +lives_ok { 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 7739b24..57d0c7f 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::Fatal; +use Test::Exception; { @@ -31,9 +31,9 @@ isa_ok($foo, 'Foo'); is($foo->baz, 'Foo::baz', '... got the right value'); -ok ! exception { +lives_ok { 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 ae5b844..1a1b662 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::Fatal; +use Test::Exception; { @@ -20,8 +20,8 @@ use Test::Fatal; ); } -ok ! exception { +lives_ok { 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 c2e9fb3..0c47a8c 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::Fatal; +use Test::Exception; =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'; - ok ! exception { + lives_ok { 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)"; - ok ! exception { + lives_ok { 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)"; - ok exception { + dies_ok { 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 c6b5bdb..d30a9c8 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::Fatal; +use Test::Exception; { @@ -26,20 +26,20 @@ use Test::Fatal; sub DEMOLISH { } } -ok ! exception { +lives_ok { Bar->new(); -}, 'Bar->new()'; +} 'Bar->new()'; -ok ! exception { +lives_ok { 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)' ); -ok ! exception { +lives_ok { 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 ee667b5..bc86c1d 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::Fatal; +use Test::Exception; { @@ -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"); -ok ! exception { AClass->new(bar => 'bar') }, '... no triggers called'; +lives_ok { 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 e5d208b..d5db002 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::Fatal; +use Test::Exception; =pod @@ -25,11 +25,11 @@ constructor. } my $scalar = 1; -like exception { Foo->new($scalar) }, qr/\QSingle parameters to new() must be a HASH ref/, +throws_ok { Foo->new($scalar) } qr/\QSingle parameters to new() must be a HASH ref/, 'Non-ref provided to immutable constructor gives useful error message'; -like exception { Foo->new(\$scalar) }, qr/\QSingle parameters to new() must be a HASH ref/, +throws_ok { Foo->new(\$scalar) } qr/\QSingle parameters to new() must be a HASH ref/, 'Scalar ref provided to immutable constructor gives useful error message'; -like exception { Foo->new(undef) }, qr/\QSingle parameters to new() must be a HASH ref/, +throws_ok { 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 2114f4a..ad4e611 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::Fatal; +use Test::Exception; { @@ -17,7 +17,7 @@ use Test::Fatal; has 'buz' => ( is => 'rw', default => q{"'\\} ); has 'faz' => ( is => 'rw', default => qq{\0} ); - ::ok ! ::exception { __PACKAGE__->meta->make_immutable }, + ::lives_ok { __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 ); - ::ok ! ::exception { __PACKAGE__->meta->make_immutable }, + ::lives_ok { __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 be7b29f..5919287 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::Fatal; +use Test::Exception; use Moose::Util qw( add_method_modifier ); my $COUNT = 0; @@ -14,13 +14,13 @@ my $COUNT = 0; sub bar { } } -ok ! exception { +lives_ok { add_method_modifier('Foo', 'before', [ ['foo', 'bar'], sub { $COUNT++ } ]); -}, 'method modifier with an arrayref'; +} 'method modifier with an arrayref'; -ok exception { +dies_ok { 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 d6e0568..c768b90 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::Fatal; +use Test::Exception; BEGIN { use_ok('Moose::Util::TypeConstraints'); } -ok ! exception { +lives_ok { subtype 'ParentConstraint' => as 'Str' => where {0}; -}, 'specified parent type constraint'; +} 'specified parent type constraint'; my $tc; -ok ! exception { +lives_ok { $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 992d1c8..8b6bccc 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::Fatal; +use Test::Exception; 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" ); - ::ok ! ::exception { with qw(Dancer) }; + ::lives_ok { with qw(Dancer) }; package Dancer::Something; use Moose; @@ -83,7 +83,7 @@ sub req_or_has ($$) { has twist => ( is => "rw" ); { - ::ok ! ::exception { with qw(Dancer) }; + ::lives_ok { 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"; - ::ok ! ::exception { with qw(Dancer::Robot) }; + ::lives_ok { 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"; - ::ok ::exception { with qw(Tree Dog) }, + ::dies_ok { with qw(Tree Dog) } } } diff --git a/t/600_todo_tests/006_required_role_accessors.t b/t/600_todo_tests/006_required_role_accessors.t index 153b32a..fed49f8 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::Fatal; +use Test::Exception; { package Foo::API; @@ -24,7 +24,7 @@ use Test::Fatal; package Foo::Class; use Moose; { our $TODO; local $TODO = "role accessors don't satisfy other role requires"; - ::ok ! ::exception { with 'Foo' }, 'requirements are satisfied properly'; + ::lives_ok { with 'Foo' } 'requirements are satisfied properly'; } } @@ -51,7 +51,7 @@ use Test::Fatal; use Moose; { our $TODO; local $TODO = "role accessors don't satisfy other role requires"; - ::ok ! ::exception { with qw(Bar Baz) }, 'requirements are satisfied properly'; + ::lives_ok { 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 81affc5..c254f51 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::Fatal; +use Test::Exception; BEGIN { { @@ -52,7 +52,7 @@ BEGIN { package Child; use Moose -traits => 'Bar'; { our $TODO; local $TODO = "no idea what's going on here"; - ::ok ! ::exception { extends 'Parent' }; + ::lives_ok { extends 'Parent' }; } }