6 use Test::More tests => 11;
13 package Fake::DateTime;
16 has 'string_repr' => ( is => 'ro' );
20 use Moose::Util::TypeConstraints;
22 coerce 'Fake::DateTime' => from 'Str' =>
23 via { Fake::DateTime->new( string_repr => $_ ) };
25 has 'closing_date' => (
27 isa => 'Fake::DateTime',
30 my ( $self, $val ) = @_;
31 ::pass('... trigger is being called');
32 ::isa_ok( $self->closing_date, 'Fake::DateTime' );
33 ::isa_ok( $val, 'Fake::DateTime' );
39 my $mtg = Mortgage->new( closing_date => 'yesterday' );
40 isa_ok( $mtg, 'Mortgage' );
42 # check that coercion worked
43 isa_ok( $mtg->closing_date, 'Fake::DateTime' );
46 Mortgage->meta->make_immutable;
47 ok( Mortgage->meta->is_immutable, '... Mortgage is now immutable' );
50 my $mtg = Mortgage->new( closing_date => 'yesterday' );
51 isa_ok( $mtg, 'Mortgage' );
53 # check that coercion worked
54 isa_ok( $mtg->closing_date, 'Fake::DateTime' );