3 use Test::More tests => 4;
4 use Mouse::Util::TypeConstraints;
6 subtype 'Foo', as 'Object', where { $_->isa('A') };
11 has data => ( is => 'rw', isa => 'Str' );
17 has a => ( is => 'rw', isa => 'Foo', coerce => 1 );
20 isa_ok(C->new(a => A->new()), 'C');
21 C->meta->make_immutable;
22 isa_ok(C->new(a => A->new()), 'C');
26 # The BUILD invocation order used to get reversed after
27 # making a class immutable. This checks it is correct.
37 sub BUILD { push @{shift->order}, 'D' }
43 sub BUILD { push @{shift->order}, 'E' }
49 sub BUILD { push @{shift->order}, 'F' }
56 print join(", ", @{$obj->order}),"\n";
57 is_deeply $obj->order, [qw(D E F)], "mutable BUILD invocation order correct";
59 # now make the classes immutable
60 $_->meta->make_immutable for qw(D E F);
64 print join(", ", @{$obj2->order}),"\n";
65 is_deeply $obj2->order, [qw(D E F)], "immutable BUILD invocation order still correct";