Allow required versions to be specified when setting superclasses and applying roles.
[gitmo/Moose.git] / t / 010_basics / 002_require_superclasses.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib', 'lib';
7
8 use Test::More;
9 use Test::Exception;
10
11
12 {
13
14     package Bar;
15     use Moose;
16
17     ::lives_ok { extends 'Foo' } 'loaded Foo superclass correctly';
18 }
19
20 {
21
22     package Baz;
23     use Moose;
24
25     ::lives_ok { extends 'Bar' } 'loaded (inline) Bar superclass correctly';
26 }
27
28 {
29
30     package Foo::Bar;
31     use Moose;
32
33     ::lives_ok { extends 'Foo', 'Bar' }
34     'loaded Foo and (inline) Bar superclass correctly';
35 }
36
37 {
38
39     package Bling;
40     use Moose;
41
42     ::throws_ok { extends 'No::Class' }
43     qr{Can't locate No/Class\.pm in \@INC},
44     'correct error when superclass could not be found';
45 }
46
47 {
48     package Affe;
49     our $VERSION = 23;
50 }
51
52 {
53     package Tiger;
54     use Moose;
55
56     ::lives_ok { extends 'Foo', Affe => { -version => 13 } }
57     'extends with version requirement';
58 }
59
60 {
61     package Birne;
62     use Moose;
63
64     ::throws_ok { extends 'Foo', Affe => { -version => 42 } }
65     qr/Affe version 42 required--this is only version 23/,
66     'extends with unsatisfied version requirement';
67 }
68
69 done_testing;