2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
21 use Mouse::Util::TypeConstraints;
25 => where { defined $_->[0] }
26 => message { ref $_ ? "ref: ". ref $_ : 'scalar' } # stringy
29 subtype 'MyObjectType'
31 => where { $_->isa('MyObject') }
33 if ( $_->isa('SomeObject') ) {
34 return 'More detailed error message';
36 elsif ( blessed $_ ) {
37 return 'Well it is an object';
46 => where { $_->isa('MyObject') }
47 => message { blessed $_ ? 'blessed' : 'scalar' }
50 has 'obj' => ( is => 'rw', isa => 'MyObjectType' );
51 has 'ar' => ( is => 'rw', isa => 'MyArrayRef' );
52 has 'nt' => ( is => 'rw', isa => 'NewType' );
56 my $obj = MyObject->new;
61 qr/Attribute \(ar\) does not pass the type constraint because: ref: ARRAY/,
62 '... got the right error message';
65 $foo->obj($foo); # Doh!
67 qr/Attribute \(obj\) does not pass the type constraint because: Well it is an object/,
68 '... got the right error message';
71 $foo->nt($foo); # scalar
73 qr/Attribute \(nt\) does not pass the type constraint because: blessed/,
74 '... got the right error message';