From: Dave Rolsky Date: Thu, 28 Oct 2010 17:52:36 +0000 (-0500) Subject: Standardize use of Test::Exception before converting to Test::Fatal X-Git-Tag: 1.18~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4e538d9bf46d1c14d2ecfd36ac35ed541ae7ee6;p=gitmo%2FMoose.git Standardize use of Test::Exception before converting to Test::Fatal --- diff --git a/t/040_type_constraints/016_subtyping_parameterized_types.t b/t/040_type_constraints/016_subtyping_parameterized_types.t index 3c6971f..21269c4 100644 --- a/t/040_type_constraints/016_subtyping_parameterized_types.t +++ b/t/040_type_constraints/016_subtyping_parameterized_types.t @@ -114,10 +114,10 @@ lives_ok { ok $SubOfMyArrayRef->check([15,20,25]), '[15,20,25] is a bunch of big ints'; ok ! $SubOfMyArrayRef->check([15,5,25]), '[15,5,25] is NOT a bunch of big ints'; - throws_ok sub { + throws_ok { 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/021_maybe_type_constraint.t b/t/040_type_constraints/021_maybe_type_constraint.t index 4974e09..bfa8991 100644 --- a/t/040_type_constraints/021_maybe_type_constraint.t +++ b/t/040_type_constraints/021_maybe_type_constraint.t @@ -121,14 +121,14 @@ ok sub {$obj->Maybe_Int(undef); 1}->() ok !$Maybe_Int->check("") => 'failed ("")'; -throws_ok sub { $obj->Maybe_Int("") }, +throws_ok { $obj->Maybe_Int("") } qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("")'; ok !$Maybe_Int->check("a") => 'failed ("a")'; -throws_ok sub { $obj->Maybe_Int("a") }, +throws_ok { $obj->Maybe_Int("a") } qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("a")'; diff --git a/t/040_type_constraints/027_parameterize_from.t b/t/040_type_constraints/027_parameterize_from.t index beab5b8..5be0677 100644 --- a/t/040_type_constraints/027_parameterize_from.t +++ b/t/040_type_constraints/027_parameterize_from.t @@ -43,39 +43,39 @@ isa_ok $params, 'Test::Moose::Meta::TypeConstraint::Parameterizable' => # test parameterizable -lives_ok sub { +lives_ok { $params->parameterizable( { a => 'Hello', b => 'World' } ); -} => 'No problem setting parameterizable'; +} 'No problem setting parameterizable'; is_deeply $params->parameterizable, { a => 'Hello', b => 'World' } => 'Got expected values'; # test parameterized -lives_ok sub { +lives_ok { $params->parameterized( { a => 1, b => 2 } ); -} => 'No problem setting parameterized'; +} 'No problem setting parameterized'; is_deeply $params->parameterized, { a => 1, b => 2 } => 'Got expected values'; -throws_ok sub { +throws_ok { $params->parameterized( { a => 'Hello', b => 'World' } ); - }, qr/Attribute \(parameterized\) does not pass the type constraint/ => + } qr/Attribute \(parameterized\) does not pass the type constraint/ => 'parameterized throws expected error'; # test from_parameterizable -lives_ok sub { +lives_ok { $params->from_parameterizable( { a => 1, b => 2 } ); -} => 'No problem setting from_parameterizable'; +} 'No problem setting from_parameterizable'; is_deeply $params->from_parameterizable, { a => 1, b => 2 } => 'Got expected values'; -throws_ok sub { +throws_ok { $params->from_parameterizable( { a => 'Hello', b => 'World' } ); - }, - qr/Attribute \(from_parameterizable\) does not pass the type constraint/ - => 'from_parameterizable throws expected error'; + } + qr/Attribute \(from_parameterizable\) does not pass the type constraint/, + 'from_parameterizable throws expected error'; done_testing; diff --git a/t/050_metaclasses/012_moose_exporter.t b/t/050_metaclasses/012_moose_exporter.t index e37669d..ac39d23 100644 --- a/t/050_metaclasses/012_moose_exporter.t +++ b/t/050_metaclasses/012_moose_exporter.t @@ -197,14 +197,13 @@ use Test::Requires { use Moose (); - ::dies_ok( - sub { + ::dies_ok + { Moose::Exporter->setup_import_methods( also => [ 'Moose', 'MooseX::CircularAlso' ], ); - }, - 'a circular reference in also dies with an error' - ); + } + 'a circular reference in also dies with an error'; ::like( $@, @@ -218,14 +217,13 @@ use Test::Requires { use Moose (); - ::dies_ok( - sub { + ::dies_ok + { Moose::Exporter->setup_import_methods( also => [ 'NoSuchThing' ], ); - }, - 'a package which does not use Moose::Exporter in also dies with an error' - ); + } + 'a package which does not use Moose::Exporter in also dies with an error'; ::like( $@, @@ -239,14 +237,13 @@ use Test::Requires { use Moose (); - ::dies_ok( - sub { + ::dies_ok + { Moose::Exporter->setup_import_methods( also => [ 'Moose::Meta::Method' ], ); - }, - 'a package which does not use Moose::Exporter in also dies with an error' - ); + } + 'a package which does not use Moose::Exporter in also dies with an error'; ::like( $@, diff --git a/t/050_metaclasses/013_metaclass_traits.t b/t/050_metaclasses/013_metaclass_traits.t index b47cea4..dcab7bd 100644 --- a/t/050_metaclasses/013_metaclass_traits.t +++ b/t/050_metaclasses/013_metaclass_traits.t @@ -167,8 +167,8 @@ is( Role::Foo->meta()->simple(), 5, { require Moose::Util::TypeConstraints; - dies_ok( sub { Moose::Util::TypeConstraints->import( -traits => 'My::SimpleTrait' ) }, - 'cannot provide -traits to an exporting module that does not init_meta' ); + dies_ok { 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' ); } diff --git a/t/050_metaclasses/014_goto_moose_import.t b/t/050_metaclasses/014_goto_moose_import.t index 06437ac..8b45680 100644 --- a/t/050_metaclasses/014_goto_moose_import.t +++ b/t/050_metaclasses/014_goto_moose_import.t @@ -31,8 +31,8 @@ use Test::Exception; MooseAlike1->import(); - ::lives_ok( sub { has( 'size', is => 'bare' ) }, - 'has was exported via MooseAlike1' ); + ::lives_ok { has( 'size', is => 'bare' ) } + 'has was exported via MooseAlike1'; MooseAlike1->unimport(); } @@ -68,8 +68,8 @@ isa_ok( Foo->meta(), 'Moose::Meta::Class' ); MooseAlike2->import(); - ::lives_ok( sub { has( 'size', is => 'bare' ) }, - 'has was exported via MooseAlike2' ); + ::lives_ok { has( 'size', is => 'bare' ) } + 'has was exported via MooseAlike2'; MooseAlike2->unimport(); }