bah
[gitmo/Moose.git] / t / 050_metaclasses / 010_extending_and_embedding.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 8;
7 use Test::Exception;
8
9 BEGIN {
10     use_ok('Moose');
11 }
12
13 BEGIN {
14     package MyFramework::Base;
15     use Moose;
16     
17     package MyFramework::Meta::Base;
18     use Moose;  
19     
20     extends 'Moose::Meta::Class';  
21     
22     package MyFramework;
23     use Moose;
24
25     sub import {
26         my $CALLER = caller();
27
28         strict->import;
29         warnings->import;
30         
31         return if $CALLER eq 'main';
32         Moose::init_meta( $CALLER, 'MyFramework::Base', 'MyFramework::Meta::Base' );
33         Moose->import({ into => $CALLER });
34
35         return 1;
36     }
37 }
38
39 {   
40     package MyClass;
41     BEGIN { MyFramework->import }
42     
43     has 'foo' => (is => 'rw');
44 }
45
46 can_ok( 'MyClass', 'meta' );
47
48 isa_ok(MyClass->meta, 'MyFramework::Meta::Base');
49 isa_ok(MyClass->meta, 'Moose::Meta::Class');
50
51 my $obj = MyClass->new(foo => 10);
52 isa_ok($obj, 'MyClass');
53 isa_ok($obj, 'MyFramework::Base');
54 isa_ok($obj, 'Moose::Object');
55
56 is($obj->foo, 10, '... got the right value');
57
58
59
60