foo
[gitmo/Moose.git] / t / 020_foreign_inheritence.t
CommitLineData
e522431d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 5;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Moose');
11}
12
13{
14 package Elk;
15 use strict;
16 use warnings;
17
18 sub new {
19 my $class = shift;
20 bless { no_moose => "Elk" } => $class;
21 }
22
23 sub no_moose { $_[0]->{no_moose} }
24
c235cd98 25 package Foo::Moose;
e522431d 26 use Moose;
27
28 extends 'Elk';
29
30 has 'moose' => (is => 'ro', default => 'Foo');
31
32 sub new {
33 my $class = shift;
34 my $super = $class->SUPER::new(@_);
35 return $class->meta->new_object('__INSTANCE__' => $super, @_);
36 }
37}
38
39my $foo_moose = Foo::Moose->new();
40isa_ok($foo_moose, 'Foo::Moose');
41isa_ok($foo_moose, 'Elk');
42
43is($foo_moose->no_moose, 'Elk', '... got the right value from the Elk method');
44is($foo_moose->moose, 'Foo', '... got the right value from the Foo::Moose method');