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