update foreign tests
[p5sagit/Function-Parameters.git] / t / foreign / Method-Signatures / typeload_moose.t
1 #!perl
2
3 use strict;
4 use warnings FATAL => 'all';
5 use Dir::Self;
6 use lib __DIR__ . '/lib';
7
8 use Test::More;
9 use Test::Fatal;
10
11
12 SKIP:
13 {
14     eval { require Moose } or skip "Moose required for testing Moose types", 1;
15
16     require MooseLoadTest;
17
18     my $foobar = Foo::Bar->new;
19
20     # can't check for type module not being loaded here, because Moose will drag it in
21
22
23     $foobar->check_int(42);
24
25     # now we should have loaded Moose to do our type checking
26
27     like $INC{'Moose/Util/TypeConstraints.pm'}, qr{Moose/Util/TypeConstraints\.pm$}, 'loaded Moose';
28
29
30     # tests for ScalarRef[X] have to live here, because they only work with Moose
31
32     my $method = 'check_paramized_sref';
33     my $bad_ref = \'thing';
34     is exception { $foobar->$method(\42) }, undef, 'call with good value for paramized_sref passes';
35     like exception { $foobar->$method($bad_ref) },
36             qr/\bcheck_paramized_sref\b.+\$bar\b.+ScalarRef\[Num\]/,
37             'call with bad value for paramized_sref dies';
38 }
39
40
41 done_testing;