don't try and apply modifiers during role composition
[gitmo/Moo.git] / t / moo.t
CommitLineData
6c74d087 1use strictures 1;
2use Test::More;
3
4{
5 package MyClass0;
6
7 BEGIN { our @ISA = 'ZeroZero' }
8
b1eebd55 9 use Moo;
6c74d087 10}
11
12BEGIN {
13 is(
14 $INC{'Class/Tiny/Object.pm'}, undef,
15 'Object.pm not loaded if not required'
16 );
17}
18
19{
20 package MyClass1;
21
b1eebd55 22 use Moo;
6c74d087 23}
24
25is_deeply(
b1eebd55 26 [ @MyClass1::ISA ], [ 'Moo::Object' ], 'superclass defaulted'
6c74d087 27);
28
29{
30 package MyClass2;
31
32 use base qw(MyClass1);
b1eebd55 33 use Moo;
6c74d087 34}
35
36is_deeply(
37 [ @MyClass2::ISA ], [ 'MyClass1' ], 'prior superclass left alone'
38);
39
40{
41 package MyClass3;
42
b1eebd55 43 use Moo;
6c74d087 44
45 extends 'MyClass2';
46}
47
48is_deeply(
49 [ @MyClass3::ISA ], [ 'MyClass2' ], 'extends sets superclass'
50);
51
dccea57d 52{ package WhatTheFlyingFornication; sub wtff {} }
53
6c74d087 54{
55 package MyClass4;
56
b1eebd55 57 use Moo;
6c74d087 58
59 extends 'WhatTheFlyingFornication';
60
61 extends qw(MyClass2 MyClass3);
62}
63
64is_deeply(
65 [ @MyClass4::ISA ], [ qw(MyClass2 MyClass3) ], 'extends overwrites'
66);
67
68{
69 package MyClass5;
70
b1eebd55 71 use Moo;
6c74d087 72
73 sub foo { 'foo' }
74
75 around foo => sub { my $orig = shift; $orig->(@_).' with around' };
76}
77
78is(MyClass5->foo, 'foo with around', 'method modifier');
79
80done_testing;