Remove cruft
[gitmo/Moose.git] / t / 040_type_constraints / 003_util_std_type_constraints.t
CommitLineData
a15dff8d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
a15dff8d 7use Test::Exception;
8
9use Scalar::Util ();
10
11BEGIN {
d03bd989 12 use_ok('Moose::Util::TypeConstraints');
a15dff8d 13}
14
74d5a674 15my $STRING = "foo";
16
a15dff8d 17my $SCALAR_REF = \(my $var);
94b8bbb8 18
19no warnings 'once'; # << I *hates* that warning ...
0d51bf49 20my $GLOB = *GLOB_REF;
21my $GLOB_REF = \$GLOB;
a15dff8d 22
0a5bd159 23my $fh;
24open($fh, '<', $0) || die "Could not open $0 for the test";
25
128c601e 26my $fh_obj = bless {}, "IO::Handle"; # not really
27
d9b40005 28Moose::Util::TypeConstraints->export_type_constraints_as_functions();
182134e8 29
a15dff8d 30ok(defined Any(0), '... Any accepts anything');
31ok(defined Any(100), '... Any accepts anything');
32ok(defined Any(''), '... Any accepts anything');
33ok(defined Any('Foo'), '... Any accepts anything');
34ok(defined Any([]), '... Any accepts anything');
35ok(defined Any({}), '... Any accepts anything');
36ok(defined Any(sub {}), '... Any accepts anything');
37ok(defined Any($SCALAR_REF), '... Any accepts anything');
0d51bf49 38ok(defined Any($GLOB), '... Any accepts anything');
3f7376b0 39ok(defined Any($GLOB_REF), '... Any accepts anything');
0a5bd159 40ok(defined Any($fh), '... Any accepts anything');
a15dff8d 41ok(defined Any(qr/../), '... Any accepts anything');
42ok(defined Any(bless {}, 'Foo'), '... Any accepts anything');
5a4c5493 43ok(defined Any(undef), '... Any accepts anything');
44
45ok(defined Item(0), '... Item is the base type, so accepts anything');
46ok(defined Item(100), '... Item is the base type, so accepts anything');
47ok(defined Item(''), '... Item is the base type, so accepts anything');
48ok(defined Item('Foo'), '... Item is the base type, so accepts anything');
49ok(defined Item([]), '... Item is the base type, so accepts anything');
50ok(defined Item({}), '... Item is the base type, so accepts anything');
51ok(defined Item(sub {}), '... Item is the base type, so accepts anything');
52ok(defined Item($SCALAR_REF), '... Item is the base type, so accepts anything');
0d51bf49 53ok(defined Item($GLOB), '... Item is the base type, so accepts anything');
3f7376b0 54ok(defined Item($GLOB_REF), '... Item is the base type, so accepts anything');
0a5bd159 55ok(defined Item($fh), '... Item is the base type, so accepts anything');
5a4c5493 56ok(defined Item(qr/../), '... Item is the base type, so accepts anything');
57ok(defined Item(bless {}, 'Foo'), '... Item is the base type, so accepts anything');
58ok(defined Item(undef), '... Item is the base type, so accepts anything');
59
60ok(defined Defined(0), '... Defined accepts anything which is defined');
61ok(defined Defined(100), '... Defined accepts anything which is defined');
62ok(defined Defined(''), '... Defined accepts anything which is defined');
63ok(defined Defined('Foo'), '... Defined accepts anything which is defined');
64ok(defined Defined([]), '... Defined accepts anything which is defined');
65ok(defined Defined({}), '... Defined accepts anything which is defined');
66ok(defined Defined(sub {}), '... Defined accepts anything which is defined');
67ok(defined Defined($SCALAR_REF), '... Defined accepts anything which is defined');
0d51bf49 68ok(defined Defined($GLOB), '... Defined accepts anything which is defined');
3f7376b0 69ok(defined Defined($GLOB_REF), '... Defined accepts anything which is defined');
0a5bd159 70ok(defined Defined($fh), '... Defined accepts anything which is defined');
5a4c5493 71ok(defined Defined(qr/../), '... Defined accepts anything which is defined');
72ok(defined Defined(bless {}, 'Foo'), '... Defined accepts anything which is defined');
73ok(!defined Defined(undef), '... Defined accepts anything which is defined');
74
75ok(!defined Undef(0), '... Undef accepts anything which is not defined');
76ok(!defined Undef(100), '... Undef accepts anything which is not defined');
77ok(!defined Undef(''), '... Undef accepts anything which is not defined');
78ok(!defined Undef('Foo'), '... Undef accepts anything which is not defined');
79ok(!defined Undef([]), '... Undef accepts anything which is not defined');
80ok(!defined Undef({}), '... Undef accepts anything which is not defined');
81ok(!defined Undef(sub {}), '... Undef accepts anything which is not defined');
82ok(!defined Undef($SCALAR_REF), '... Undef accepts anything which is not defined');
0d51bf49 83ok(!defined Undef($GLOB), '... Undef accepts anything which is not defined');
3f7376b0 84ok(!defined Undef($GLOB_REF), '... Undef accepts anything which is not defined');
0a5bd159 85ok(!defined Undef($fh), '... Undef accepts anything which is not defined');
5a4c5493 86ok(!defined Undef(qr/../), '... Undef accepts anything which is not defined');
87ok(!defined Undef(bless {}, 'Foo'), '... Undef accepts anything which is not defined');
88ok(defined Undef(undef), '... Undef accepts anything which is not defined');
89
90ok(defined Bool(0), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
91ok(defined Bool(1), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
92ok(!defined Bool(100), '... 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('Foo'), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
95ok(!defined Bool([]), '... 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(sub {}), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
98ok(!defined Bool($SCALAR_REF), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
0d51bf49 99ok(!defined Bool($GLOB), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
3f7376b0 100ok(!defined Bool($GLOB_REF), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
0a5bd159 101ok(!defined Bool($fh), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
5a4c5493 102ok(!defined Bool(qr/../), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
103ok(!defined Bool(bless {}, 'Foo'), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
104ok(defined Bool(undef), '... Bool rejects anything which is not a 1 or 0 or "" or undef');
5204cd52 105
a15dff8d 106ok(defined Value(0), '... Value accepts anything which is not a Ref');
107ok(defined Value(100), '... Value accepts anything which is not a Ref');
108ok(defined Value(''), '... Value accepts anything which is not a Ref');
109ok(defined Value('Foo'), '... Value accepts anything which is not a Ref');
110ok(!defined Value([]), '... Value rejects anything which is not a Value');
111ok(!defined Value({}), '... Value rejects anything which is not a Value');
112ok(!defined Value(sub {}), '... Value rejects anything which is not a Value');
113ok(!defined Value($SCALAR_REF), '... Value rejects anything which is not a Value');
0d51bf49 114ok(defined Value($GLOB), '... Value accepts anything which is not a Ref');
3f7376b0 115ok(!defined Value($GLOB_REF), '... Value rejects anything which is not a Value');
0a5bd159 116ok(!defined Value($fh), '... Value rejects anything which is not a Value');
a15dff8d 117ok(!defined Value(qr/../), '... Value rejects anything which is not a Value');
118ok(!defined Value(bless {}, 'Foo'), '... Value rejects anything which is not a Value');
5a4c5493 119ok(!defined Value(undef), '... Value rejects anything which is not a Value');
a15dff8d 120
121ok(!defined Ref(0), '... Ref accepts anything which is not a Value');
122ok(!defined Ref(100), '... Ref accepts anything which is not a Value');
123ok(!defined Ref(''), '... Ref accepts anything which is not a Value');
124ok(!defined Ref('Foo'), '... Ref accepts anything which is not a Value');
125ok(defined Ref([]), '... Ref rejects anything which is not a Ref');
126ok(defined Ref({}), '... Ref rejects anything which is not a Ref');
127ok(defined Ref(sub {}), '... Ref rejects anything which is not a Ref');
128ok(defined Ref($SCALAR_REF), '... Ref rejects anything which is not a Ref');
0d51bf49 129ok(!defined Ref($GLOB), '... Ref accepts anything which is not a Value');
3f7376b0 130ok(defined Ref($GLOB_REF), '... Ref rejects anything which is not a Ref');
0a5bd159 131ok(defined Ref($fh), '... Ref rejects anything which is not a Ref');
a15dff8d 132ok(defined Ref(qr/../), '... Ref rejects anything which is not a Ref');
133ok(defined Ref(bless {}, 'Foo'), '... Ref rejects anything which is not a Ref');
5a4c5493 134ok(!defined Ref(undef), '... Ref rejects anything which is not a Ref');
a15dff8d 135
136ok(defined Int(0), '... Int accepts anything which is an Int');
137ok(defined Int(100), '... Int accepts anything which is an Int');
b754c04f 138ok(!defined Int(0.5), '... Int accepts anything which is not an Int');
139ok(!defined Int(100.01), '... Int accepts anything which is not an Int');
140ok(!defined Int(''), '... Int rejects anything which is not an Int');
141ok(!defined Int('Foo'), '... Int rejects anything which is not an Int');
142ok(!defined Int([]), '... Int rejects anything which is not an Int');
143ok(!defined Int({}), '... Int rejects anything which is not an Int');
144ok(!defined Int(sub {}), '... Int rejects anything which is not an Int');
145ok(!defined Int($SCALAR_REF), '... Int rejects anything which is not an Int');
146ok(!defined Int($GLOB), '... Int rejects anything which is not an Int');
147ok(!defined Int($GLOB_REF), '... Int rejects anything which is not an Int');
148ok(!defined Int($fh), '... Int rejects anything which is not an Int');
149ok(!defined Int(qr/../), '... Int rejects anything which is not an Int');
150ok(!defined Int(bless {}, 'Foo'), '... Int rejects anything which is not an Int');
151ok(!defined Int(undef), '... Int rejects anything which is not an Int');
5a4c5493 152
153ok(defined Num(0), '... Num accepts anything which is an Num');
154ok(defined Num(100), '... Num accepts anything which is an Num');
155ok(defined Num(0.5), '... Num accepts anything which is an Num');
156ok(defined Num(100.01), '... Num accepts anything which is an Num');
157ok(!defined Num(''), '... Num rejects anything which is not a Num');
158ok(!defined Num('Foo'), '... Num rejects anything which is not a Num');
159ok(!defined Num([]), '... Num rejects anything which is not a Num');
160ok(!defined Num({}), '... Num rejects anything which is not a Num');
161ok(!defined Num(sub {}), '... Num rejects anything which is not a Num');
162ok(!defined Num($SCALAR_REF), '... Num rejects anything which is not a Num');
0d51bf49 163ok(!defined Num($GLOB), '... Num rejects anything which is not a Num');
3f7376b0 164ok(!defined Num($GLOB_REF), '... Num rejects anything which is not a Num');
0a5bd159 165ok(!defined Num($fh), '... Num rejects anything which is not a Num');
5a4c5493 166ok(!defined Num(qr/../), '... Num rejects anything which is not a Num');
167ok(!defined Num(bless {}, 'Foo'), '... Num rejects anything which is not a Num');
168ok(!defined Num(undef), '... Num rejects anything which is not a Num');
169
170ok(defined Str(0), '... Str accepts anything which is a Str');
171ok(defined Str(100), '... Str accepts anything which is a Str');
a15dff8d 172ok(defined Str(''), '... Str accepts anything which is a Str');
173ok(defined Str('Foo'), '... Str accepts anything which is a Str');
74d5a674 174ok(defined Str(substr($STRING,0,1)),'... Str accepts anything which is a Str');
a15dff8d 175ok(!defined Str([]), '... Str rejects anything which is not a Str');
176ok(!defined Str({}), '... Str rejects anything which is not a Str');
177ok(!defined Str(sub {}), '... Str rejects anything which is not a Str');
178ok(!defined Str($SCALAR_REF), '... Str rejects anything which is not a Str');
0a5bd159 179ok(!defined Str($fh), '... Str rejects anything which is not a Str');
0d51bf49 180ok(!defined Str($GLOB), '... Str rejects anything which is not a Str');
3f7376b0 181ok(!defined Str($GLOB_REF), '... Str rejects anything which is not a Str');
a15dff8d 182ok(!defined Str(qr/../), '... Str rejects anything which is not a Str');
183ok(!defined Str(bless {}, 'Foo'), '... Str rejects anything which is not a Str');
5a4c5493 184ok(!defined Str(undef), '... Str rejects anything which is not a Str');
a15dff8d 185
186ok(!defined ScalarRef(0), '... ScalarRef rejects anything which is not a ScalarRef');
187ok(!defined ScalarRef(100), '... ScalarRef rejects anything which is not a ScalarRef');
188ok(!defined ScalarRef(''), '... ScalarRef rejects anything which is not a ScalarRef');
189ok(!defined ScalarRef('Foo'), '... ScalarRef rejects anything which is not a ScalarRef');
190ok(!defined ScalarRef([]), '... ScalarRef rejects anything which is not a ScalarRef');
191ok(!defined ScalarRef({}), '... ScalarRef rejects anything which is not a ScalarRef');
192ok(!defined ScalarRef(sub {}), '... ScalarRef rejects anything which is not a ScalarRef');
193ok(defined ScalarRef($SCALAR_REF), '... ScalarRef accepts anything which is a ScalarRef');
150e5142 194ok(defined ScalarRef(\$SCALAR_REF), '... ScalarRef accepts references to references');
0d51bf49 195ok(!defined ScalarRef($GLOB), '... ScalarRef rejects anything which is not a ScalarRef');
3f7376b0 196ok(!defined ScalarRef($GLOB_REF), '... ScalarRef rejects anything which is not a ScalarRef');
0a5bd159 197ok(!defined ScalarRef($fh), '... ScalarRef rejects anything which is not a ScalarRef');
a15dff8d 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');
5a4c5493 200ok(!defined ScalarRef(undef), '... ScalarRef rejects anything which is not a ScalarRef');
a15dff8d 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');
0d51bf49 210ok(!defined ArrayRef($GLOB), '... ArrayRef rejects anything which is not a ArrayRef');
3f7376b0 211ok(!defined ArrayRef($GLOB_REF), '... ArrayRef rejects anything which is not a ArrayRef');
0a5bd159 212ok(!defined ArrayRef($fh), '... ArrayRef rejects anything which is not a ArrayRef');
a15dff8d 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');
5a4c5493 215ok(!defined ArrayRef(undef), '... ArrayRef rejects anything which is not a ArrayRef');
a15dff8d 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');
0d51bf49 225ok(!defined HashRef($GLOB), '... HashRef rejects anything which is not a HashRef');
3f7376b0 226ok(!defined HashRef($GLOB_REF), '... HashRef rejects anything which is not a HashRef');
0a5bd159 227ok(!defined HashRef($fh), '... HashRef rejects anything which is not a HashRef');
a15dff8d 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');
5a4c5493 230ok(!defined HashRef(undef), '... HashRef rejects anything which is not a HashRef');
a15dff8d 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');
0d51bf49 240ok(!defined CodeRef($GLOB), '... CodeRef rejects anything which is not a CodeRef');
3f7376b0 241ok(!defined CodeRef($GLOB_REF), '... CodeRef rejects anything which is not a CodeRef');
0a5bd159 242ok(!defined CodeRef($fh), '... CodeRef rejects anything which is not a CodeRef');
a15dff8d 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');
5a4c5493 245ok(!defined CodeRef(undef), '... CodeRef rejects anything which is not a CodeRef');
a15dff8d 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');
0d51bf49 255ok(!defined RegexpRef($GLOB), '... RegexpRef rejects anything which is not a RegexpRef');
3f7376b0 256ok(!defined RegexpRef($GLOB_REF), '... RegexpRef rejects anything which is not a RegexpRef');
0a5bd159 257ok(!defined RegexpRef($fh), '... RegexpRef rejects anything which is not a RegexpRef');
a15dff8d 258ok(defined RegexpRef(qr/../), '... RegexpRef accepts anything which is a RegexpRef');
259ok(!defined RegexpRef(bless {}, 'Foo'), '... RegexpRef rejects anything which is not a RegexpRef');
5a4c5493 260ok(!defined RegexpRef(undef), '... RegexpRef rejects anything which is not a RegexpRef');
a15dff8d 261
3f7376b0 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');
0d51bf49 270ok(!defined GlobRef($GLOB), '... GlobRef rejects anything which is not a GlobRef');
0a5bd159 271ok(defined GlobRef($GLOB_REF), '... GlobRef accepts anything which is a GlobRef');
272ok(defined GlobRef($fh), '... GlobRef accepts anything which is a GlobRef');
128c601e 273ok(!defined GlobRef($fh_obj), '... GlobRef rejects anything which is not a GlobRef');
0a5bd159 274ok(!defined GlobRef(qr/../), '... GlobRef rejects anything which is not a GlobRef');
3f7376b0 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
0a5bd159 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');
0d51bf49 286ok(!defined FileHandle($GLOB), '... FileHandle rejects anything which is not a FileHandle');
0a5bd159 287ok(!defined FileHandle($GLOB_REF), '... FileHandle rejects anything which is not a FileHandle');
288ok(defined FileHandle($fh), '... FileHandle accepts anything which is a FileHandle');
128c601e 289ok(defined FileHandle($fh_obj), '... FileHandle accepts anything which is a FileHandle');
0a5bd159 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
a15dff8d 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');
0d51bf49 302ok(!defined Object($GLOB), '... Object rejects anything which is not blessed');
3f7376b0 303ok(!defined Object($GLOB_REF), '... Object rejects anything which is not blessed');
0a5bd159 304ok(!defined Object($fh), '... Object rejects anything which is not blessed');
a15dff8d 305ok(!defined Object(qr/../), '... Object rejects anything which is not blessed');
306ok(defined Object(bless {}, 'Foo'), '... Object accepts anything which is blessed');
5a4c5493 307ok(!defined Object(undef), '... Object accepts anything which is blessed');
02a0fb52 308
9af1d28b 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');
5030b52f 313
314{
315 package Quux::Wibble; # this makes Quux symbol table exist
5d776bdf 316
317 sub foo {}
5030b52f 318}
319
320ok(!defined ClassName('Quux'), '... ClassName rejects anything which is not a ClassName');
9af1d28b 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');
0d51bf49 326ok(!defined ClassName($GLOB), '... ClassName rejects anything which is not a ClassName');
9af1d28b 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');
5d776bdf 332ok(defined ClassName('Quux::Wibble'), '... ClassName accepts anything which is a ClassName');
9af1d28b 333ok(defined ClassName('Moose::Meta::TypeConstraint'), '... ClassName accepts anything which is a ClassName');
334
f0cac16f 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 Moose::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');
0d51bf49 352ok(!defined RoleName($GLOB), '... Rolename rejects anything which is not a RoleName');
f0cac16f 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');
6e478208 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('Moose::Meta::TypeConstraint'), '... RoleName accepts anything which is a RoleName');
f0cac16f 360ok(defined RoleName('Quux::Wibble::Role'), '... RoleName accepts anything which is a RoleName');
361
0a5bd159 362close($fh) || die "Could not close the filehandle $0 for test";
a28e50e4 363
364done_testing;