From: Karen Etheridge Date: Mon, 14 Mar 2011 21:41:04 +0000 (-0700) Subject: better Test::Fatal tests X-Git-Tag: 0.10~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=015b91679983f142397cd7172262a5e56f3cd850;p=gitmo%2FMooseX-UndefTolerant.git better Test::Fatal tests --- diff --git a/t/constructor.t b/t/constructor.t index a638cbf..ca51315 100644 --- a/t/constructor.t +++ b/t/constructor.t @@ -50,7 +50,7 @@ sub do_tests { my $obj = Foo->new(attr1 => undef); ok(!$obj->has_attr1, 'UT attr1 has no value when assigned undef in constructor'); - ok (exception { $obj = Foo->new(attr2 => undef) }, + is (exception { $obj = Foo->new(attr2 => undef) }, undef, 'But assigning undef to attr2 generates a type constraint error'); } @@ -73,7 +73,7 @@ sub do_tests { my $obj = Bar->new(attr1 => undef); ok(!$obj->has_attr1, 'attr1 has no value when assigned undef in constructor'); - ok (!exception { $obj = Bar->new(attr2 => undef) }, + is (exception { $obj = Bar->new(attr2 => undef) }, undef, 'assigning undef to attr2 does not produce an error'); ok(!$obj->has_attr2, 'attr2 has no value when assigned undef in constructor'); } @@ -98,7 +98,7 @@ Bar->meta->make_immutable; TODO: { local $TODO = 'some immutable cases are not handled yet'; # for now, catch errors - ok(! exception { do_tests }, 'tests do not die'); + is(exception { do_tests }, undef, 'tests do not die'); is(Test::More->builder->current_test, 28, 'if we got here, we can declare victory!'); } diff --git a/t/defaults.t b/t/defaults.t index bd0a6ad..6e29950 100644 --- a/t/defaults.t +++ b/t/defaults.t @@ -95,7 +95,7 @@ Bar->meta->make_immutable; TODO: { local $TODO = 'some immutable cases are not handled yet'; # for now, catch errors - ok(! exception { do_tests }, 'tests do not die'); + is (exception { do_tests }, undef, 'tests do not die'); is(Test::More->builder->current_test, 44, 'if we got here, we can declare victory!'); }