summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-21 01:08:40 -0400
committerJesse Luehrs <doy@tozt.net>2013-06-21 01:08:40 -0400
commit0b8f07dffcac7063775d31a9fef6424a2141ab39 (patch)
tree3117576229e91bdd67a106671b85bce6b120aa18
parent889ca3fbbdd079873d52f94a23b01896be8f48de (diff)
downloadclass-refresh-0b8f07dffcac7063775d31a9fef6424a2141ab39.tar.gz
class-refresh-0b8f07dffcac7063775d31a9fef6424a2141ab39.zip
fix up this test a bit
-rw-r--r--t/compile-error.t30
-rw-r--r--t/data/compile-error/after/Foo.pm2
-rw-r--r--t/data/compile-error/before/Foo.pm2
-rw-r--r--t/data/compile-error/middle/Foo.pm2
4 files changed, 21 insertions, 15 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;
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;