typo fix
[gitmo/Moo.git] / xt / moo-coercion-construction-bug.t
CommitLineData
2a79705d 1use strict;
2use warnings;
3use Test::More;
4
5{
6 package MyTest::Role;
7 use Moo::Role;
8 use Sub::Quote;
9
10 has test_attr => (
11 isa => quote_sub(q{ die $_[0] . "not an object" unless Scalar::Util::blessed($_[0]) }),
12 coerce => quote_sub(q{
13 return $_[0] if Scalar::Util::blessed($_[0]);
14 die;
15 }),
16 is => 'ro',
17 required => 1,
18 );
19}
20
21{
22 package MyTest::ClassOne;
23 use Moo;
24
25 with 'MyTest::Role';
26
27}
28{
29 package MyTest::ClassTwo;
30 use Moo;
31
32 with 'MyTest::Role';
33}
34
35my $t = MyTest::ClassOne->new(test_attr => bless {}, 'Bar');
36my $n = MyTest::ClassTwo->new( test_attr => $t);
37is ref($n), 'MyTest::ClassTwo';
38
39done_testing;
40