Moose now warns when you try to load it from the main package. Added a
[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 tests => 5;
9
10
11
12 {
13     package Bar;
14     use Moose;
15     
16     eval { extends 'Foo'; };
17     ::ok(!$@, '... loaded Foo superclass correctly');
18 }
19
20 {
21     package Baz;
22     use Moose;
23     
24     eval { extends 'Bar'; };
25     ::ok(!$@, '... loaded (inline) Bar superclass correctly');
26 }
27
28 {
29     package Foo::Bar;
30     use Moose;
31     
32     eval { extends 'Foo', 'Bar'; };
33     ::ok(!$@, '... loaded Foo and (inline) Bar superclass correctly');
34 }
35
36 {
37     package Bling;
38     use Moose;
39     
40     eval { extends 'No::Class'; };
41     ::ok($@, '... could not find the superclass (as expected)');
42     ::like($@, qr/^Could not load class \(No\:\:Class\) because \:/, '... and got the error we expected');
43 }
44