Allow required versions to be specified when setting superclasses and applying roles.
[gitmo/Moose.git] / t / 010_basics / 002_require_superclasses.t
CommitLineData
d7f17ebb 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use lib 't/lib', 'lib';
7
a28e50e4 8use Test::More;
6b584f6c 9use Test::Exception;
7ff56534 10
d7f17ebb 11
d7f17ebb 12{
6b584f6c 13
d7f17ebb 14 package Bar;
d7f17ebb 15 use Moose;
d03bd989 16
6b584f6c 17 ::lives_ok { extends 'Foo' } 'loaded Foo superclass correctly';
d7f17ebb 18}
19
20{
6b584f6c 21
d7f17ebb 22 package Baz;
d7f17ebb 23 use Moose;
d03bd989 24
6b584f6c 25 ::lives_ok { extends 'Bar' } 'loaded (inline) Bar superclass correctly';
d7f17ebb 26}
27
28{
6b584f6c 29
d7f17ebb 30 package Foo::Bar;
d7f17ebb 31 use Moose;
d03bd989 32
6b584f6c 33 ::lives_ok { extends 'Foo', 'Bar' }
34 'loaded Foo and (inline) Bar superclass correctly';
d7f17ebb 35}
36
7eaef7ad 37{
6b584f6c 38
7eaef7ad 39 package Bling;
7eaef7ad 40 use Moose;
d03bd989 41
6b584f6c 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';
7eaef7ad 45}
46
2e7f6cf4 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
a28e50e4 69done_testing;