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