X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Moose-t-failing%2F030_roles%2F026_role_composition_method_mods.t;fp=Moose-t-failing%2F030_roles%2F026_role_composition_method_mods.t;h=94eee114d529eb38cd886c2cb233aff3c493f301;hb=c47cf41554416ee1828eab17d31342a53aaa0839;hp=0000000000000000000000000000000000000000;hpb=9864f0e4ba233c5f30ad6dc7c484ced43d883d27;p=gitmo%2FMouse.git diff --git a/Moose-t-failing/030_roles/026_role_composition_method_mods.t b/Moose-t-failing/030_roles/026_role_composition_method_mods.t new file mode 100644 index 0000000..94eee11 --- /dev/null +++ b/Moose-t-failing/030_roles/026_role_composition_method_mods.t @@ -0,0 +1,92 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +use Mouse::Meta::Role::Application; +use Mouse::Meta::Role::Composite; + +{ + package Role::Foo; + use Mouse::Role; + + before foo => sub { 'Role::Foo::foo' }; + around foo => sub { 'Role::Foo::foo' }; + after foo => sub { 'Role::Foo::foo' }; + around baz => sub { [ 'Role::Foo', @{shift->(@_)} ] }; + + package Role::Bar; + use Mouse::Role; + + before bar => sub { 'Role::Bar::bar' }; + around bar => sub { 'Role::Bar::bar' }; + after bar => sub { 'Role::Bar::bar' }; + + package Role::Baz; + use Mouse::Role; + + with 'Role::Foo'; + around baz => sub { [ 'Role::Baz', @{shift->(@_)} ] }; + +} + +{ + package Class::FooBar; + use Mouse; + + with 'Role::Baz'; + sub foo { 'placeholder' } + sub baz { ['Class::FooBar'] } +} + +#test modifier call order +{ + is_deeply( + Class::FooBar->baz, + ['Role::Baz','Role::Foo','Class::FooBar'] + ); +} + +# test simple overrides +{ + my $c = Mouse::Meta::Role::Composite->new( + roles => [ + Role::Foo->meta, + Role::Bar->meta, + ] + ); + isa_ok($c, 'Mouse::Meta::Role::Composite'); + + is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); + + lives_ok { + Mouse::Meta::Role::Application->new->apply($c); + } '... this succeeds as expected'; + + is_deeply( + [ sort $c->get_method_modifier_list('before') ], + [ 'bar', 'foo' ], + '... got the right list of methods' + ); + + is_deeply( + [ sort $c->get_method_modifier_list('after') ], + [ 'bar', 'foo' ], + '... got the right list of methods' + ); + + is_deeply( + [ sort $c->get_method_modifier_list('around') ], + [ 'bar', 'baz', 'foo' ], + '... got the right list of methods' + ); +} + +done_testing;