Import tc tests
[gitmo/Mouse.git] / t / 040_type_constraints / failing / 003_util_std_type_constraints.t
CommitLineData
b2b106d7 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 297;
7use Test::Exception;
8
9use Scalar::Util ();
10
11BEGIN {
12 use_ok('Mouse::Util::TypeConstraints');
13}
14
15my $SCALAR_REF = \(my $var);
16
17no warnings 'once'; # << I *hates* that warning ...
18my $GLOB = *GLOB_REF;
19my $GLOB_REF = \$GLOB;
20
21my $fh;
22open($fh, '<', $0) || die "Could not open $0 for the test";
23
24my $fh_obj = bless {}, "IO::Handle"; # not really
25
26Mouse::Util::TypeConstraints->export_type_constraints_as_functions();
27
28ok(defined Any(0), '... Any accepts anything');
29ok(defined Any(100), '... Any accepts anything');
30ok(defined Any(''), '... Any accepts anything');
31ok(defined Any('Foo'), '... Any accepts anything');
32ok(defined Any([]), '... Any accepts anything');
33ok(defined Any({}), '... Any accepts anything');
34ok(defined Any(sub {}), '... Any accepts anything');
35ok(defined Any($SCALAR_REF), '... Any accepts anything');
36ok(defined Any($GLOB), '... Any accepts anything');
37ok(defined Any($GLOB_REF), '... Any accepts anything');
38ok(defined Any($fh), '... Any accepts anything');
39ok(defined Any(qr/../), '... Any accepts anything');
40ok(defined Any(bless {}, 'Foo'), '... Any accepts anything');
41ok(defined Any(undef), '... Any accepts anything');
42
43ok(defined Item(0), '... Item is the base type, so accepts anything');
44ok(defined Item(100), '... Item is the base type, so accepts anything');
45ok(defined Item(''), '... Item is the base type, so accepts anything');
46ok(defined Item('Foo'), '... Item is the base type, so accepts anything');
47ok(defined Item([]), '... Item is the base type, so accepts anything');
48ok(defined Item({}), '... Item is the base type, so accepts anything');
49ok(defined Item(sub {}), '... Item is the base type, so accepts anything');
50ok(defined Item($SCALAR_REF), '... Item is the base type, so accepts anything');
51ok(defined Item($GLOB), '... Item is the base type, so accepts anything');
52ok(defined Item($GLOB_REF), '... Item is the base type, so accepts anything');
53ok(defined Item($fh), '... Item is the base type, so accepts anything');
54ok(defined Item(qr/../), '... Item is the base type, so accepts anything');
55ok(defined Item(bless {}, 'Foo'), '... Item is the base type, so accepts anything');
56ok(defined Item(undef), '... Item is the base type, so accepts anything');
57
58ok(defined Defined(0), '... Defined accepts anything which is defined');
59ok(defined Defined(100), '... Defined accepts anything which is defined');
60ok(defined Defined(''), '... Defined accepts anything which is defined');
61ok(defined Defined('Foo'), '... Defined accepts anything which is defined');
62ok(defined Defined([]), '... Defined accepts anything which is defined');
63ok(defined Defined({}), '... Defined accepts anything which is defined');
64ok(defined Defined(sub {}), '... Defined accepts anything which is defined');
65ok(defined Defined($SCALAR_REF), '... Defined accepts anything which is defined');
66ok(defined Defined($GLOB), '... Defined accepts anything which is defined');
67ok(defined Defined($GLOB_REF), '... Defined accepts anything which is defined');
68ok(defined Defined($fh), '... Defined accepts anything which is defined');
69ok(defined Defined(qr/../), '... Defined accepts anything which is defined');
70ok(defined Defined(bless {}, 'Foo'), '... Defined accepts anything which is defined');
71ok(!defined Defined(undef), '... Defined accepts anything which is defined');
72
73ok(!defined Undef(0), '... Undef accepts anything which is not defined');
74ok(!defined Undef(100), '... Undef accepts anything which is not defined');
75ok(!defined Undef(''), '... Undef accepts anything which is not defined');
76ok(!defined Undef('Foo'), '... Undef accepts anything which is not defined');
77ok(!defined Undef([]), '... Undef accepts anything which is not defined');
78ok(!defined Undef({}), '... Undef accepts anything which is not defined');
79ok(!defined Undef(sub {}), '... Undef accepts anything which is not defined');
80ok(!defined Undef($SCALAR_REF), '... Undef accepts anything which is not defined');
81ok(!defined Undef($GLOB), '... Undef accepts anything which is not defined');
82ok(!defined Undef($GLOB_REF), '... Undef accepts anything which is not defined');
83ok(!defined Undef($fh), '... Undef accepts anything which is not defined');
84ok(!defined Undef(qr/../), '... Undef accepts anything which is not defined');
85ok(!defined Undef(bless {}, 'Foo'), '... Undef accepts anything which is not defined');
86ok(defined Undef(undef), '... Undef accepts anything which is not defined');
87
88ok(defined Bool(0), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
89ok(defined Bool(1), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
90ok(!defined Bool(100), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
91ok(defined Bool(''), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
92ok(!defined Bool('Foo'), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
93ok(!defined Bool([]), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
94ok(!defined Bool({}), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
95ok(!defined Bool(sub {}), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
96ok(!defined Bool($SCALAR_REF), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
97ok(!defined Bool($GLOB), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
98ok(!defined Bool($GLOB_REF), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
99ok(!defined Bool($fh), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
100ok(!defined Bool(qr/../), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
101ok(!defined Bool(bless {}, 'Foo'), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
102ok(defined Bool(undef), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
103
104ok(defined Value(0), '... Value accepts anything which is not a Ref');
105ok(defined Value(100), '... Value accepts anything which is not a Ref');
106ok(defined Value(''), '... Value accepts anything which is not a Ref');
107ok(defined Value('Foo'), '... Value accepts anything which is not a Ref');
108ok(!defined Value([]), '... Value rejects anything which is not a Value');
109ok(!defined Value({}), '... Value rejects anything which is not a Value');
110ok(!defined Value(sub {}), '... Value rejects anything which is not a Value');
111ok(!defined Value($SCALAR_REF), '... Value rejects anything which is not a Value');
112ok(defined Value($GLOB), '... Value accepts anything which is not a Ref');
113ok(!defined Value($GLOB_REF), '... Value rejects anything which is not a Value');
114ok(!defined Value($fh), '... Value rejects anything which is not a Value');
115ok(!defined Value(qr/../), '... Value rejects anything which is not a Value');
116ok(!defined Value(bless {}, 'Foo'), '... Value rejects anything which is not a Value');
117ok(!defined Value(undef), '... Value rejects anything which is not a Value');
118
119ok(!defined Ref(0), '... Ref accepts anything which is not a Value');
120ok(!defined Ref(100), '... Ref accepts anything which is not a Value');
121ok(!defined Ref(''), '... Ref accepts anything which is not a Value');
122ok(!defined Ref('Foo'), '... Ref accepts anything which is not a Value');
123ok(defined Ref([]), '... Ref rejects anything which is not a Ref');
124ok(defined Ref({}), '... Ref rejects anything which is not a Ref');
125ok(defined Ref(sub {}), '... Ref rejects anything which is not a Ref');
126ok(defined Ref($SCALAR_REF), '... Ref rejects anything which is not a Ref');
127ok(!defined Ref($GLOB), '... Ref accepts anything which is not a Value');
128ok(defined Ref($GLOB_REF), '... Ref rejects anything which is not a Ref');
129ok(defined Ref($fh), '... Ref rejects anything which is not a Ref');
130ok(defined Ref(qr/../), '... Ref rejects anything which is not a Ref');
131ok(defined Ref(bless {}, 'Foo'), '... Ref rejects anything which is not a Ref');
132ok(!defined Ref(undef), '... Ref rejects anything which is not a Ref');
133
134ok(defined Int(0), '... Int accepts anything which is an Int');
135ok(defined Int(100), '... Int accepts anything which is an Int');
136ok(!defined Int(0.5), '... Int accepts anything which is not a Int');
137ok(!defined Int(100.01), '... Int accepts anything which is not a Int');
138ok(!defined Int(''), '... Int rejects anything which is not a Int');
139ok(!defined Int('Foo'), '... Int rejects anything which is not a Int');
140ok(!defined Int([]), '... Int rejects anything which is not a Int');
141ok(!defined Int({}), '... Int rejects anything which is not a Int');
142ok(!defined Int(sub {}), '... Int rejects anything which is not a Int');
143ok(!defined Int($SCALAR_REF), '... Int rejects anything which is not a Int');
144ok(!defined Int($GLOB), '... Int rejects anything which is not a Int');
145ok(!defined Int($GLOB_REF), '... Int rejects anything which is not a Int');
146ok(!defined Int($fh), '... Int rejects anything which is not a Int');
147ok(!defined Int(qr/../), '... Int rejects anything which is not a Int');
148ok(!defined Int(bless {}, 'Foo'), '... Int rejects anything which is not a Int');
149ok(!defined Int(undef), '... Int rejects anything which is not a Int');
150
151ok(defined Num(0), '... Num accepts anything which is an Num');
152ok(defined Num(100), '... Num accepts anything which is an Num');
153ok(defined Num(0.5), '... Num accepts anything which is an Num');
154ok(defined Num(100.01), '... Num accepts anything which is an Num');
155ok(!defined Num(''), '... Num rejects anything which is not a Num');
156ok(!defined Num('Foo'), '... Num rejects anything which is not a Num');
157ok(!defined Num([]), '... Num rejects anything which is not a Num');
158ok(!defined Num({}), '... Num rejects anything which is not a Num');
159ok(!defined Num(sub {}), '... Num rejects anything which is not a Num');
160ok(!defined Num($SCALAR_REF), '... Num rejects anything which is not a Num');
161ok(!defined Num($GLOB), '... Num rejects anything which is not a Num');
162ok(!defined Num($GLOB_REF), '... Num rejects anything which is not a Num');
163ok(!defined Num($fh), '... Num rejects anything which is not a Num');
164ok(!defined Num(qr/../), '... Num rejects anything which is not a Num');
165ok(!defined Num(bless {}, 'Foo'), '... Num rejects anything which is not a Num');
166ok(!defined Num(undef), '... Num rejects anything which is not a Num');
167
168ok(defined Str(0), '... Str accepts anything which is a Str');
169ok(defined Str(100), '... Str accepts anything which is a Str');
170ok(defined Str(''), '... Str accepts anything which is a Str');
171ok(defined Str('Foo'), '... Str accepts anything which is a Str');
172ok(!defined Str([]), '... Str rejects anything which is not a Str');
173ok(!defined Str({}), '... Str rejects anything which is not a Str');
174ok(!defined Str(sub {}), '... Str rejects anything which is not a Str');
175ok(!defined Str($SCALAR_REF), '... Str rejects anything which is not a Str');
176ok(!defined Str($fh), '... Str rejects anything which is not a Str');
177ok(!defined Str($GLOB), '... Str rejects anything which is not a Str');
178ok(!defined Str($GLOB_REF), '... Str rejects anything which is not a Str');
179ok(!defined Str(qr/../), '... Str rejects anything which is not a Str');
180ok(!defined Str(bless {}, 'Foo'), '... Str rejects anything which is not a Str');
181ok(!defined Str(undef), '... Str rejects anything which is not a Str');
182
183ok(!defined ScalarRef(0), '... ScalarRef rejects anything which is not a ScalarRef');
184ok(!defined ScalarRef(100), '... ScalarRef rejects anything which is not a ScalarRef');
185ok(!defined ScalarRef(''), '... ScalarRef rejects anything which is not a ScalarRef');
186ok(!defined ScalarRef('Foo'), '... ScalarRef rejects anything which is not a ScalarRef');
187ok(!defined ScalarRef([]), '... ScalarRef rejects anything which is not a ScalarRef');
188ok(!defined ScalarRef({}), '... ScalarRef rejects anything which is not a ScalarRef');
189ok(!defined ScalarRef(sub {}), '... ScalarRef rejects anything which is not a ScalarRef');
190ok(defined ScalarRef($SCALAR_REF), '... ScalarRef accepts anything which is a ScalarRef');
191ok(!defined ScalarRef($GLOB), '... ScalarRef rejects anything which is not a ScalarRef');
192ok(!defined ScalarRef($GLOB_REF), '... ScalarRef rejects anything which is not a ScalarRef');
193ok(!defined ScalarRef($fh), '... ScalarRef rejects anything which is not a ScalarRef');
194ok(!defined ScalarRef(qr/../), '... ScalarRef rejects anything which is not a ScalarRef');
195ok(!defined ScalarRef(bless {}, 'Foo'), '... ScalarRef rejects anything which is not a ScalarRef');
196ok(!defined ScalarRef(undef), '... ScalarRef rejects anything which is not a ScalarRef');
197
198ok(!defined ArrayRef(0), '... ArrayRef rejects anything which is not a ArrayRef');
199ok(!defined ArrayRef(100), '... ArrayRef rejects anything which is not a ArrayRef');
200ok(!defined ArrayRef(''), '... ArrayRef rejects anything which is not a ArrayRef');
201ok(!defined ArrayRef('Foo'), '... ArrayRef rejects anything which is not a ArrayRef');
202ok(defined ArrayRef([]), '... ArrayRef accepts anything which is a ArrayRef');
203ok(!defined ArrayRef({}), '... ArrayRef rejects anything which is not a ArrayRef');
204ok(!defined ArrayRef(sub {}), '... ArrayRef rejects anything which is not a ArrayRef');
205ok(!defined ArrayRef($SCALAR_REF), '... ArrayRef rejects anything which is not a ArrayRef');
206ok(!defined ArrayRef($GLOB), '... ArrayRef rejects anything which is not a ArrayRef');
207ok(!defined ArrayRef($GLOB_REF), '... ArrayRef rejects anything which is not a ArrayRef');
208ok(!defined ArrayRef($fh), '... ArrayRef rejects anything which is not a ArrayRef');
209ok(!defined ArrayRef(qr/../), '... ArrayRef rejects anything which is not a ArrayRef');
210ok(!defined ArrayRef(bless {}, 'Foo'), '... ArrayRef rejects anything which is not a ArrayRef');
211ok(!defined ArrayRef(undef), '... ArrayRef rejects anything which is not a ArrayRef');
212
213ok(!defined HashRef(0), '... HashRef rejects anything which is not a HashRef');
214ok(!defined HashRef(100), '... HashRef rejects anything which is not a HashRef');
215ok(!defined HashRef(''), '... HashRef rejects anything which is not a HashRef');
216ok(!defined HashRef('Foo'), '... HashRef rejects anything which is not a HashRef');
217ok(!defined HashRef([]), '... HashRef rejects anything which is not a HashRef');
218ok(defined HashRef({}), '... HashRef accepts anything which is a HashRef');
219ok(!defined HashRef(sub {}), '... HashRef rejects anything which is not a HashRef');
220ok(!defined HashRef($SCALAR_REF), '... HashRef rejects anything which is not a HashRef');
221ok(!defined HashRef($GLOB), '... HashRef rejects anything which is not a HashRef');
222ok(!defined HashRef($GLOB_REF), '... HashRef rejects anything which is not a HashRef');
223ok(!defined HashRef($fh), '... HashRef rejects anything which is not a HashRef');
224ok(!defined HashRef(qr/../), '... HashRef rejects anything which is not a HashRef');
225ok(!defined HashRef(bless {}, 'Foo'), '... HashRef rejects anything which is not a HashRef');
226ok(!defined HashRef(undef), '... HashRef rejects anything which is not a HashRef');
227
228ok(!defined CodeRef(0), '... CodeRef rejects anything which is not a CodeRef');
229ok(!defined CodeRef(100), '... CodeRef rejects anything which is not a CodeRef');
230ok(!defined CodeRef(''), '... CodeRef rejects anything which is not a CodeRef');
231ok(!defined CodeRef('Foo'), '... CodeRef rejects anything which is not a CodeRef');
232ok(!defined CodeRef([]), '... CodeRef rejects anything which is not a CodeRef');
233ok(!defined CodeRef({}), '... CodeRef rejects anything which is not a CodeRef');
234ok(defined CodeRef(sub {}), '... CodeRef accepts anything which is a CodeRef');
235ok(!defined CodeRef($SCALAR_REF), '... CodeRef rejects anything which is not a CodeRef');
236ok(!defined CodeRef($GLOB), '... CodeRef rejects anything which is not a CodeRef');
237ok(!defined CodeRef($GLOB_REF), '... CodeRef rejects anything which is not a CodeRef');
238ok(!defined CodeRef($fh), '... CodeRef rejects anything which is not a CodeRef');
239ok(!defined CodeRef(qr/../), '... CodeRef rejects anything which is not a CodeRef');
240ok(!defined CodeRef(bless {}, 'Foo'), '... CodeRef rejects anything which is not a CodeRef');
241ok(!defined CodeRef(undef), '... CodeRef rejects anything which is not a CodeRef');
242
243ok(!defined RegexpRef(0), '... RegexpRef rejects anything which is not a RegexpRef');
244ok(!defined RegexpRef(100), '... RegexpRef rejects anything which is not a RegexpRef');
245ok(!defined RegexpRef(''), '... RegexpRef rejects anything which is not a RegexpRef');
246ok(!defined RegexpRef('Foo'), '... RegexpRef rejects anything which is not a RegexpRef');
247ok(!defined RegexpRef([]), '... RegexpRef rejects anything which is not a RegexpRef');
248ok(!defined RegexpRef({}), '... RegexpRef rejects anything which is not a RegexpRef');
249ok(!defined RegexpRef(sub {}), '... RegexpRef rejects anything which is not a RegexpRef');
250ok(!defined RegexpRef($SCALAR_REF), '... RegexpRef rejects anything which is not a RegexpRef');
251ok(!defined RegexpRef($GLOB), '... RegexpRef rejects anything which is not a RegexpRef');
252ok(!defined RegexpRef($GLOB_REF), '... RegexpRef rejects anything which is not a RegexpRef');
253ok(!defined RegexpRef($fh), '... RegexpRef rejects anything which is not a RegexpRef');
254ok(defined RegexpRef(qr/../), '... RegexpRef accepts anything which is a RegexpRef');
255ok(!defined RegexpRef(bless {}, 'Foo'), '... RegexpRef rejects anything which is not a RegexpRef');
256ok(!defined RegexpRef(undef), '... RegexpRef rejects anything which is not a RegexpRef');
257
258ok(!defined GlobRef(0), '... GlobRef rejects anything which is not a GlobRef');
259ok(!defined GlobRef(100), '... GlobRef rejects anything which is not a GlobRef');
260ok(!defined GlobRef(''), '... GlobRef rejects anything which is not a GlobRef');
261ok(!defined GlobRef('Foo'), '... GlobRef rejects anything which is not a GlobRef');
262ok(!defined GlobRef([]), '... GlobRef rejects anything which is not a GlobRef');
263ok(!defined GlobRef({}), '... GlobRef rejects anything which is not a GlobRef');
264ok(!defined GlobRef(sub {}), '... GlobRef rejects anything which is not a GlobRef');
265ok(!defined GlobRef($SCALAR_REF), '... GlobRef rejects anything which is not a GlobRef');
266ok(!defined GlobRef($GLOB), '... GlobRef rejects anything which is not a GlobRef');
267ok(defined GlobRef($GLOB_REF), '... GlobRef accepts anything which is a GlobRef');
268ok(defined GlobRef($fh), '... GlobRef accepts anything which is a GlobRef');
269ok(!defined GlobRef($fh_obj), '... GlobRef rejects anything which is not a GlobRef');
270ok(!defined GlobRef(qr/../), '... GlobRef rejects anything which is not a GlobRef');
271ok(!defined GlobRef(bless {}, 'Foo'), '... GlobRef rejects anything which is not a GlobRef');
272ok(!defined GlobRef(undef), '... GlobRef rejects anything which is not a GlobRef');
273
274ok(!defined FileHandle(0), '... FileHandle rejects anything which is not a FileHandle');
275ok(!defined FileHandle(100), '... FileHandle rejects anything which is not a FileHandle');
276ok(!defined FileHandle(''), '... FileHandle rejects anything which is not a FileHandle');
277ok(!defined FileHandle('Foo'), '... FileHandle rejects anything which is not a FileHandle');
278ok(!defined FileHandle([]), '... FileHandle rejects anything which is not a FileHandle');
279ok(!defined FileHandle({}), '... FileHandle rejects anything which is not a FileHandle');
280ok(!defined FileHandle(sub {}), '... FileHandle rejects anything which is not a FileHandle');
281ok(!defined FileHandle($SCALAR_REF), '... FileHandle rejects anything which is not a FileHandle');
282ok(!defined FileHandle($GLOB), '... FileHandle rejects anything which is not a FileHandle');
283ok(!defined FileHandle($GLOB_REF), '... FileHandle rejects anything which is not a FileHandle');
284ok(defined FileHandle($fh), '... FileHandle accepts anything which is a FileHandle');
285ok(defined FileHandle($fh_obj), '... FileHandle accepts anything which is a FileHandle');
286ok(!defined FileHandle(qr/../), '... FileHandle rejects anything which is not a FileHandle');
287ok(!defined FileHandle(bless {}, 'Foo'), '... FileHandle rejects anything which is not a FileHandle');
288ok(!defined FileHandle(undef), '... FileHandle rejects anything which is not a FileHandle');
289
290ok(!defined Object(0), '... Object rejects anything which is not blessed');
291ok(!defined Object(100), '... Object rejects anything which is not blessed');
292ok(!defined Object(''), '... Object rejects anything which is not blessed');
293ok(!defined Object('Foo'), '... Object rejects anything which is not blessed');
294ok(!defined Object([]), '... Object rejects anything which is not blessed');
295ok(!defined Object({}), '... Object rejects anything which is not blessed');
296ok(!defined Object(sub {}), '... Object rejects anything which is not blessed');
297ok(!defined Object($SCALAR_REF), '... Object rejects anything which is not blessed');
298ok(!defined Object($GLOB), '... Object rejects anything which is not blessed');
299ok(!defined Object($GLOB_REF), '... Object rejects anything which is not blessed');
300ok(!defined Object($fh), '... Object rejects anything which is not blessed');
301ok(!defined Object(qr/../), '... Object rejects anything which is not blessed');
302ok(defined Object(bless {}, 'Foo'), '... Object accepts anything which is blessed');
303ok(!defined Object(undef), '... Object accepts anything which is blessed');
304
305ok(!defined ClassName(0), '... ClassName rejects anything which is not a ClassName');
306ok(!defined ClassName(100), '... ClassName rejects anything which is not a ClassName');
307ok(!defined ClassName(''), '... ClassName rejects anything which is not a ClassName');
308ok(!defined ClassName('Baz'), '... ClassName rejects anything which is not a ClassName');
309
310{
311 package Quux::Wibble; # this makes Quux symbol table exist
312
313 sub foo {}
314}
315
316ok(!defined ClassName('Quux'), '... ClassName rejects anything which is not a ClassName');
317ok(!defined ClassName([]), '... ClassName rejects anything which is not a ClassName');
318ok(!defined ClassName({}), '... ClassName rejects anything which is not a ClassName');
319ok(!defined ClassName(sub {}), '... ClassName rejects anything which is not a ClassName');
320ok(!defined ClassName($SCALAR_REF), '... ClassName rejects anything which is not a ClassName');
321ok(!defined ClassName($fh), '... ClassName rejects anything which is not a ClassName');
322ok(!defined ClassName($GLOB), '... ClassName rejects anything which is not a ClassName');
323ok(!defined ClassName($GLOB_REF), '... ClassName rejects anything which is not a ClassName');
324ok(!defined ClassName(qr/../), '... ClassName rejects anything which is not a ClassName');
325ok(!defined ClassName(bless {}, 'Foo'), '... ClassName rejects anything which is not a ClassName');
326ok(!defined ClassName(undef), '... ClassName rejects anything which is not a ClassName');
327ok(defined ClassName('UNIVERSAL'), '... ClassName accepts anything which is a ClassName');
328ok(defined ClassName('Quux::Wibble'), '... ClassName accepts anything which is a ClassName');
329ok(defined ClassName('Mouse::Meta::TypeConstraint'), '... ClassName accepts anything which is a ClassName');
330
331ok(!defined RoleName(0), '... RoleName rejects anything which is not a RoleName');
332ok(!defined RoleName(100), '... RoleName rejects anything which is not a RoleName');
333ok(!defined RoleName(''), '... RoleName rejects anything which is not a RoleName');
334ok(!defined RoleName('Baz'), '... RoleName rejects anything which is not a RoleName');
335
336{
337 package Quux::Wibble::Role; # this makes Quux symbol table exist
338 use Mouse::Role;
339 sub foo {}
340}
341
342ok(!defined RoleName('Quux'), '... RoleName rejects anything which is not a RoleName');
343ok(!defined RoleName([]), '... Rolename rejects anything which is not a RoleName');
344ok(!defined RoleName({}), '... Rolename rejects anything which is not a RoleName');
345ok(!defined RoleName(sub {}), '... Rolename rejects anything which is not a RoleName');
346ok(!defined RoleName($SCALAR_REF), '... Rolename rejects anything which is not a RoleName');
347ok(!defined RoleName($fh), '... Rolename rejects anything which is not a RoleName');
348ok(!defined RoleName($GLOB), '... Rolename rejects anything which is not a RoleName');
349ok(!defined RoleName($GLOB_REF), '... Rolename rejects anything which is not a RoleName');
350ok(!defined RoleName(qr/../), '... Rolename rejects anything which is not a RoleName');
351ok(!defined RoleName(bless {}, 'Foo'), '... Rolename rejects anything which is not a RoleName');
352ok(!defined RoleName(undef), '... Rolename rejects anything which is not a RoleName');
353ok(!defined RoleName('UNIVERSAL'), '... Rolename rejects anything which is not a RoleName');
354ok(!defined RoleName('Quux::Wibble'), '... Rolename rejects anything which is not a RoleName');
355ok(!defined RoleName('Mouse::Meta::TypeConstraint'), '... RoleName accepts anything which is a RoleName');
356ok(defined RoleName('Quux::Wibble::Role'), '... RoleName accepts anything which is a RoleName');
357
358close($fh) || die "Could not close the filehandle $0 for test";