From: Yuval Kogman Date: Fri, 25 Sep 2009 19:53:15 +0000 (+0300) Subject: use Test::Exception instead of eval { } X-Git-Tag: 0.93~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6b584f6c4dc1c2108c1bc233caec49627b2cce04;p=gitmo%2FMoose.git use Test::Exception instead of eval { } --- diff --git a/t/010_basics/002_require_superclasses.t b/t/010_basics/002_require_superclasses.t index ba210e4..1d311a5 100644 --- a/t/010_basics/002_require_superclasses.t +++ b/t/010_basics/002_require_superclasses.t @@ -5,41 +5,43 @@ use warnings; use lib 't/lib', 'lib'; -use Test::More tests => 5; +use Test::More tests => 4; +use Test::Exception; { + package Bar; use Moose; - eval { extends 'Foo'; }; - ::ok(!$@, '... loaded Foo superclass correctly'); + ::lives_ok { extends 'Foo' } 'loaded Foo superclass correctly'; } { + package Baz; use Moose; - eval { extends 'Bar'; }; - ::ok(!$@, '... loaded (inline) Bar superclass correctly'); + ::lives_ok { extends 'Bar' } 'loaded (inline) Bar superclass correctly'; } { + package Foo::Bar; use Moose; - eval { extends 'Foo', 'Bar'; }; - ::ok(!$@, '... loaded Foo and (inline) Bar superclass correctly'); + ::lives_ok { extends 'Foo', 'Bar' } + 'loaded Foo and (inline) Bar superclass correctly'; } { + package Bling; use Moose; - eval { extends 'No::Class'; }; - my $e = $@; - ::ok($e, '... could not find the superclass (as expected)'); - ::like($e, qr{Can't locate No/Class\.pm in \@INC}, '... and got the error we expected'); + ::throws_ok { extends 'No::Class' } + qr{Can't locate No/Class\.pm in \@INC}, + 'correct error when superclass could not be found'; }