6 use Test::More tests => 16;
12 package Foo::Meta::Attribute;
15 extends 'Mouse::Meta::Attribute';
21 $next->($self, $name, (is => 'rw', isa => 'Foo'), @_);
27 has 'foo' => (metaclass => 'Foo::Meta::Attribute');
33 my $foo_attr = Foo->meta->get_attribute('foo');
34 isa_ok($foo_attr, 'Foo::Meta::Attribute');
35 isa_ok($foo_attr, 'Mouse::Meta::Attribute');
37 is($foo_attr->name, 'foo', '... got the right name for our meta-attribute');
38 ok($foo_attr->has_accessor, '... our meta-attrubute created the accessor for us');
40 ok($foo_attr->has_type_constraint, '... our meta-attrubute created the type_constraint for us');
42 my $foo_attr_type_constraint = $foo_attr->type_constraint;
43 isa_ok($foo_attr_type_constraint, 'Mouse::Meta::TypeConstraint');
45 is($foo_attr_type_constraint->name, 'Foo', '... got the right type constraint name');
47 local $TODO = '$type_constraint->parent is not reliable';
48 is($foo_attr_type_constraint->parent, 'Object', '... got the right type constraint parent name');
51 package Bar::Meta::Attribute;
54 #extends 'Class::MOP::Attribute';
55 extends 'Foo::Meta::Attribute';
61 has 'bar' => (metaclass => 'Bar::Meta::Attribute');
62 } '... the attribute metaclass need not be a Mouse::Meta::Attribute as long as it behaves';
66 package Mouse::Meta::Attribute::Custom::Foo;
67 sub register_implementation { 'Foo::Meta::Attribute' }
69 package Mouse::Meta::Attribute::Custom::Bar;
72 extends 'Mouse::Meta::Attribute';
78 has 'foo' => (metaclass => 'Foo');
79 } '... the attribute metaclass alias worked correctly';
82 has 'bar' => (metaclass => 'Bar', is => 'bare');
83 } '... the attribute metaclass alias worked correctly';
87 my $foo_attr = Another::Foo->meta->get_attribute('foo');
88 isa_ok($foo_attr, 'Foo::Meta::Attribute');
89 isa_ok($foo_attr, 'Mouse::Meta::Attribute');
91 my $bar_attr = Another::Foo->meta->get_attribute('bar');
92 isa_ok($bar_attr, 'Mouse::Meta::Attribute::Custom::Bar');
93 isa_ok($bar_attr, 'Mouse::Meta::Attribute');