2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
16 use Mouse::Util::TypeConstraints;
21 => where { defined($_) && !ref($_) && Scalar::Util::looks_like_number($_) };
24 => where { defined($_) && !ref($_) && !Scalar::Util::looks_like_number($_) };
26 has vUndef => ( is => 'rw', isa => 'Undef' );
27 has vDefined => ( is => 'rw', isa => 'Defined' );
28 has vInt => ( is => 'rw', isa => 'Int' );
29 has vNumber => ( is => 'rw', isa => 'Number' );
30 has vStr => ( is => 'rw', isa => 'Str' );
31 has vString => ( is => 'rw', isa => 'String' );
33 has v_lazy_Undef => ( is => 'rw', lazy => 1, default => sub { undef }, isa => 'Undef' );
34 has v_lazy_Defined => ( is => 'rw', lazy => 1, default => sub { undef }, isa => 'Defined' );
35 has v_lazy_Int => ( is => 'rw', lazy => 1, default => sub { undef }, isa => 'Int' );
36 has v_lazy_Number => ( is => 'rw', lazy => 1, default => sub { undef }, isa => 'Number' );
37 has v_lazy_Str => ( is => 'rw', lazy => 1, default => sub { undef }, isa => 'Str' );
38 has v_lazy_String => ( is => 'rw', lazy => 1, default => sub { undef }, isa => 'String' );
41 # EXPORT TYPE CONSTRAINTS
43 Mouse::Util::TypeConstraints->export_type_constraints_as_functions;
45 ok( Undef(undef), '... undef is a Undef');
46 ok(!Defined(undef), '... undef is NOT a Defined');
47 ok(!Int(undef), '... undef is NOT an Int');
48 ok(!Number(undef), '... undef is NOT a Number');
49 ok(!Str(undef), '... undef is NOT a Str');
50 ok(!String(undef), '... undef is NOT a String');
52 ok(!Undef(5), '... 5 is a NOT a Undef');
53 ok(Defined(5), '... 5 is a Defined');
54 ok(Int(5), '... 5 is an Int');
55 ok(Number(5), '... 5 is a Number');
56 ok(Str(5), '... 5 is a Str');
57 ok(!String(5), '... 5 is NOT a String');
59 ok(!Undef(0.5), '... 0.5 is a NOT a Undef');
60 ok(Defined(0.5), '... 0.5 is a Defined');
61 ok(!Int(0.5), '... 0.5 is NOT an Int');
62 ok(Number(0.5), '... 0.5 is a Number');
63 ok(Str(0.5), '... 0.5 is a Str');
64 ok(!String(0.5), '... 0.5 is NOT a String');
66 ok(!Undef('Foo'), '... "Foo" is NOT a Undef');
67 ok(Defined('Foo'), '... "Foo" is a Defined');
68 ok(!Int('Foo'), '... "Foo" is NOT an Int');
69 ok(!Number('Foo'), '... "Foo" is NOT a Number');
70 ok(Str('Foo'), '... "Foo" is a Str');
71 ok(String('Foo'), '... "Foo" is a String');
76 lives_ok { $foo->vUndef(undef) } '... undef is a Foo->Undef';
77 dies_ok { $foo->vDefined(undef) } '... undef is NOT a Foo->Defined';
78 dies_ok { $foo->vInt(undef) } '... undef is NOT a Foo->Int';
79 dies_ok { $foo->vNumber(undef) } '... undef is NOT a Foo->Number';
80 dies_ok { $foo->vStr(undef) } '... undef is NOT a Foo->Str';
81 dies_ok { $foo->vString(undef) } '... undef is NOT a Foo->String';
83 dies_ok { $foo->vUndef(5) } '... 5 is NOT a Foo->Undef';
84 lives_ok { $foo->vDefined(5) } '... 5 is a Foo->Defined';
85 lives_ok { $foo->vInt(5) } '... 5 is a Foo->Int';
86 lives_ok { $foo->vNumber(5) } '... 5 is a Foo->Number';
87 lives_ok { $foo->vStr(5) } '... 5 is a Foo->Str';
88 dies_ok { $foo->vString(5) } '... 5 is NOT a Foo->String';
90 dies_ok { $foo->vUndef(0.5) } '... 0.5 is NOT a Foo->Undef';
91 lives_ok { $foo->vDefined(0.5) } '... 0.5 is a Foo->Defined';
92 dies_ok { $foo->vInt(0.5) } '... 0.5 is NOT a Foo->Int';
93 lives_ok { $foo->vNumber(0.5) } '... 0.5 is a Foo->Number';
94 lives_ok { $foo->vStr(0.5) } '... 0.5 is a Foo->Str';
95 dies_ok { $foo->vString(0.5) } '... 0.5 is NOT a Foo->String';
97 dies_ok { $foo->vUndef('Foo') } '... "Foo" is NOT a Foo->Undef';
98 lives_ok { $foo->vDefined('Foo') } '... "Foo" is a Foo->Defined';
99 dies_ok { $foo->vInt('Foo') } '... "Foo" is NOT a Foo->Int';
100 dies_ok { $foo->vNumber('Foo') } '... "Foo" is NOT a Foo->Number';
101 lives_ok { $foo->vStr('Foo') } '... "Foo" is a Foo->Str';
102 lives_ok { $foo->vString('Foo') } '... "Foo" is a Foo->String';
106 lives_ok { $foo->v_lazy_Undef() } '... undef is a Foo->Undef';
107 dies_ok { $foo->v_lazy_Defined() } '... undef is NOT a Foo->Defined';
108 dies_ok { $foo->v_lazy_Int() } '... undef is NOT a Foo->Int';
109 dies_ok { $foo->v_lazy_Number() } '... undef is NOT a Foo->Number';
110 dies_ok { $foo->v_lazy_Str() } '... undef is NOT a Foo->Str';
111 dies_ok { $foo->v_lazy_String() } '... undef is NOT a Foo->String';