Commit | Line | Data |
688fcdda |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
7ff56534 |
6 | use Test::More tests => 7; |
688fcdda |
7 | use Test::Exception; |
8 | |
7ff56534 |
9 | |
688fcdda |
10 | |
11 | BEGIN { |
12 | package MyFramework::Base; |
13 | use Moose; |
14 | |
15 | package MyFramework::Meta::Base; |
16 | use Moose; |
17 | |
18 | extends 'Moose::Meta::Class'; |
19 | |
20 | package MyFramework; |
21 | use Moose; |
22 | |
23 | sub import { |
24 | my $CALLER = caller(); |
25 | |
26 | strict->import; |
27 | warnings->import; |
28 | |
29 | return if $CALLER eq 'main'; |
30 | Moose::init_meta( $CALLER, 'MyFramework::Base', 'MyFramework::Meta::Base' ); |
31 | Moose->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, 'Moose::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, 'Moose::Object'); |
53 | |
54 | is($obj->foo, 10, '... got the right value'); |
55 | |
56 | |
57 | |
58 | |