Commit | Line | Data |
7e030e45 |
1 | #!perl |
2 | # https://rt.cpan.org/Public/Bug/Display.html?id=61852 |
3 | use strict; |
4 | use warnings; |
5 | use Test::More; |
6 | { |
7 | package X; |
8 | use Mouse; |
9 | use Mouse::Util::TypeConstraints; |
10 | |
11 | subtype 'List' |
12 | => as 'ArrayRef[Any]' |
13 | => where { |
14 | foreach my $item(@{$_}) { |
15 | defined($item) or return 0; |
16 | } |
17 | return 1; |
18 | }; |
19 | |
20 | has 'list' => ( |
21 | is => 'ro', |
22 | isa => 'List', |
23 | ); |
24 | } |
25 | |
26 | eval { X->new(list => [ 1, 2, 3 ]) }; |
27 | is $@, ''; |
28 | |
29 | eval { X->new(list => [ 1, undef, 3 ]) }; |
30 | like $@, qr/Validation[ ]failed[ ]for[ ]'List'/xms; |
31 | done_testing; |