X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F800_shikabased%2F010-isa-or.t;h=b912815b94a1ca08e9740617959f5aff0c692646;hb=a09601ab6f3b4b6efb78d3f24a050fec92dcf02f;hp=0ede006e93b95c4e2ee7e5910acb549ed9238f4e;hpb=bcc5080bdc8c8b3edfbb3dd6af0b65224074043f;p=gitmo%2FMouse.git diff --git a/t/800_shikabased/010-isa-or.t b/t/800_shikabased/010-isa-or.t index 0ede006..b912815 100644 --- a/t/800_shikabased/010-isa-or.t +++ b/t/800_shikabased/010-isa-or.t @@ -7,14 +7,17 @@ use Test::More tests => 18; use Mouse; use Mouse::Util::TypeConstraints; type Baz => where { defined($_) && $_ eq 'Baz' }; + coerce Baz => from 'ArrayRef', via { 'Baz' }; + has 'bar' => ( is => 'rw', isa => 'Str | Baz | Undef', coerce => 1 ); } eval { Foo->new( bar => +{} ); }; -ok $@, 'not got an object'; +like($@, qr/^Attribute \(bar\) does not pass the type constraint because: Validation failed for 'Str\|Baz\|Undef' failed with value HASH\(\w+\)/, 'type constraint and coercion failed') + or diag "\$@='$@'"; eval { isa_ok(Foo->new( bar => undef ), 'Foo'); @@ -32,7 +35,7 @@ my $f = Foo->new; eval { $f->bar([]); }; -ok !$@; +ok !$@, $@; is $f->bar, 'Baz', 'bar is baz (coerce from ArrayRef)'; eval { @@ -69,7 +72,7 @@ is $foo->foo, 'Name', 'foo is Name'; { package KLASS; - sub new { bless {}, shift }; + use Mouse; } { package Funk;