Commit | Line | Data |
e522431d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
b43a4bca |
6 | use Test::More tests => 6; |
e522431d |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
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 | } |
8ecb1fa0 |
37 | |
38 | __PACKAGE__->meta->make_immutable(debug => 0); |
b43a4bca |
39 | |
40 | package Bucket; |
41 | |
42 | use metaclass 'Class::MOP::Class'; |
43 | |
44 | __PACKAGE__->meta->add_attribute('squeegee' => (accessor => 'squeegee')); |
45 | |
46 | package Old::Bucket::Nose; |
47 | |
48 | # see http://www.moosefoundation.org/moose_facts.htm |
49 | |
50 | use Moose; |
51 | |
52 | extends 'Bucket'; |
2f9e53fb |
53 | |
54 | # XXX FIXME subclassing meta-attrs and immutable-ing the subclass fails |
e522431d |
55 | } |
56 | |
57 | my $foo_moose = Foo::Moose->new(); |
58 | isa_ok($foo_moose, 'Foo::Moose'); |
59 | isa_ok($foo_moose, 'Elk'); |
60 | |
61 | is($foo_moose->no_moose, 'Elk', '... got the right value from the Elk method'); |
b43a4bca |
62 | is($foo_moose->moose, 'Foo', '... got the right value from the Foo::Moose method'); |
63 | |
64 | lives_ok { Old::Bucket::Nose->meta->make_immutable(debug => 0); } |
d66bea3c |
65 | 'Immutability on Moose class extending Class::MOP class ok'; |