File: moose_respects_base.t

package info (click to toggle)
libmoose-perl 2.2207-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,416 kB
  • sloc: perl: 21,345; ansic: 291; makefile: 10
file content (46 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use strict;
use warnings;

use Test::More;


=pod

This test demonstrates that Moose will respect
a previously set @ISA using use base, and not
try to add Moose::Object to it.

However, this is extremely order sensitive as
this test also demonstrates.

=cut

{
    package Foo;
    use strict;
    use warnings;

    sub foo { 'Foo::foo' }

    package Bar;
    use parent -norequire => 'Foo';
    use Moose;

    sub new { (shift)->meta->new_object(@_) }

    package Baz;
    use Moose;
    use parent -norequire => 'Foo';
}

my $bar = Bar->new;
isa_ok($bar, 'Bar');
isa_ok($bar, 'Foo');
ok(!$bar->isa('Moose::Object'), '... Bar is not Moose::Object subclass');

my $baz = Baz->new;
isa_ok($baz, 'Baz');
isa_ok($baz, 'Foo');
isa_ok($baz, 'Moose::Object');

done_testing;