From 0b8f07dffcac7063775d31a9fef6424a2141ab39 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 21 Jun 2013 01:08:40 -0400 Subject: fix up this test a bit --- t/compile-error.t | 30 ++++++++++++++++++------------ t/data/compile-error/after/Foo.pm | 2 +- t/data/compile-error/before/Foo.pm | 2 +- t/data/compile-error/middle/Foo.pm | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) (limited to 't') diff --git a/t/compile-error.t b/t/compile-error.t index afc06a6..db4e980 100644 --- a/t/compile-error.t +++ b/t/compile-error.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Requires 'Moose'; use lib 't/lib'; use Test::Class::Refresh; @@ -15,29 +15,35 @@ push @INC, $dir->dirname; require Foo; -Class::Refresh->refresh; +is(exception { Class::Refresh->refresh }, undef, "loads successfully"); my $foo = Foo->new; -lives_ok { $foo->meth } '$foo->meth works'; +my $val; +is(exception { $val = $foo->meth }, undef, "\$foo->meth works"); +is($val, 1, "got the right value"); sleep 2; update_temp_dir_for('compile-error', $dir, 'middle'); -try { -Class::Refresh->refresh; -}; +like( + exception { Class::Refresh->refresh }, + qr/^Global symbol "\$error" requires explicit package name/, + "compilation error" +); -dies_ok { $foo->meth } '$foo->meth doesnt work now'; +like( + exception { $foo->meth }, + qr/^Can't locate object method "meth" via package "Foo"/, + "\$foo->meth doesn't work now" +); sleep 2; update_temp_dir_for('compile-error', $dir, 'after'); -try { -Class::Refresh->refresh; -}; - -lives_ok { $foo->meth } '$foo->meth works again'; +is(exception { Class::Refresh->refresh }, undef, "loads successfully"); +is(exception { $val = $foo->meth }, undef, "\$foo->meth works again"); +is($val, 3, "got the right value"); done_testing; diff --git a/t/data/compile-error/after/Foo.pm b/t/data/compile-error/after/Foo.pm index 18b5fa8..fe8e08b 100644 --- a/t/data/compile-error/after/Foo.pm +++ b/t/data/compile-error/after/Foo.pm @@ -3,7 +3,7 @@ use Moose; has bar => (is => 'ro'); -sub meth { my $error; } +sub meth { my $error; 3 } no Moose; diff --git a/t/data/compile-error/before/Foo.pm b/t/data/compile-error/before/Foo.pm index a63046a..9faa961 100644 --- a/t/data/compile-error/before/Foo.pm +++ b/t/data/compile-error/before/Foo.pm @@ -3,7 +3,7 @@ use Moose; has foo => (is => 'ro'); -sub meth { } +sub meth { 1 } no Moose; diff --git a/t/data/compile-error/middle/Foo.pm b/t/data/compile-error/middle/Foo.pm index 3e3946c..d7a61f1 100644 --- a/t/data/compile-error/middle/Foo.pm +++ b/t/data/compile-error/middle/Foo.pm @@ -3,7 +3,7 @@ use Moose; has bar => (is => 'ro'); -sub meth { $error } +sub meth { $error; 2 } no Moose; -- cgit v1.2.3-54-g00ecf