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