Test that a lazy attr without a default or builder dies
[gitmo/Moose.git] / t / 040_type_constraints / 023_types_and_undef.t
index ca36bdb..549958c 100644 (file)
@@ -3,9 +3,8 @@
 use strict;
 use warnings;
 
-use Test::More tests => 54;
-use Test::Exception;
-
+use Test::More;
+use Test::Fatal;
 
 
 {
@@ -42,28 +41,28 @@ Moose::Util::TypeConstraints->export_type_constraints_as_functions;
 
 ok( Undef(undef),   '... undef is a Undef');
 ok(!Defined(undef), '... undef is NOT a Defined');
-ok(!Int(undef),     '... undef is NOT a Int');
+ok(!Int(undef),     '... undef is NOT an Int');
 ok(!Number(undef),  '... undef is NOT a Number');
 ok(!Str(undef),     '... undef is NOT a Str');
 ok(!String(undef),  '... undef is NOT a String');
 
 ok(!Undef(5),  '... 5 is a NOT a Undef');
 ok(Defined(5), '... 5 is a Defined');
-ok(Int(5),     '... 5 is a Int');
+ok(Int(5),     '... 5 is an Int');
 ok(Number(5),  '... 5 is a Number');
 ok(Str(5),     '... 5 is a Str');
 ok(!String(5), '... 5 is NOT a String');
 
 ok(!Undef(0.5),  '... 0.5 is a NOT a Undef');
 ok(Defined(0.5), '... 0.5 is a Defined');
-ok(!Int(0.5),    '... 0.5 is NOT a Int');
+ok(!Int(0.5),    '... 0.5 is NOT an Int');
 ok(Number(0.5),  '... 0.5 is a Number');
 ok(Str(0.5),     '... 0.5 is a Str');
 ok(!String(0.5), '... 0.5 is NOT a String');
 
 ok(!Undef('Foo'),  '... "Foo" is NOT a Undef');
 ok(Defined('Foo'), '... "Foo" is a Defined');
-ok(!Int('Foo'),    '... "Foo" is NOT a Int');
+ok(!Int('Foo'),    '... "Foo" is NOT an Int');
 ok(!Number('Foo'), '... "Foo" is NOT a Number');
 ok(Str('Foo'),     '... "Foo" is a Str');
 ok(String('Foo'),  '... "Foo" is a String');
@@ -71,43 +70,41 @@ ok(String('Foo'),  '... "Foo" is a String');
 
 my $foo = Foo->new;
 
-lives_ok { $foo->vUndef(undef) } '... undef is a Foo->Undef';
-dies_ok { $foo->vDefined(undef) } '... undef is NOT a Foo->Defined';
-dies_ok { $foo->vInt(undef) } '... undef is NOT a Foo->Int';
-dies_ok { $foo->vNumber(undef) } '... undef is NOT a Foo->Number';
-dies_ok { $foo->vStr(undef) } '... undef is NOT a Foo->Str';
-dies_ok { $foo->vString(undef) } '... undef is NOT a Foo->String';
-
-dies_ok { $foo->vUndef(5) } '... 5 is NOT a Foo->Undef';
-lives_ok { $foo->vDefined(5) } '... 5 is a Foo->Defined';
-lives_ok { $foo->vInt(5) } '... 5 is a Foo->Int';
-lives_ok { $foo->vNumber(5) } '... 5 is a Foo->Number';
-lives_ok { $foo->vStr(5) } '... 5 is a Foo->Str';
-dies_ok { $foo->vString(5) } '... 5 is NOT a Foo->String';
-
-dies_ok { $foo->vUndef(0.5) } '... 0.5 is NOT a Foo->Undef';
-lives_ok { $foo->vDefined(0.5) } '... 0.5 is a Foo->Defined';
-dies_ok { $foo->vInt(0.5) } '... 0.5 is NOT a Foo->Int';
-lives_ok { $foo->vNumber(0.5) } '... 0.5 is a Foo->Number';
-lives_ok { $foo->vStr(0.5) } '... 0.5 is a Foo->Str';
-dies_ok { $foo->vString(0.5) } '... 0.5 is NOT a Foo->String';
-
-dies_ok { $foo->vUndef('Foo') } '... "Foo" is NOT a Foo->Undef';
-lives_ok { $foo->vDefined('Foo') } '... "Foo" is a Foo->Defined';
-dies_ok { $foo->vInt('Foo') } '... "Foo" is NOT a Foo->Int';
-dies_ok { $foo->vNumber('Foo') } '... "Foo" is NOT a Foo->Number';
-lives_ok { $foo->vStr('Foo') } '... "Foo" is a Foo->Str';
-lives_ok { $foo->vString('Foo') } '... "Foo" is a Foo->String';
+is( exception { $foo->vUndef(undef) }, undef, '... undef is a Foo->Undef' );
+isnt( exception { $foo->vDefined(undef) }, undef, '... undef is NOT a Foo->Defined' );
+isnt( exception { $foo->vInt(undef) }, undef, '... undef is NOT a Foo->Int' );
+isnt( exception { $foo->vNumber(undef) }, undef, '... undef is NOT a Foo->Number' );
+isnt( exception { $foo->vStr(undef) }, undef, '... undef is NOT a Foo->Str' );
+isnt( exception { $foo->vString(undef) }, undef, '... undef is NOT a Foo->String' );
+
+isnt( exception { $foo->vUndef(5) }, undef, '... 5 is NOT a Foo->Undef' );
+is( exception { $foo->vDefined(5) }, undef, '... 5 is a Foo->Defined' );
+is( exception { $foo->vInt(5) }, undef, '... 5 is a Foo->Int' );
+is( exception { $foo->vNumber(5) }, undef, '... 5 is a Foo->Number' );
+is( exception { $foo->vStr(5) }, undef, '... 5 is a Foo->Str' );
+isnt( exception { $foo->vString(5) }, undef, '... 5 is NOT a Foo->String' );
+
+isnt( exception { $foo->vUndef(0.5) }, undef, '... 0.5 is NOT a Foo->Undef' );
+is( exception { $foo->vDefined(0.5) }, undef, '... 0.5 is a Foo->Defined' );
+isnt( exception { $foo->vInt(0.5) }, undef, '... 0.5 is NOT a Foo->Int' );
+is( exception { $foo->vNumber(0.5) }, undef, '... 0.5 is a Foo->Number' );
+is( exception { $foo->vStr(0.5) }, undef, '... 0.5 is a Foo->Str' );
+isnt( exception { $foo->vString(0.5) }, undef, '... 0.5 is NOT a Foo->String' );
+
+isnt( exception { $foo->vUndef('Foo') }, undef, '... "Foo" is NOT a Foo->Undef' );
+is( exception { $foo->vDefined('Foo') }, undef, '... "Foo" is a Foo->Defined' );
+isnt( exception { $foo->vInt('Foo') }, undef, '... "Foo" is NOT a Foo->Int' );
+isnt( exception { $foo->vNumber('Foo') }, undef, '... "Foo" is NOT a Foo->Number' );
+is( exception { $foo->vStr('Foo') }, undef, '... "Foo" is a Foo->Str' );
+is( exception { $foo->vString('Foo') }, undef, '... "Foo" is a Foo->String' );
 
 # the lazy tests
 
-lives_ok { $foo->v_lazy_Undef() } '... undef is a Foo->Undef';
-dies_ok { $foo->v_lazy_Defined() } '... undef is NOT a Foo->Defined';
-dies_ok { $foo->v_lazy_Int() } '... undef is NOT a Foo->Int';
-dies_ok { $foo->v_lazy_Number() } '... undef is NOT a Foo->Number';
-dies_ok { $foo->v_lazy_Str() } '... undef is NOT a Foo->Str';
-dies_ok { $foo->v_lazy_String() } '... undef is NOT a Foo->String';
-
-
-
+is( exception { $foo->v_lazy_Undef() }, undef, '... undef is a Foo->Undef' );
+isnt( exception { $foo->v_lazy_Defined() }, undef, '... undef is NOT a Foo->Defined' );
+isnt( exception { $foo->v_lazy_Int() }, undef, '... undef is NOT a Foo->Int' );
+isnt( exception { $foo->v_lazy_Number() }, undef, '... undef is NOT a Foo->Number' );
+isnt( exception { $foo->v_lazy_Str() }, undef, '... undef is NOT a Foo->Str' );
+isnt( exception { $foo->v_lazy_String() }, undef, '... undef is NOT a Foo->String' );
 
+done_testing;