8 use Moose::Util::TypeConstraints;
12 This is a good candidate for LectroTest
17 ## check the containers
19 ok(Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
20 '... this correctly detected a container (' . $_ . ')')
23 'ArrayRef[Foo | Int]',
24 'ArrayRef[ArrayRef[Int]]',
25 'ArrayRef[ArrayRef[Int | Foo]]',
26 'ArrayRef[ArrayRef[Int|Str]]',
29 ok(!Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
30 '... this correctly detected a non-container (' . $_ . ')')
38 'ArrayRef[Foo]' => [ 'ArrayRef', 'Foo' ],
39 'ArrayRef[Foo | Int]' => [ 'ArrayRef', 'Foo | Int' ],
40 'ArrayRef[Foo|Int]' => [ 'ArrayRef', 'Foo|Int' ],
41 # these will get processed with recusion,
42 # so we only need to detect it once
43 'ArrayRef[ArrayRef[Int]]' => [ 'ArrayRef', 'ArrayRef[Int]' ],
44 'ArrayRef[ArrayRef[Int | Foo]]' => [ 'ArrayRef', 'ArrayRef[Int | Foo]' ],
45 'ArrayRef[ArrayRef[Int|Str]]' => [ 'ArrayRef', 'ArrayRef[Int|Str]' ],
49 [ Moose::Util::TypeConstraints::_parse_parameterized_type_constraint($_) ],
51 '... this correctly split the container (' . $_ . ')'
52 ) for keys %split_tests;
57 ok(Moose::Util::TypeConstraints::_detect_type_constraint_union($_),
58 '... this correctly detected union (' . $_ . ')')
62 'ArrayRef[Foo] | Int',
64 'Int | ArrayRef[Foo]',
66 'ArrayRef[Foo | Int] | Str',
67 'ArrayRef[Foo|Int]|Str',
68 'Str | ArrayRef[Foo | Int]',
69 'Str|ArrayRef[Foo|Int]',
70 'Some|Silly|Name|With|Pipes | Int',
71 'Some|Silly|Name|With|Pipes|Int',
74 ok(!Moose::Util::TypeConstraints::_detect_type_constraint_union($_),
75 '... this correctly detected a non-union (' . $_ . ')')
78 'ArrayRef[Foo | Int]',
84 'Int | Str' => [ 'Int', 'Str' ],
85 'Int|Str' => [ 'Int', 'Str' ],
86 'ArrayRef[Foo] | Int' => [ 'ArrayRef[Foo]', 'Int' ],
87 'ArrayRef[Foo]|Int' => [ 'ArrayRef[Foo]', 'Int' ],
88 'Int | ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ],
89 'Int|ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ],
90 'ArrayRef[Foo | Int] | Str' => [ 'ArrayRef[Foo | Int]', 'Str' ],
91 'ArrayRef[Foo|Int]|Str' => [ 'ArrayRef[Foo|Int]', 'Str' ],
92 'Str | ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ],
93 'Str|ArrayRef[Foo|Int]' => [ 'Str', 'ArrayRef[Foo|Int]' ],
94 'Some|Silly|Name|With|Pipes | Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ],
95 'Some|Silly|Name|With|Pipes|Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ],
99 [ Moose::Util::TypeConstraints::_parse_type_constraint_union($_) ],
101 '... this correctly split the union (' . $_ . ')'
102 ) for keys %split_tests;