2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
11 use Mouse::Util::TypeConstraints;
12 use List::Util qw(sum);
14 subtype 'A1', as 'ArrayRef[Int]';
15 subtype 'A2', as 'ArrayRef', where { @$_ < 2 };
16 subtype 'A3', as 'ArrayRef[Int]', where { sum @$_ < 5 };
18 no Mouse::Util::TypeConstraints;
36 isa => 'ArrayRef[Int]',
38 push_array_int => 'push',
71 dies_ok { $foo->push_array('foo') } "can't push onto undef";
74 is($foo->array, $array, "same ref");
75 is_deeply($foo->array, [], "correct contents");
77 $foo->push_array('foo');
78 is($foo->array, $array, "same ref");
79 is_deeply($foo->array, ['foo'], "correct contents");
84 dies_ok { $foo->push_array_int(1) } "can't push onto undef";
86 $foo->array_int($array);
87 is($foo->array_int, $array, "same ref");
88 is_deeply($foo->array_int, [], "correct contents");
90 dies_ok { $foo->push_array_int('foo') } "can't push wrong type";
91 is($foo->array_int, $array, "same ref");
92 is_deeply($foo->array_int, [], "correct contents");
95 $foo->push_array_int(1);
96 is($foo->array_int, $array, "same ref");
97 is_deeply($foo->array_int, [1], "correct contents");
102 dies_ok { $foo->push_a1('foo') } "can't push onto undef";
105 is($foo->a1, $array, "same ref");
106 is_deeply($foo->a1, [], "correct contents");
108 { local $TODO = "type parameters aren't checked on subtypes";
109 dies_ok { $foo->push_a1('foo') } "can't push wrong type";
111 is($foo->a1, $array, "same ref");
112 { local $TODO = "type parameters aren't checked on subtypes";
113 is_deeply($foo->a1, [], "correct contents");
118 is($foo->a1, $array, "same ref");
119 is_deeply($foo->a1, [1], "correct contents");
124 dies_ok { $foo->push_a2('foo') } "can't push onto undef";
127 is($foo->a2, $array, "same ref");
128 is_deeply($foo->a2, [], "correct contents");
130 $foo->push_a2('foo');
131 is($foo->a2, $array, "same ref");
132 is_deeply($foo->a2, ['foo'], "correct contents");
134 { local $TODO = "overall tcs aren't checked";
135 dies_ok { $foo->push_a2('bar') } "can't push more than one element";
137 is($foo->a2, $array, "same ref");
138 { local $TODO = "overall tcs aren't checked";
139 is_deeply($foo->a2, ['foo'], "correct contents");
145 dies_ok { $foo->push_a3(1) } "can't push onto undef";
148 is($foo->a3, $array, "same ref");
149 is_deeply($foo->a3, [], "correct contents");
151 { local $TODO = "tc parameters aren't checked on subtypes";
152 dies_ok { $foo->push_a3('foo') } "can't push non-int";
154 { local $TODO = "overall tcs aren't checked";
155 dies_ok { $foo->push_a3(100) } "can't violate overall type constraint";
157 is($foo->a3, $array, "same ref");
158 { local $TODO = "tc checks are broken";
159 is_deeply($foo->a3, [], "correct contents");
164 is($foo->a3, $array, "same ref");
165 is_deeply($foo->a3, [1], "correct contents");
167 { local $TODO = "overall tcs aren't checked";
168 dies_ok { $foo->push_a3(100) } "can't violate overall type constraint";
170 is($foo->a3, $array, "same ref");
171 { local $TODO = "overall tcs aren't checked";
172 is_deeply($foo->a3, [1], "correct contents");
177 is($foo->a3, $array, "same ref");
178 is_deeply($foo->a3, [1, 3], "correct contents");