From: Dave Rolsky Date: Sun, 10 May 2009 15:55:28 +0000 (-0500) Subject: Extend t0m's tests for mixed moose/non-moose parentage to make sure X-Git-Tag: 0.78~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1276b4c9fefb8de9231ce0515880a123a6165684;p=gitmo%2FMoose.git Extend t0m's tests for mixed moose/non-moose parentage to make sure that metaclass roles always end up propogated, even when there is multiple inheritance from various mixtures of Moose & non-Moose parents. --- diff --git a/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t b/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t index 3865848..ba212df 100644 --- a/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t +++ b/t/060_compat/004_extends_nonmoose_that_isa_moose_with_metarole.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 18; { package My::Role; @@ -25,5 +25,158 @@ use Test::More tests => 1; lives_ok { extends 'SubClassUseBase'; } - 'Can extend non-moose class with parent class that is a Moose class with a meta role'; + 'Can extend non-Moose class with parent class that is a Moose class with a meta role'; } + +{ + ok( SubSubClassUseBase->meta->meta->can('does_role') + && SubSubClassUseBase->meta->meta->does_role('My::Role'), + 'SubSubClassUseBase meta metaclass does the My::Role role' ); +} + +{ + package OtherClass; + use Moose; +} + +{ + package OtherSubClassUseBase; + use base 'OtherClass'; +} + +{ + package MultiParent1; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends qw( SubClassUseBase OtherSubClassUseBase ); + } + 'Can extend two non-Moose classes with parents that are different Moose metaclasses'; +} + +{ + ok( MultiParent1->meta->meta->can('does_role') + && MultiParent1->meta->meta->does_role('My::Role'), + 'MultiParent1 meta metaclass does the My::Role role' ); +} + +{ + package MultiParent2; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends qw( OtherSubClassUseBase SubClassUseBase ); + } + 'Can extend two non-Moose classes with parents that are different Moose metaclasses (reverse order)'; +} + +{ + ok( MultiParent2->meta->meta->can('does_role') + && MultiParent2->meta->meta->does_role('My::Role'), + 'MultiParent2 meta metaclass does the My::Role role' ); +} + +{ + package MultiParent3; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends qw( OtherClass SubClassUseBase ); + } + 'Can extend one Moose class and one non-Moose class'; +} + +{ + ok( MultiParent3->meta->meta->can('does_role') + && MultiParent3->meta->meta->does_role('My::Role'), + 'MultiParent3 meta metaclass does the My::Role role' ); +} + +{ + package MultiParent4; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends qw( SubClassUseBase OtherClass ); + } + 'Can extend one non-Moose class and one Moose class'; +} + +{ + ok( MultiParent4->meta->meta->can('does_role') + && MultiParent4->meta->meta->does_role('My::Role'), + 'MultiParent4 meta metaclass does the My::Role role' ); +} + +{ + package MultiChild1; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends 'MultiParent1'; + } + 'Can extend class that itself extends two non-Moose classes with Moose parents'; +} + +{ + ok( MultiChild1->meta->meta->can('does_role') + && MultiChild1->meta->meta->does_role('My::Role'), + 'MultiChild1 meta metaclass does the My::Role role' ); +} + +{ + package MultiChild2; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends 'MultiParent2'; + } + 'Can extend class that itself extends two non-Moose classes with Moose parents (reverse order)'; +} + +{ + ok( MultiChild2->meta->meta->can('does_role') + && MultiChild2->meta->meta->does_role('My::Role'), + 'MultiChild2 meta metaclass does the My::Role role' ); +} + +{ + package MultiChild3; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends 'MultiParent3'; + } + 'Can extend class that itself extends one Moose and one non-Moose parent'; +} + +{ + ok( MultiChild3->meta->meta->can('does_role') + && MultiChild3->meta->meta->does_role('My::Role'), + 'MultiChild3 meta metaclass does the My::Role role' ); +} + +{ + package MultiChild4; + use Moose; + use Test::More; + use Test::Exception; + lives_ok { + extends 'MultiParent4'; + } + 'Can extend class that itself extends one non-Moose and one Moose parent'; +} + +{ + ok( MultiChild4->meta->meta->can('does_role') + && MultiChild4->meta->meta->does_role('My::Role'), + 'MultiChild4 meta metaclass does the My::Role role' ); +} +