Reorganize t/020_attributes/
[gitmo/Mouse.git] / t / 020_attributes / 025_chained_coercion.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
4060c871 5
6use strict;
7use warnings;
8
1f5ce14a 9use Test::More;
4060c871 10use 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
46my $foo = Foo->new(bar => { baz => { hello => 'World' } });
47isa_ok($foo, 'Foo');
48isa_ok($foo->bar, 'Bar');
49isa_ok($foo->bar->baz, 'Baz');
50is($foo->bar->baz->hello, 'World', '... this all worked fine');
51
1f5ce14a 52done_testing;