no automatic travis testing for wip/blocked branches
[gitmo/Moo.git] / t / buildall.t
CommitLineData
098a367b 1use strictures 1;
2use Test::More;
3
4my @ran;
5
6{
b1eebd55 7 package Foo; use Moo; sub BUILD { push @ran, 'Foo' }
8 package Bar; use Moo; extends 'Foo'; sub BUILD { push @ran, 'Bar' }
9 package Baz; use Moo; extends 'Bar';
10 package Quux; use Moo; extends 'Baz'; sub BUILD { push @ran, 'Quux' }
098a367b 11}
12
077bd026 13{
14 package Fleem;
b1eebd55 15 use Moo;
077bd026 16 extends 'Quux';
17 has 'foo' => (is => 'ro');
18 sub BUILD { push @ran, $_[0]->foo, $_[1]->{bar} }
19}
20
c4570291 21{
22 package Odd1;
23 use Moo;
24 has 'odd1' => (is => 'ro');
25 sub BUILD { push @ran, 'Odd1' }
26 package Odd2;
27 use Moo;
28 extends 'Odd1';
29 package Odd3;
30 use Moo;
31 extends 'Odd2';
32 has 'odd3' => (is => 'ro');
33 sub BUILD { push @ran, 'Odd3' }
34}
35
e0e12d16 36{
37 package Sub1;
38 use Moo;
39 has 'foo' => (is => 'ro');
40 package Sub2;
41 use Moo;
42 extends 'Sub1';
43 sub BUILD { push @ran, "sub2" }
44}
45
098a367b 46my $o = Quux->new;
47
48is(ref($o), 'Quux', 'object returned');
49is_deeply(\@ran, [ qw(Foo Bar Quux) ], 'BUILDs ran in order');
50
077bd026 51@ran = ();
52
53$o = Fleem->new(foo => 'Fleem1', bar => 'Fleem2');
54
55is(ref($o), 'Fleem', 'object with inline constructor returned');
56is_deeply(\@ran, [ qw(Foo Bar Quux Fleem1 Fleem2) ], 'BUILDs ran in order');
57
c4570291 58@ran = ();
59
60$o = Odd3->new(odd1 => 1, odd3 => 3);
61
62is(ref($o), 'Odd3', 'Odd3 object constructed');
63is_deeply(\@ran, [ qw(Odd1 Odd3) ], 'BUILDs ran in order');
64
e0e12d16 65@ran = ();
66
67$o = Sub2->new;
68
69is(ref($o), 'Sub2', 'Sub2 object constructed');
70is_deeply(\@ran, [ qw(sub2) ], 'BUILD ran');
71
098a367b 72done_testing;