From: Dave Rolsky Date: Sun, 13 Feb 2011 19:51:31 +0000 (-0600) Subject: Add tests to make sure that metaclass object know about roles that use MXCA X-Git-Tag: v0.23~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=26fcf8918699b20988518d7a82ce8e786767168b;p=gitmo%2FMooseX-ClassAttribute.git Add tests to make sure that metaclass object know about roles that use MXCA --- diff --git a/t/06-role.t b/t/06-role.t index b6fe678..fb1cbb5 100644 --- a/t/06-role.t +++ b/t/06-role.t @@ -45,8 +45,23 @@ use Moose::Util qw( apply_all_roles ); } } +is_deeply( + [ map { $_->name() } ClassWithRoleHCA->meta()->calculate_all_roles() ], + ['RoleHCA'], + 'ClassWithRoleHCA does RoleHCA' +); + SharedTests::run_tests('ClassWithRoleHCA'); +ClassWithRoleHCA->meta()->make_immutable(); + +is_deeply( + [ map { $_->name() } ClassWithRoleHCA->meta()->calculate_all_roles() ], + ['RoleHCA'], + 'ClassWithRoleHCA (immutable) does RoleHCA' +); + + # These next tests are aimed at testing to-role application followed by # to-class application { @@ -84,8 +99,22 @@ SharedTests::run_tests('ClassWithRoleHCA'); } } +is_deeply( + [ map { $_->name() } ClassWithRoleHCA->meta()->calculate_all_roles() ], + ['RoleHCA'], + 'ClassWithRoleWithRoleHCA does RoleHCA' +); + SharedTests::run_tests('ClassWithRoleWithRoleHCA'); +ClassWithRoleWithRoleHCA->meta()->make_immutable(); + +is_deeply( + [ map { $_->name() } ClassWithRoleHCA->meta()->calculate_all_roles() ], + ['RoleHCA'], + 'ClassWithRoleWithRoleHCA (immutable) does RoleHCA' +); + { package InstanceWithRoleHCA; @@ -108,8 +137,22 @@ my $instance = InstanceWithRoleHCA->new(); apply_all_roles( $instance, 'RoleHCA' ); +is_deeply( + [ map { $_->name() } $instance->meta()->calculate_all_roles() ], + ['RoleHCA'], + '$instance does RoleHCA' +); + $instance->ObjectCount(1); SharedTests::run_tests($instance); +$instance->meta()->make_immutable(); + +is_deeply( + [ map { $_->name() } $instance->meta()->calculate_all_roles() ], + ['RoleHCA'], + '$instance (immutable) does RoleHCA' +); + done_testing();