From: Jesse Luehrs Date: Sat, 12 Jun 2010 20:47:51 +0000 (-0500) Subject: fix tests for not checking attr or method metaclasses X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ftopic%2Fno_checking_attr_method_metaclasses;p=gitmo%2FMoose.git fix tests for not checking attr or method metaclasses --- diff --git a/t/050_metaclasses/015_metarole.t b/t/050_metaclasses/015_metarole.t index c91c2a6..70b7399 100644 --- a/t/050_metaclasses/015_metarole.t +++ b/t/050_metaclasses/015_metarole.t @@ -352,16 +352,17 @@ use Moose::Util::MetaRole; { ok( My::Class5->meta()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s does Role::Foo because it extends My::Class} ); - ok( My::Class5->meta()->attribute_metaclass()->meta()->does_role('Role::Foo'), - q{My::Class5->meta()'s attribute metaclass also does Role::Foo} ); - ok( My::Class5->meta()->method_metaclass()->meta()->does_role('Role::Foo'), - q{My::Class5->meta()'s method metaclass also does Role::Foo} ); ok( My::Class5->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s instance metaclass also does Role::Foo} ); ok( My::Class5->meta()->constructor_class()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s constructor class also does Role::Foo} ); ok( My::Class5->meta()->destructor_class()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s destructor class also does Role::Foo} ); + # attribute and method metaclasses aren't inherited + ok( !My::Class5->meta()->attribute_metaclass()->meta()->can('does_role'), + q{My::Class5->meta()'s attribute metaclass also does Role::Foo} ); + ok( !My::Class5->meta()->method_metaclass()->meta()->can('does_role'), + q{My::Class5->meta()'s method metaclass also does Role::Foo} ); } { @@ -443,8 +444,8 @@ use Moose::Util::MetaRole; q{... and My::Class8->meta() does Role::Foo because My::Class8 extends My::Class} ); ok( My::Class8->meta()->attribute_metaclass->meta()->does_role('Role::Bar'), q{apply Role::Bar to My::Class8->meta()->attribute_metaclass before extends} ); - ok( My::Class8->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), - q{... and My::Class8->meta()->attribute_metaclass does Role::Foo because My::Class8 extends My::Class} ); + ok( !My::Class8->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), + q{... and My::Class8->meta()->attribute_metaclass doesn't do Role::Foo because attribute metaclasses aren't inherited} ); } @@ -465,8 +466,8 @@ use Moose::Util::MetaRole; q{... and My::Class9->meta() does Role::Foo because My::Class9 extends My::Class} ); ok( My::Class9->meta()->attribute_metaclass->meta()->does_role('Role::Bar'), q{apply Role::Bar to My::Class9->meta()->attribute_metaclass before extends} ); - ok( My::Class9->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), - q{... and My::Class9->meta()->attribute_metaclass does Role::Foo because My::Class9 extends My::Class} ); + ok( !My::Class9->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), + q{... and My::Class9->meta()->attribute_metaclass doesn't do Role::Foo because attribute metaclasses aren't inherited} ); } # This tests applying meta roles to a metaclass's metaclass. This is diff --git a/t/050_metaclasses/050_metarole_backcompat.t b/t/050_metaclasses/050_metarole_backcompat.t index d4a6adf..5ef8560 100644 --- a/t/050_metaclasses/050_metarole_backcompat.t +++ b/t/050_metaclasses/050_metarole_backcompat.t @@ -353,16 +353,17 @@ use Moose::Util::MetaRole; { ok( My::Class5->meta()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s does Role::Foo because it extends My::Class} ); - ok( My::Class5->meta()->attribute_metaclass()->meta()->does_role('Role::Foo'), - q{My::Class5->meta()'s attribute metaclass also does Role::Foo} ); - ok( My::Class5->meta()->method_metaclass()->meta()->does_role('Role::Foo'), - q{My::Class5->meta()'s method metaclass also does Role::Foo} ); ok( My::Class5->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s instance metaclass also does Role::Foo} ); ok( My::Class5->meta()->constructor_class()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s constructor class also does Role::Foo} ); ok( My::Class5->meta()->destructor_class()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s destructor class also does Role::Foo} ); + # attribute and method metaclasses aren't inherited + ok( !My::Class5->meta()->attribute_metaclass()->meta()->can('does_role'), + q{My::Class5->meta()'s attribute metaclass also does Role::Foo} ); + ok( !My::Class5->meta()->method_metaclass()->meta()->can('does_role'), + q{My::Class5->meta()'s method metaclass also does Role::Foo} ); } { @@ -442,8 +443,8 @@ use Moose::Util::MetaRole; q{... and My::Class8->meta() does Role::Foo because My::Class8 extends My::Class} ); ok( My::Class8->meta()->attribute_metaclass->meta()->does_role('Role::Bar'), q{apply Role::Bar to My::Class8->meta()->attribute_metaclass before extends} ); - ok( My::Class8->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), - q{... and My::Class8->meta()->attribute_metaclass does Role::Foo because My::Class8 extends My::Class} ); + ok( !My::Class8->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), + q{... and My::Class8->meta()->attribute_metaclass doesn't do Role::Foo because attribute metaclasses aren't inherited} ); } @@ -464,8 +465,8 @@ use Moose::Util::MetaRole; q{... and My::Class9->meta() does Role::Foo because My::Class9 extends My::Class} ); ok( My::Class9->meta()->attribute_metaclass->meta()->does_role('Role::Bar'), q{apply Role::Bar to My::Class9->meta()->attribute_metaclass before extends} ); - ok( My::Class9->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), - q{... and My::Class9->meta()->attribute_metaclass does Role::Foo because My::Class9 extends My::Class} ); + ok( !My::Class9->meta()->attribute_metaclass->meta()->does_role('Role::Foo'), + q{... and My::Class9->meta()->attribute_metaclass doesn't do Role::Foo because attribute metaclasses aren't inherited} ); } # This tests applying meta roles to a metaclass's metaclass. This is diff --git a/t/200_examples/006_example_Protomoose.t b/t/200_examples/006_example_Protomoose.t index 09a82aa..2eee83d 100644 --- a/t/200_examples/006_example_Protomoose.t +++ b/t/200_examples/006_example_Protomoose.t @@ -154,6 +154,16 @@ Well cause merlyn asked if it could :) return $self->prototype_instance; }; + # XXX: not ideal, but it sort of works + around '_base_metaclasses' => sub { + my $next = shift; + my $self = shift; + return ( + $self->$next(@_), + 'attribute_metaclass' => 'Moose::Meta::Attribute' + ); + }; + } {