Resolve a 'failing' test
[gitmo/Mouse.git] / t / 800_shikabased / 010-isa-or.t
index 0b42f5c..c60e45c 100644 (file)
@@ -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 => +{} );
 };
-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');
+like($@, qr/^Attribute \(bar\) does not pass the type constraint because: Validation failed for 'Baz\|Str\|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;
@@ -83,7 +86,7 @@ is $foo->foo, 'Name', 'foo is Name';
 }
 
 eval { Funk->new( foo => 'aaa' ) };
-like $@, qr/Attribute \(foo\) does not pass the type constraint because: Validation failed for 'Type3\|KLASS\|Undef' failed with value aaa/;
+like $@, qr/Attribute \(foo\) does not pass the type constraint because: Validation failed for 'KLASS\|Type3\|Undef' failed with value aaa/;
 
 my $k = Funk->new;
 ok $k, 'got an object 4';