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';
}
{
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")';
# 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;
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(
$@,
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(
$@,
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(
$@,
{
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' );
}
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();
}
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();
}