X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fforeign%2FMethod-Signatures%2Ftypeload_moose.t;fp=t%2Fforeign%2FMethod-Signatures%2Ftypeload_moose.t;h=2ece30dd06c892ef9938ed060e72fcc03b3d5977;hb=1a52f2db46f6d870454428a07bfae09e0359eeee;hp=c3d08c08fccc6edeed989909ecdaf0cb8ce39a9b;hpb=ff265988561375d3cf480004e29e3891094c0afb;p=p5sagit%2FFunction-Parameters.git diff --git a/t/foreign/Method-Signatures/typeload_moose.t b/t/foreign/Method-Signatures/typeload_moose.t index c3d08c0..2ece30d 100644 --- a/t/foreign/Method-Signatures/typeload_moose.t +++ b/t/foreign/Method-Signatures/typeload_moose.t @@ -5,23 +5,37 @@ use warnings FATAL => 'all'; use Dir::Self; use lib __DIR__ . '/lib'; -use Test::More - eval { require Moose; 1 } - ? (tests => 2) - : (skip_all => "Moose required for testing types") -; +use Test::More; +use Test::Fatal; -require MooseLoadTest; +SKIP: +{ + eval { require Moose } or skip "Moose required for testing Moose types", 1; -my $foobar = Foo::Bar->new; + require MooseLoadTest; -# can't check for type module not being loaded here, because Moose will drag it in + my $foobar = Foo::Bar->new; + # can't check for type module not being loaded here, because Moose will drag it in -$foobar->check_int(42); -# now we should have loaded Moose, not Mouse, to do our type checking + $foobar->check_int(42); -is $INC{'Mouse/Util/TypeConstraints.pm'}, undef, "didn't load Mouse"; -like $INC{'Moose/Util/TypeConstraints.pm'}, qr{Moose/Util/TypeConstraints\.pm$}, 'loaded Moose'; + # now we should have loaded Moose to do our type checking + + like $INC{'Moose/Util/TypeConstraints.pm'}, qr{Moose/Util/TypeConstraints\.pm$}, 'loaded Moose'; + + + # tests for ScalarRef[X] have to live here, because they only work with Moose + + my $method = 'check_paramized_sref'; + my $bad_ref = \'thing'; + is exception { $foobar->$method(\42) }, undef, 'call with good value for paramized_sref passes'; + like exception { $foobar->$method($bad_ref) }, + qr/\bcheck_paramized_sref\b.+\$bar\b.+ScalarRef\[Num\]/, + 'call with bad value for paramized_sref dies'; +} + + +done_testing;