update foreign tests
[p5sagit/Function-Parameters.git] / t / foreign / MooseX-Method-Signatures / types.t
CommitLineData
1a52f2db 1#!perl
2use strict;
3use warnings FATAL => 'all';
4use Test::More
5 eval { require Moose; require MooseX::Types }
6 ? (tests => 4)
7 : (skip_all => "Moose, MooseX::Types required for testing types")
8;
9use Test::Fatal;
10
11{
12 package MyTypes;
13 use MooseX::Types::Moose qw/Str/;
14 use Moose::Util::TypeConstraints;
15 use MooseX::Types -declare => [qw/CustomType/];
16
17 BEGIN {
18 subtype CustomType,
19 as Str,
20 where { length($_) == 2 };
21 }
22}
23
24{
25 package TestClass;
26 use Function::Parameters qw(:strict);
27 BEGIN { MyTypes->import('CustomType') };
28 use MooseX::Types::Moose qw/ArrayRef/;
29 #use namespace::clean;
30
31 method foo ((CustomType) $bar) { }
32
33 method bar ((ArrayRef[CustomType]) $baz) { }
34}
35
36my $o = bless {} => 'TestClass';
37
38is(exception { $o->foo('42') }, undef);
39ok(exception { $o->foo('bar') });
40
41is(exception { $o->bar(['42', '23']) }, undef);
42ok(exception { $o->bar(['foo', 'bar']) });