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