diff options
Diffstat (limited to 't/compile-error.t')
-rw-r--r-- | t/compile-error.t | 30 |
1 files changed, 18 insertions, 12 deletions
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; |