9 use_ok("Moose::Util::TypeConstraints");
14 This is a good candidate for LectroTest
19 ## check the containers
21 ok(Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
22 '... this correctly detected a container (' . $_ . ')')
25 'ArrayRef[Foo | Int]',
26 'ArrayRef[ArrayRef[Int]]',
27 'ArrayRef[ArrayRef[Int | Foo]]',
28 'ArrayRef[ArrayRef[Int|Str]]',
31 ok(!Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
32 '... this correctly detected a non-container (' . $_ . ')')
40 'ArrayRef[Foo]' => [ 'ArrayRef', 'Foo' ],
41 'ArrayRef[Foo | Int]' => [ 'ArrayRef', 'Foo | Int' ],
42 'ArrayRef[Foo|Int]' => [ 'ArrayRef', 'Foo|Int' ],
43 # these will get processed with recusion,
44 # so we only need to detect it once
45 'ArrayRef[ArrayRef[Int]]' => [ 'ArrayRef', 'ArrayRef[Int]' ],
46 'ArrayRef[ArrayRef[Int | Foo]]' => [ 'ArrayRef', 'ArrayRef[Int | Foo]' ],
47 'ArrayRef[ArrayRef[Int|Str]]' => [ 'ArrayRef', 'ArrayRef[Int|Str]' ],
51 [ Moose::Util::TypeConstraints::_parse_parameterized_type_constraint($_) ],
53 '... this correctly split the container (' . $_ . ')'
54 ) for keys %split_tests;
59 ok(Moose::Util::TypeConstraints::_detect_type_constraint_union($_),
60 '... this correctly detected union (' . $_ . ')')
64 'ArrayRef[Foo] | Int',
66 'Int | ArrayRef[Foo]',
68 'ArrayRef[Foo | Int] | Str',
69 'ArrayRef[Foo|Int]|Str',
70 'Str | ArrayRef[Foo | Int]',
71 'Str|ArrayRef[Foo|Int]',
72 'Some|Silly|Name|With|Pipes | Int',
73 'Some|Silly|Name|With|Pipes|Int',
76 ok(!Moose::Util::TypeConstraints::_detect_type_constraint_union($_),
77 '... this correctly detected a non-union (' . $_ . ')')
80 'ArrayRef[Foo | Int]',
86 'Int | Str' => [ 'Int', 'Str' ],
87 'Int|Str' => [ 'Int', 'Str' ],
88 'ArrayRef[Foo] | Int' => [ 'ArrayRef[Foo]', 'Int' ],
89 'ArrayRef[Foo]|Int' => [ 'ArrayRef[Foo]', 'Int' ],
90 'Int | ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ],
91 'Int|ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ],
92 'ArrayRef[Foo | Int] | Str' => [ 'ArrayRef[Foo | Int]', 'Str' ],
93 'ArrayRef[Foo|Int]|Str' => [ 'ArrayRef[Foo|Int]', 'Str' ],
94 'Str | ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ],
95 'Str|ArrayRef[Foo|Int]' => [ 'Str', 'ArrayRef[Foo|Int]' ],
96 'Some|Silly|Name|With|Pipes | Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ],
97 'Some|Silly|Name|With|Pipes|Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ],
101 [ Moose::Util::TypeConstraints::_parse_type_constraint_union($_) ],
103 '... this correctly split the union (' . $_ . ')'
104 ) for keys %split_tests;