X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Moose-t-failing%2F030_roles%2F023_role_composition_attributes.t;fp=Moose-t-failing%2F030_roles%2F023_role_composition_attributes.t;h=4c04817e30b9f7c69e3304a3f154558119012b2b;hb=c47cf41554416ee1828eab17d31342a53aaa0839;hp=0000000000000000000000000000000000000000;hpb=9864f0e4ba233c5f30ad6dc7c484ced43d883d27;p=gitmo%2FMouse.git diff --git a/Moose-t-failing/030_roles/023_role_composition_attributes.t b/Moose-t-failing/030_roles/023_role_composition_attributes.t new file mode 100644 index 0000000..4c04817 --- /dev/null +++ b/Moose-t-failing/030_roles/023_role_composition_attributes.t @@ -0,0 +1,99 @@ +#!/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; + has 'foo' => (is => 'rw'); + + package Role::Bar; + use Mouse::Role; + has 'bar' => (is => 'rw'); + + package Role::FooConflict; + use Mouse::Role; + has 'foo' => (is => 'rw'); + + package Role::BarConflict; + use Mouse::Role; + has 'bar' => (is => 'rw'); + + package Role::AnotherFooConflict; + use Mouse::Role; + with 'Role::FooConflict'; +} + +# test simple attributes +{ + 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_attribute_list ], + [ 'bar', 'foo' ], + '... got the right list of attributes' + ); +} + +# test simple conflict +dies_ok { + Mouse::Meta::Role::Application->new->apply( + Mouse::Meta::Role::Composite->new( + roles => [ + Role::Foo->meta, + Role::FooConflict->meta, + ] + ) + ); +} '... this fails as expected'; + +# test complex conflict +dies_ok { + Mouse::Meta::Role::Application->new->apply( + Mouse::Meta::Role::Composite->new( + roles => [ + Role::Foo->meta, + Role::Bar->meta, + Role::FooConflict->meta, + Role::BarConflict->meta, + ] + ) + ); +} '... this fails as expected'; + +# test simple conflict +dies_ok { + Mouse::Meta::Role::Application->new->apply( + Mouse::Meta::Role::Composite->new( + roles => [ + Role::Foo->meta, + Role::AnotherFooConflict->meta, + ] + ) + ); +} '... this fails as expected'; + +done_testing;