inlining for overloaded object isa/coerce
[gitmo/Moo.git] / t / moo-accessors.t
1 use strictures 1;
2 use Test::More;
3
4 {
5   package Foo;
6
7   use Moo;
8
9   has one => (is => 'ro');
10   has two => (is => 'rw', init_arg => undef);
11   has three => (is => 'ro', init_arg => 'THREE', required => 1);
12
13   package Bar;
14
15   use Moo::Role;
16
17   has four => (is => 'ro');
18
19   package Baz;
20
21   use Moo;
22
23   extends 'Foo';
24
25   with 'Bar';
26
27   has five => (is => 'rw');
28 }
29
30 my $foo = Foo->new(
31   one => 1,
32   THREE => 3
33 );
34
35 is_deeply(
36   { %$foo }, { one => 1, three => 3 }, 'simple class ok'
37 );
38
39 my $baz = Baz->new(
40   one => 1,
41   THREE => 3,
42   four => 4,
43   five => 5,
44 );
45
46 is_deeply(
47   { %$baz }, { one => 1, three => 3, four => 4, five => 5 },
48   'subclass with role ok'
49 );
50
51 ok(eval { Foo->meta->make_immutable }, 'make_immutable returns true');
52 ok(!$INC{"Moose.pm"}, "Didn't load Moose");
53
54 done_testing unless caller;