Cleanup failing tests
[gitmo/Mouse.git] / Moose-t-failing / 040_type_constraints / 026_normalize_type_name.t
CommitLineData
b2b106d7 1#!/usr/bin/perl
c47cf415 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
c47cf415 9use Test::More;
10$TODO = q{Mouse is not yet completed};
b2b106d7 11use Test::Exception;
12
13BEGIN {
14 use_ok('Mouse::Util::TypeConstraints');
15}
16
17## First, we check that the new regex parsing works
18
19ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
20 'ArrayRef[Str]') => 'detected correctly';
21
22is_deeply
23 [
24 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
25 'ArrayRef[Str]')
26 ],
27 [ "ArrayRef", "Str" ] => 'Correctly parsed ArrayRef[Str]';
28
29ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
30 'ArrayRef[Str ]') => 'detected correctly';
31
32is_deeply
33 [
34 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
35 'ArrayRef[Str ]')
36 ],
37 [ "ArrayRef", "Str" ] => 'Correctly parsed ArrayRef[Str ]';
38
39ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
40 'ArrayRef[ Str]') => 'detected correctly';
41
42is_deeply
43 [
44 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
45 'ArrayRef[ Str]')
46 ],
47 [ "ArrayRef", "Str" ] => 'Correctly parsed ArrayRef[ Str]';
48
49ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
50 'ArrayRef[ Str ]') => 'detected correctly';
51
52is_deeply
53 [
54 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
55 'ArrayRef[ Str ]')
56 ],
57 [ "ArrayRef", "Str" ] => 'Correctly parsed ArrayRef[ Str ]';
58
59ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
60 'ArrayRef[ HashRef[Int] ]') => 'detected correctly';
61
62is_deeply
63 [
64 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
65 'ArrayRef[ HashRef[Int] ]')
66 ],
67 [ "ArrayRef", "HashRef[Int]" ] =>
68 'Correctly parsed ArrayRef[ HashRef[Int] ]';
69
70ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
71 'ArrayRef[ HashRef[Int ] ]') => 'detected correctly';
72
73is_deeply
74 [
75 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
76 'ArrayRef[ HashRef[Int ] ]')
77 ],
78 [ "ArrayRef", "HashRef[Int ]" ] =>
79 'Correctly parsed ArrayRef[ HashRef[Int ] ]';
80
81ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
82 'ArrayRef[Int|Str]') => 'detected correctly';
83
84is_deeply
85 [
86 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
87 'ArrayRef[Int|Str]')
88 ],
89 [ "ArrayRef", "Int|Str" ] => 'Correctly parsed ArrayRef[Int|Str]';
90
91ok Mouse::Util::TypeConstraints::_detect_parameterized_type_constraint(
92 'ArrayRef[ArrayRef[Int]|Str]') => 'detected correctly';
93
94is_deeply
95 [
96 Mouse::Util::TypeConstraints::_parse_parameterized_type_constraint(
97 'ArrayRef[ArrayRef[Int]|Str]')
98 ],
99 [ "ArrayRef", "ArrayRef[Int]|Str" ] =>
100 'Correctly parsed ArrayRef[ArrayRef[Int]|Str]';
101
102## creating names via subtype
103
104ok my $r = Mouse::Util::TypeConstraints->get_type_constraint_registry =>
105 'Got registry object';
106
107ok my $subtype_a1
108 = subtype( 'subtype_a1' => as 'HashRef[Int]' ), => 'created subtype_a1';
109
110ok my $subtype_a2
111 = subtype( 'subtype_a2' => as 'HashRef[ Int]' ), => 'created subtype_a2';
112
113ok my $subtype_a3
114 = subtype( 'subtype_a2' => as 'HashRef[Int ]' ), => 'created subtype_a2';
115
116ok my $subtype_a4 = subtype( 'subtype_a2' => as 'HashRef[ Int ]' ), =>
117 'created subtype_a2';
118
119is $subtype_a1->parent->name, $subtype_a2->parent->name => 'names match';
120
121is $subtype_a1->parent->name, $subtype_a3->parent->name => 'names match';
122
123is $subtype_a1->parent->name, $subtype_a4->parent->name => 'names match';
124
125ok my $subtype_b1 = subtype( 'subtype_b1' => as 'HashRef[Int|Str]' ), =>
126 'created subtype_b1';
127
128ok my $subtype_b2 = subtype( 'subtype_b2' => as 'HashRef[Int | Str]' ), =>
129 'created subtype_b2';
130
131ok my $subtype_b3 = subtype( 'subtype_b3' => as 'HashRef[Str|Int]' ), =>
132 'created subtype_b3';
133
134is $subtype_b1->parent->name, $subtype_b2->parent->name => 'names match';
135
136is $subtype_b1->parent->name, $subtype_b3->parent->name => 'names match';
137
138is $subtype_b2->parent->name, $subtype_b3->parent->name => 'names match';
139
140## testing via add_constraint
141
142ok my $union1 = Mouse::Util::TypeConstraints::create_type_constraint_union(
143 'ArrayRef[Int|Str] | ArrayRef[Int | HashRef]') => 'Created Union1';
144
145ok my $union2 = Mouse::Util::TypeConstraints::create_type_constraint_union(
146 'ArrayRef[ Int|Str] | ArrayRef[Int | HashRef]') => 'Created Union2';
147
148ok my $union3 = Mouse::Util::TypeConstraints::create_type_constraint_union(
149 'ArrayRef[Int |Str ] | ArrayRef[Int | HashRef ]') => 'Created Union3';
150
151is $union1->name, $union2->name, 'names match';
152
153is $union1->name, $union3->name, 'names match';
154
155is $union2->name, $union3->name, 'names match';
c47cf415 156
157done_testing;