6 use Test::More tests => 26;
9 use_ok("Moose::Util::TypeConstraints");
12 ## check the containers
14 ok(Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
15 '... this correctly detected a container (' . $_ . ')')
18 'ArrayRef[Foo | Int]',
19 'ArrayRef[ArrayRef[Int]]',
20 'ArrayRef[ArrayRef[Int | Foo]]',
23 ok(!Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
24 '... this correctly detected a non-container (' . $_ . ')')
32 'ArrayRef[Foo]' => [ 'ArrayRef', 'Foo' ],
33 'ArrayRef[Foo | Int]' => [ 'ArrayRef', 'Foo | Int' ],
34 # these will get processed with recusion,
35 # so we only need to detect it once
36 'ArrayRef[ArrayRef[Int]]' => [ 'ArrayRef', 'ArrayRef[Int]' ],
37 'ArrayRef[ArrayRef[Int | Foo]]' => [ 'ArrayRef', 'ArrayRef[Int | Foo]' ],
41 [ Moose::Util::TypeConstraints::_parse_parameterized_type_constraint($_) ],
43 '... this correctly split the container (' . $_ . ')'
44 ) for keys %split_tests;
49 ok(Moose::Util::TypeConstraints::_detect_type_constraint_union($_),
50 '... this correctly detected union (' . $_ . ')')
53 'ArrayRef[Foo] | Int',
54 'Int | ArrayRef[Foo]',
55 'ArrayRef[Foo | Int] | Str',
56 'Str | ArrayRef[Foo | Int]',
57 'Some|Silly|Name|With|Pipes | Int',
60 ok(!Moose::Util::TypeConstraints::_detect_type_constraint_union($_),
61 '... this correctly detected a non-union (' . $_ . ')')
64 'ArrayRef[Foo | Int]',
65 'Some|Silly|Name|With|Pipes',
70 'Int | Str' => [ 'Int', 'Str' ],
71 'ArrayRef[Foo] | Int' => [ 'ArrayRef[Foo]', 'Int' ],
72 'Int | ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ],
73 'ArrayRef[Foo | Int] | Str' => [ 'ArrayRef[Foo | Int]', 'Str' ],
74 'Str | ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ],
75 'Some|Silly|Name|With|Pipes | Int' => [ 'Some|Silly|Name|With|Pipes', 'Int' ],
79 [ Moose::Util::TypeConstraints::_parse_type_constraint_union($_) ],
81 '... this correctly split the union (' . $_ . ')'
82 ) for keys %split_tests;