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