X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t-failing%2F020_attributes%2F010_attribute_delegation.t;fp=t%2F020_attributes%2Ffailing%2F010_attribute_delegation.t;h=b111bc88a84fdcea3b5116d9f0f033155bb3f5c9;hb=fde8e43f95fe996fbc2a778aa259feeb04552171;hp=9dd746a239190afbeebce444927f60c45a6c1759;hpb=0bdc9d38dfd3de07aad929f6629f8fa65d434c27;p=gitmo%2FMouse.git diff --git a/t/020_attributes/failing/010_attribute_delegation.t b/t-failing/020_attributes/010_attribute_delegation.t similarity index 90% rename from t/020_attributes/failing/010_attribute_delegation.t rename to t-failing/020_attributes/010_attribute_delegation.t index 9dd746a..b111bc8 100644 --- a/t/020_attributes/failing/010_attribute_delegation.t +++ b/t-failing/020_attributes/010_attribute_delegation.t @@ -1,13 +1,16 @@ #!/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 tests => 92; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - # ------------------------------------------------------------------- # HASH handles # ------------------------------------------------------------------- @@ -44,7 +47,7 @@ ok($bar->foo, '... we have something in bar->foo'); isa_ok($bar->foo, 'Foo'); my $meth = Bar->meta->get_method('foo_bar'); -isa_ok($meth, 'Mouse::Meta::Method::Delegation'); +isa_ok($meth, 'Mouse::Meta::Method'); is($meth->associated_attribute->name, 'foo', 'associated_attribute->name for this method is foo'); @@ -244,6 +247,15 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); handles => 'Foo::Bar', ); + package Foo::OtherThing; + use Mouse; + use Mouse::Util::TypeConstraints; + + has 'other_thing' => ( + is => 'rw', + isa => 'Foo::Baz', + handles => Mouse::Util::TypeConstraints::find_type_constraint('Foo::Bar'), + ); } { @@ -260,6 +272,19 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); is($foo->thing->baz, 'Foo::Baz::BAZ', '... got the right value'); } +{ + my $foo = Foo::OtherThing->new(other_thing => Foo::Baz->new); + isa_ok($foo, 'Foo::OtherThing'); + isa_ok($foo->other_thing, 'Foo::Baz'); + + ok($foo->meta->has_method('foo'), '... we have the method we expect'); + ok($foo->meta->has_method('bar'), '... we have the method we expect'); + ok(!$foo->meta->has_method('baz'), '... we dont have the method we expect'); + + is($foo->foo, 'Foo::Baz::FOO', '... got the right value'); + is($foo->bar, 'Foo::Baz::BAR', '... got the right value'); + is($foo->other_thing->baz, 'Foo::Baz::BAZ', '... got the right value'); +} # ------------------------------------------------------------------- # AUTOLOAD & handles # ------------------------------------------------------------------- @@ -434,3 +459,5 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); my $k = Bar->new(foo => "Foo"); lives_ok { $k->foo_baz } "but not for class name"; } + +done_testing;