Moose now warns when you try to load it from the main package. Added a
[gitmo/Moose.git] / t / 060_compat / 002_moose_respects_base.t
CommitLineData
7eaef7ad 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
7ff56534 6use Test::More tests => 6;
7eaef7ad 7use Test::Exception;
8
7ff56534 9
7eaef7ad 10
bbd2fe69 11=pod
12
13This test demonstrates that Moose will respect
14a previously set @ISA using use base, and not
15try to add Moose::Object to it.
16
17However, this is extremely order sensitive as
18this test also demonstrates.
19
20=cut
21
7eaef7ad 22{
23 package Foo;
24 use strict;
25 use warnings;
26
27 sub foo { 'Foo::foo' }
28
c235cd98 29 package Bar;
7eaef7ad 30 use base 'Foo';
bbd2fe69 31 use Moose;
32
33 sub new { (shift)->meta->new_object(@_) }
34
35 package Baz;
bbd2fe69 36 use Moose;
37 use base 'Foo';
7eaef7ad 38}
39
40my $bar = Bar->new;
41isa_ok($bar, 'Bar');
bbd2fe69 42isa_ok($bar, 'Foo');
43ok(!$bar->isa('Moose::Object'), '... Bar is not Moose::Object subclass');
44
45my $baz = Baz->new;
46isa_ok($baz, 'Baz');
47isa_ok($baz, 'Foo');
48isa_ok($baz, 'Moose::Object');
49