6 use Test::More tests => 12;
14 package Fake::DateTime;
17 has 'string_repr' => (is => 'ro');
21 use Moose::Util::TypeConstraints;
23 coerce 'Fake::DateTime'
25 => via { Fake::DateTime->new(string_repr => $_) };
27 has 'closing_date' => (
29 isa => 'Fake::DateTime',
32 my ( $self, $val, $meta ) = @_;
33 ::pass('... trigger is being called');
34 ::isa_ok($self->closing_date, 'Fake::DateTime');
35 ::isa_ok($val, 'Fake::DateTime');
41 my $mtg = Mortgage->new( closing_date => 'yesterday' );
42 isa_ok($mtg, 'Mortgage');
44 # check that coercion worked
45 isa_ok($mtg->closing_date, 'Fake::DateTime');
48 Mortgage->meta->make_immutable;
49 ok(Mortgage->meta->is_immutable, '... Mortgage is now immutable');
52 my $mtg = Mortgage->new( closing_date => 'yesterday' );
53 isa_ok($mtg, 'Mortgage');
55 # check that coercion worked
56 isa_ok($mtg->closing_date, 'Fake::DateTime');