add BUILDALL support
[gitmo/Moo.git] / t / class-tiny.t
CommitLineData
6c74d087 1use strictures 1;
2use Test::More;
3
4{
5 package MyClass0;
6
7 BEGIN { our @ISA = 'ZeroZero' }
8
9 use Class::Tiny;
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
22 use Class::Tiny;
23}
24
25is_deeply(
26 [ @MyClass1::ISA ], [ 'Class::Tiny::Object' ], 'superclass defaulted'
27);
28
29{
30 package MyClass2;
31
32 use base qw(MyClass1);
33 use Class::Tiny;
34}
35
36is_deeply(
37 [ @MyClass2::ISA ], [ 'MyClass1' ], 'prior superclass left alone'
38);
39
40{
41 package MyClass3;
42
43 use Class::Tiny;
44
45 extends 'MyClass2';
46}
47
48is_deeply(
49 [ @MyClass3::ISA ], [ 'MyClass2' ], 'extends sets superclass'
50);
51
52{
53 package MyClass4;
54
55 use Class::Tiny;
56
57 extends 'WhatTheFlyingFornication';
58
59 extends qw(MyClass2 MyClass3);
60}
61
62is_deeply(
63 [ @MyClass4::ISA ], [ qw(MyClass2 MyClass3) ], 'extends overwrites'
64);
65
66{
67 package MyClass5;
68
69 use Class::Tiny;
70
71 sub foo { 'foo' }
72
73 around foo => sub { my $orig = shift; $orig->(@_).' with around' };
74}
75
76is(MyClass5->foo, 'foo with around', 'method modifier');
77
78done_testing;