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