X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F001_mouse%2F019-handles.t;h=5bae5a9f13e25efb0b429c5db2bb219e727c9206;hb=4fbbc6564dcc9332bb0c8dc073e66fb4d82fdf9d;hp=9208a3c8fc6475922b293cc68fabf8ddca921c3d;hpb=920139b3efca66d2caeeef306c97fa0da62c6b73;p=gitmo%2FMouse.git diff --git a/t/001_mouse/019-handles.t b/t/001_mouse/019-handles.t index 9208a3c..5bae5a9 100644 --- a/t/001_mouse/019-handles.t +++ b/t/001_mouse/019-handles.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 28; +use Test::More tests => 26; use Test::Exception; do { @@ -17,6 +17,11 @@ do { sub name { $_[0]->{name} = $_[1] if @_ > 1; $_[0]->{name} } sub age { $_[0]->{age} = $_[1] if @_ > 1; $_[0]->{age} } + sub make_string { + my($self, $template) = @_; + return sprintf $template, $self->name; + } + package Class; use Mouse; @@ -28,6 +33,7 @@ do { handles => { person_name => 'name', person_age => 'age', + person_hello => [make_string => 'Hello, %s'], }, ); @@ -37,46 +43,6 @@ do { predicate => 'quid', handles => [qw/name age/], ); - - TODO: { - local our $TODO = "Mouse lacks this"; - eval { - has error => ( - handles => "string", - ); - }; - ::ok(!$@, "handles => role"); - } - - TODO: { - local our $TODO = "Mouse lacks this"; - eval { - has error2 => ( - handles => \"ref_to_string", - ); - }; - ::ok(!$@, "handles => \\str"); - } - - TODO: { - local our $TODO = "Mouse lacks this"; - eval { - has error3 => ( - handles => qr/regex/, - ); - }; - ::ok(!$@, "handles => qr/re/"); - } - - TODO: { - local our $TODO = "Mouse lacks this"; - eval { - has error4 => ( - handles => sub { "code" }, - ); - }; - ::ok(!$@, "handles => sub { code }"); - } }; can_ok(Class => qw(person has_person person_name person_age name age quid)); @@ -91,6 +57,7 @@ is($object->person_name, "Todd", "handles method"); is($object->person->name, "Todd", "traditional lookup"); is($object->person_age, 37, "handles method"); is($object->person->age, 37, "traditional lookup"); +is($object->person_hello, 'Hello, Todd', 'curring'); my $object2 = Class->new(person => Person->new(name => "Philbert")); ok($object2->has_person, "we have a person from the constructor"); @@ -98,7 +65,7 @@ is($object2->person_name, "Philbert", "handles method"); is($object2->person->name, "Philbert", "traditional lookup"); is($object2->person_age, undef, "no age because we didn't use the default"); is($object2->person->age, undef, "no age because we didn't use the default"); - +is($object2->person_hello, 'Hello, Philbert', 'currying'); ok($object->quid, "we have a Shawn"); is($object->name, "Shawn", "name handle"); @@ -114,13 +81,12 @@ is_deeply( is_deeply( $object->meta->get_attribute('person')->handles, - { person_name => 'name', person_age => 'age' }, + { person_name => 'name', person_age => 'age', person_hello => [make_string => 'Hello, %s']}, "correct handles layout for 'person'", ); { - local $TODO = "failed on some environment, but I don't know why it happens (gfx)"; throws_ok{ $object->person(undef); $object->person_name();