stop closing over the method metaobject
[gitmo/Moose.git] / t / metaclasses / extending_and_embedding_back_compat.t
CommitLineData
688fcdda 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
688fcdda 7
7ff56534 8
688fcdda 9BEGIN {
10 package MyFramework::Base;
11 use Moose;
d03bd989 12
688fcdda 13 package MyFramework::Meta::Base;
d03bd989 14 use Moose;
15
16 extends 'Moose::Meta::Class';
17
688fcdda 18 package MyFramework;
19 use Moose;
ee52c565 20 use Moose::Deprecated -api_version => '0.55';
688fcdda 21
22 sub import {
23 my $CALLER = caller();
24
25 strict->import;
26 warnings->import;
d03bd989 27
688fcdda 28 return if $CALLER eq 'main';
29 Moose::init_meta( $CALLER, 'MyFramework::Base', 'MyFramework::Meta::Base' );
30 Moose->import({ into => $CALLER });
31
32 return 1;
33 }
34}
35
d03bd989 36{
688fcdda 37 package MyClass;
38 BEGIN { MyFramework->import }
d03bd989 39
688fcdda 40 has 'foo' => (is => 'rw');
41}
42
43can_ok( 'MyClass', 'meta' );
44
45isa_ok(MyClass->meta, 'MyFramework::Meta::Base');
46isa_ok(MyClass->meta, 'Moose::Meta::Class');
47
48my $obj = MyClass->new(foo => 10);
49isa_ok($obj, 'MyClass');
50isa_ok($obj, 'MyFramework::Base');
51isa_ok($obj, 'Moose::Object');
52
53is($obj->foo, 10, '... got the right value');
54
a28e50e4 55done_testing;