X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F019-handles.t;h=10acf1ea6dddcd65e75fef1f80bc6519f47183b3;hb=1b9e472d8c7e704eced9b2ea83194f83f0265018;hp=5f4e51f0f427d21a62e172bd729255bd95af4edb;hpb=6fbbcaf48a79f9cb43d436dba0b508f2607ac0ae;p=gitmo%2FMouse.git diff --git a/t/019-handles.t b/t/019-handles.t index 5f4e51f..10acf1e 100644 --- a/t/019-handles.t +++ b/t/019-handles.t @@ -1,7 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 20; +use Test::More tests => 28; +use Test::Exception; do { package Person; @@ -38,39 +39,43 @@ do { ); TODO: { - local $::TODO = "handles => role"; + local our $TODO = "Mouse lacks this"; eval { has error => ( handles => "string", ); }; + ::ok(!$@, "handles => role"); } TODO: { - local $::TODO = "handles => \\str"; + local our $TODO = "Mouse lacks this"; eval { has error2 => ( handles => \"ref_to_string", ); }; + ::ok(!$@, "handles => \\str"); } TODO: { - local $::TODO = "handles => qr/re/"; + local our $TODO = "Mouse lacks this"; eval { has error3 => ( handles => qr/regex/, ); }; + ::ok(!$@, "handles => qr/re/"); } TODO: { - local $::TODO = "handles => sub { code }"; + local our $TODO = "Mouse lacks this"; eval { has error4 => ( handles => sub { "code" }, ); }; + ::ok(!$@, "handles => sub { code }"); } }; @@ -113,3 +118,30 @@ is_deeply( "correct handles layout for 'person'", ); + +{ + local $TODO = "failed in 5.10.1, but I don't know why (gfx)" if $] == 5.010_001; + throws_ok{ + $object->person(undef); + $object->person_name(); + } qr/Cannot delegate person_name to name because the value of person is not defined/; + + throws_ok{ + $object->person([]); + $object->person_age(); + } qr/Cannot delegate person_age to age because the value of person is not an object/; +} + +eval{ + $object->person(undef); + $object->person_name(); +}; +like $@, qr/Cannot delegate person_name to name because the value of person is not defined/; + +eval{ + $object->person([]); + $object->person_age(); +}; +like $@, qr/Cannot delegate person_age to age because the value of person is not an object/; + +