X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2F007_util_more_type_coercion.t;h=cd29ea0ab93df221372cb8f8e6a1c01ae8cd6b47;hb=32a1dc89aa0691a28ac39820648fc0d2960d6cd4;hp=64802223e620e9b40b61af5acf87f391e3c0a758;hpb=41e007e41e1dd7b10b59208da01afb9e711ec90a;p=gitmo%2FMoose.git 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 6480222..cd29ea0 100644 --- a/t/040_type_constraints/007_util_more_type_coercion.t +++ b/t/040_type_constraints/007_util_more_type_coercion.t @@ -3,35 +3,33 @@ use strict; use warnings; -use Test::More tests => 26; +use Test::More tests => 25; use Test::Exception; -BEGIN { - use_ok('Moose'); -} + { package HTTPHeader; use Moose; use Moose::Util::TypeConstraints; - + coerce 'HTTPHeader' - => from ArrayRef + => from ArrayRef => via { HTTPHeader->new(array => $_[0]) }; - + coerce 'HTTPHeader' - => from HashRef - => via { HTTPHeader->new(hash => $_[0]) }; - + => from HashRef + => via { HTTPHeader->new(hash => $_[0]) }; + has 'array' => (is => 'ro'); - has 'hash' => (is => 'ro'); + has 'hash' => (is => 'ro'); package Engine; use strict; use warnings; use Moose; - - has 'header' => (is => 'rw', isa => 'HTTPHeader', coerce => 1); + + has 'header' => (is => 'rw', isa => 'HTTPHeader', coerce => 1); } { @@ -65,11 +63,11 @@ BEGIN { ok(!defined($engine->header->array), '... no array value set'); dies_ok { - $engine->header("Foo"); + $engine->header("Foo"); } '... dies with the wrong type, even after coercion'; lives_ok { - $engine->header(HTTPHeader->new); + $engine->header(HTTPHeader->new); } '... lives with the right type, even after coercion'; }