Commit | Line | Data |
220f2fbb |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | |
6 | { |
7 | package Test::MooseX::Types::Structured::StringyBug; |
8 | |
9 | use Moose; |
10 | use MooseX::Types::Moose qw(Str); |
11 | use MooseX::Types::Structured qw(Tuple Dict); |
12 | use Moose::Util::TypeConstraints; |
13 | |
14 | subtype "TestStringTypes::SubType", |
15 | as Str, |
16 | where { 1 }; |
17 | |
18 | has 'attr1' => ( |
19 | is => 'ro', |
20 | required => 1, |
21 | isa => Dict[ |
22 | foo1 => Str, |
23 | foo2 => "Int", |
24 | foo3 => "TestStringTypes::SubType", |
25 | ], |
26 | ); |
27 | |
28 | has 'attr2' => ( |
29 | is => 'ro', |
30 | required => 1, |
31 | isa => Tuple[ |
32 | Str, |
33 | "Int", |
34 | "TestStringTypes::SubType", |
35 | ], |
36 | ); |
37 | } |
38 | |
39 | my %init_args = ( |
40 | attr1 => { |
41 | foo1 => 'a', |
42 | foo2 => 2, |
43 | foo3 => 'c', |
44 | }, |
45 | attr2 => ['a', 2, 'c'], |
46 | ); |
47 | |
48 | ok( |
49 | Test::MooseX::Types::Structured::StringyBug->new(%init_args), |
50 | 'Made a class with mixed constraint types', |
51 | ); |
52 | |
53 | done_testing; |