Commit | Line | Data |
4060c871 |
1 | #!/usr/bin/perl |
1f5ce14a |
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; |
4060c871 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
1f5ce14a |
9 | use Test::More; |
4060c871 |
10 | use Test::Exception; |
11 | |
12 | { |
13 | package Baz; |
14 | use Mouse; |
15 | use Mouse::Util::TypeConstraints; |
16 | |
17 | coerce 'Baz' => from 'HashRef' => via { Baz->new($_) }; |
18 | |
19 | has 'hello' => ( |
20 | is => 'ro', |
21 | isa => 'Str', |
22 | ); |
23 | |
24 | package Bar; |
25 | use Mouse; |
26 | use Mouse::Util::TypeConstraints; |
27 | |
28 | coerce 'Bar' => from 'HashRef' => via { Bar->new($_) }; |
29 | |
30 | has 'baz' => ( |
31 | is => 'ro', |
32 | isa => 'Baz', |
33 | coerce => 1 |
34 | ); |
35 | |
36 | package Foo; |
37 | use Mouse; |
38 | |
39 | has 'bar' => ( |
40 | is => 'ro', |
41 | isa => 'Bar', |
42 | coerce => 1, |
43 | ); |
44 | } |
45 | |
46 | my $foo = Foo->new(bar => { baz => { hello => 'World' } }); |
47 | isa_ok($foo, 'Foo'); |
48 | isa_ok($foo->bar, 'Bar'); |
49 | isa_ok($foo->bar->baz, 'Baz'); |
50 | is($foo->bar->baz->hello, 'World', '... this all worked fine'); |
51 | |
1f5ce14a |
52 | done_testing; |