Commit | Line | Data |
6c74d087 |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
4 | { |
5 | package MyClass0; |
6 | |
7 | BEGIN { our @ISA = 'ZeroZero' } |
8 | |
b1eebd55 |
9 | use Moo; |
6c74d087 |
10 | } |
11 | |
12 | BEGIN { |
13 | is( |
9b80021f |
14 | $INC{'Moo/Object.pm'}, undef, |
6c74d087 |
15 | 'Object.pm not loaded if not required' |
16 | ); |
17 | } |
18 | |
19 | { |
20 | package MyClass1; |
21 | |
b1eebd55 |
22 | use Moo; |
6c74d087 |
23 | } |
24 | |
25 | is_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 | |
36 | is_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 | |
48 | is_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 | |
64 | is_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 | |
78 | is(MyClass5->foo, 'foo with around', 'method modifier'); |
79 | |
80 | done_testing; |