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