X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2F017_subtyping_union_types.t;h=12d8226d382318ed24431e0650219eaae1f8ddea;hb=be0ed15704fdad5f2d8517380a6f24687432c1dd;hp=22dec83e005729922be979bfacbbaa74421629b0;hpb=2c78d8110cb935f2fdc5086c5d327907a2c5c4f9;p=gitmo%2FMoose.git diff --git a/t/040_type_constraints/017_subtyping_union_types.t b/t/040_type_constraints/017_subtyping_union_types.t index 22dec83..12d8226 100644 --- a/t/040_type_constraints/017_subtyping_union_types.t +++ b/t/040_type_constraints/017_subtyping_union_types.t @@ -3,16 +3,16 @@ use strict; use warnings; -use Test::More tests => 21; -use Test::Exception; +use Test::More; +use Test::Fatal; BEGIN { use_ok("Moose::Util::TypeConstraints"); } -lives_ok { +ok ! exception { subtype 'MyCollections' => as 'ArrayRef | HashRef'; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; { my $t = find_type_constraint('MyCollections'); @@ -24,26 +24,26 @@ lives_ok { isa_ok($p, 'Moose::Meta::TypeConstraint::Union'); isa_ok($p, 'Moose::Meta::TypeConstraint'); - is($p->name, 'ArrayRef | HashRef', '... parent name is correct'); + is($p->name, 'ArrayRef|HashRef', '... parent name is correct'); ok($t->check([]), '... validated it correctly'); - ok($t->check({}), '... validated it correctly'); + ok($t->check({}), '... validated it correctly'); ok(!$t->check(1), '... validated it correctly'); } -lives_ok { - subtype 'MyCollectionsExtended' - => as 'ArrayRef | HashRef' +ok ! exception { + subtype 'MyCollectionsExtended' + => as 'ArrayRef|HashRef' => where { if (ref($_) eq 'ARRAY') { return if scalar(@$_) < 2; } elsif (ref($_) eq 'HASH') { - return if scalar(keys(%$_)) < 2; + return if scalar(keys(%$_)) < 2; } 1; }; -} '... created the subtype special okay'; +}, '... created the subtype special okay'; { my $t = find_type_constraint('MyCollectionsExtended'); @@ -55,15 +55,15 @@ lives_ok { isa_ok($p, 'Moose::Meta::TypeConstraint::Union'); isa_ok($p, 'Moose::Meta::TypeConstraint'); - is($p->name, 'ArrayRef | HashRef', '... parent name is correct'); + is($p->name, 'ArrayRef|HashRef', '... parent name is correct'); ok(!$t->check([]), '... validated it correctly'); - ok($t->check([1, 2]), '... validated it correctly'); - - ok(!$t->check({}), '... validated it correctly'); - ok($t->check({ one => 1, two => 2 }), '... validated it correctly'); - + ok($t->check([1, 2]), '... validated it correctly'); + + ok(!$t->check({}), '... validated it correctly'); + ok($t->check({ one => 1, two => 2 }), '... validated it correctly'); + ok(!$t->check(1), '... validated it correctly'); } - +done_testing;