Regenerate test files
[gitmo/Mouse.git] / t-failing / 040_type_constraints / 014_type_notation_parser.t
CommitLineData
b2b106d7 1#!/usr/bin/perl
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
b2b106d7 5
6use strict;
7use warnings;
8
fde8e43f 9use Test::More;
10$TODO = q{Mouse is not yet completed};
b2b106d7 11
12BEGIN {
13 use_ok("Mouse::Util::TypeConstraints");
14}
15
16=pod
17
18This is a good candidate for LectroTest
19Volunteers welcome :)
20
21=cut
22
23## check the containers
24
25ok(Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
26 '... this correctly detected a container (' . $_ . ')')
27 for (
28 'ArrayRef[Foo]',
29 'ArrayRef[Foo | Int]',
30 'ArrayRef[ArrayRef[Int]]',
31 'ArrayRef[ArrayRef[Int | Foo]]',
32 'ArrayRef[ArrayRef[Int|Str]]',
33);
34
35ok(!Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint($_),
36 '... this correctly detected a non-container (' . $_ . ')')
37 for (
38 'ArrayRef[]',
39 'ArrayRef[Foo]Bar',
40);
41
42{
43 my %split_tests = (
44 'ArrayRef[Foo]' => [ 'ArrayRef', 'Foo' ],
45 'ArrayRef[Foo | Int]' => [ 'ArrayRef', 'Foo | Int' ],
46 'ArrayRef[Foo|Int]' => [ 'ArrayRef', 'Foo|Int' ],
47 # these will get processed with recusion,
48 # so we only need to detect it once
49 'ArrayRef[ArrayRef[Int]]' => [ 'ArrayRef', 'ArrayRef[Int]' ],
50 'ArrayRef[ArrayRef[Int | Foo]]' => [ 'ArrayRef', 'ArrayRef[Int | Foo]' ],
51 'ArrayRef[ArrayRef[Int|Str]]' => [ 'ArrayRef', 'ArrayRef[Int|Str]' ],
52 );
53
54 is_deeply(
55 [ Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint($_) ],
56 $split_tests{$_},
57 '... this correctly split the container (' . $_ . ')'
58 ) for keys %split_tests;
59}
60
61## now for the unions
62
63ok(Mouse::Util::TypeConstraints::_detect_type_constraint_union($_),
64 '... this correctly detected union (' . $_ . ')')
65 for (
66 'Int | Str',
67 'Int|Str',
68 'ArrayRef[Foo] | Int',
69 'ArrayRef[Foo]|Int',
70 'Int | ArrayRef[Foo]',
71 'Int|ArrayRef[Foo]',
72 'ArrayRef[Foo | Int] | Str',
73 'ArrayRef[Foo|Int]|Str',
74 'Str | ArrayRef[Foo | Int]',
75 'Str|ArrayRef[Foo|Int]',
76 'Some|Silly|Name|With|Pipes | Int',
77 'Some|Silly|Name|With|Pipes|Int',
78);
79
80ok(!Mouse::Util::TypeConstraints::_detect_type_constraint_union($_),
81 '... this correctly detected a non-union (' . $_ . ')')
82 for (
83 'Int',
84 'ArrayRef[Foo | Int]',
85 'ArrayRef[Foo|Int]',
86);
87
88{
89 my %split_tests = (
90 'Int | Str' => [ 'Int', 'Str' ],
91 'Int|Str' => [ 'Int', 'Str' ],
92 'ArrayRef[Foo] | Int' => [ 'ArrayRef[Foo]', 'Int' ],
93 'ArrayRef[Foo]|Int' => [ 'ArrayRef[Foo]', 'Int' ],
94 'Int | ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ],
95 'Int|ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ],
96 'ArrayRef[Foo | Int] | Str' => [ 'ArrayRef[Foo | Int]', 'Str' ],
97 'ArrayRef[Foo|Int]|Str' => [ 'ArrayRef[Foo|Int]', 'Str' ],
98 'Str | ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ],
99 'Str|ArrayRef[Foo|Int]' => [ 'Str', 'ArrayRef[Foo|Int]' ],
100 'Some|Silly|Name|With|Pipes | Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ],
101 'Some|Silly|Name|With|Pipes|Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ],
102 );
103
104 is_deeply(
105 [ Mouse::Util::TypeConstraints::_parse_type_constraint_union($_) ],
106 $split_tests{$_},
107 '... this correctly split the union (' . $_ . ')'
108 ) for keys %split_tests;
109}
fde8e43f 110
111done_testing;