tests for handles
[gitmo/Role-Tiny.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
52{
53 package MyClass4;
54
b1eebd55 55 use Moo;
6c74d087 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
b1eebd55 69 use Moo;
6c74d087 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;