summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-10-31 16:24:41 -0500
committerJesse Luehrs <doy@tozt.net>2010-10-31 16:24:41 -0500
commit01b68b64a3f85bdf4615d74d357a4e8735ead106 (patch)
tree84928d9da70adc3efb9a0a514c0962b53d66aede /t
parent53b0abc5127b2a28344d9c17caefefcbebbee11b (diff)
downloadeval-closure-01b68b64a3f85bdf4615d74d357a4e8735ead106.tar.gz
eval-closure-01b68b64a3f85bdf4615d74d357a4e8735ead106.zip
convert to Test::Fatal
Diffstat (limited to 't')
-rw-r--r--t/01-basic.t4
-rw-r--r--t/02-close-over.t18
-rw-r--r--t/03-description.t20
-rw-r--r--t/10-errors.t82
4 files changed, 70 insertions, 54 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
index 7856f6e..d6d9b37 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Eval::Closure;
@@ -12,7 +12,7 @@ use Eval::Closure;
);
ok($code, "got something");
- throws_ok { $code->() } qr/^called$/, "got the right thing";
+ like(exception { $code->() }, qr/^called$/, "got the right thing");
}
{
diff --git a/t/02-close-over.t b/t/02-close-over.t
index 4b0e06a..8a58aa3 100644
--- a/t/02-close-over.t
+++ b/t/02-close-over.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Eval::Closure;
@@ -37,12 +37,16 @@ use Test::Requires 'PadWalker';
my $foo = [];
my $env = { '$foo' => \$foo };
- throws_ok {
- my $code = eval_closure(
- source => 'sub { push @$foo, @_; return $__captures }',
- environment => $env,
- );
- } qr/Global symbol "\$__captures/, "we don't close over \$__captures";
+ like(
+ exception {
+ eval_closure(
+ source => 'sub { push @$foo, @_; return $__captures }',
+ environment => $env,
+ );
+ },
+ qr/Global symbol "\$__captures/,
+ "we don't close over \$__captures"
+ );
}
# it'd be nice if we could test that closing over other things wasn't possible,
diff --git a/t/03-description.t b/t/03-description.t
index 8f7d893..97f8372 100644
--- a/t/03-description.t
+++ b/t/03-description.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Eval::Closure;
@@ -17,10 +17,11 @@ SOURCE
source => $source,
);
- throws_ok {
- $code->();
- } qr/^foo at \(eval \d+\) line \d+\n/,
- "no location info if context isn't passed";
+ like(
+ exception { $code->() },
+ qr/^foo at \(eval \d+\) line \d+\n/,
+ "no location info if context isn't passed"
+ );
}
{
@@ -29,10 +30,11 @@ SOURCE
description => 'accessor foo (defined at Class.pm line 282)',
);
- throws_ok {
- $code->();
- } qr/^foo at accessor foo \(defined at Class\.pm line 282\) line 2\n/,
- "description is set";
+ like(
+ exception { $code->() },
+ qr/^foo at accessor foo \(defined at Class\.pm line 282\) line 2\n/,
+ "description is set"
+ );
}
done_testing;
diff --git a/t/10-errors.t b/t/10-errors.t
index d8925ee..e724e78 100644
--- a/t/10-errors.t
+++ b/t/10-errors.t
@@ -2,44 +2,54 @@
use strict;
use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Eval::Closure;
-throws_ok {
- eval_closure()
-} qr/'source'.*required/, "error when source isn't declared";
-
-throws_ok {
- eval_closure(
- source => {},
- )
-} qr/'source'.*string or array/, "error when source isn't string or array";
-
-throws_ok {
- eval_closure(
- source => '1',
- )
-} qr/'source'.*return.*sub/, "error when source doesn't return a sub";
-
-throws_ok {
- eval_closure(
- source => 'sub { }',
- environment => { 'foo' => \1 },
- )
-} qr/should start with \@, \%, or \$/, "error from malformed env";
-
-throws_ok {
- eval_closure(
- source => 'sub { }',
- environment => { '$foo' => 1 },
- )
-} qr/must be.*reference/, "error from non-ref value";
-
-throws_ok {
- eval_closure(
- source => '$1++',
- )
-} qr/Modification of a read-only value/, "gives us compile errors properly";
+like(
+ exception { eval_closure() },
+ qr/'source'.*required/,
+ "error when source isn't declared"
+);
+
+like(
+ exception { eval_closure(source => {}) },
+ qr/'source'.*string or array/,
+ "error when source isn't string or array"
+);
+
+like(
+ exception { eval_closure(source => 1) },
+ qr/'source'.*return.*sub/,
+ "error when source doesn't return a sub"
+);
+
+like(
+ exception {
+ eval_closure(
+ source => 'sub { }',
+ environment => { 'foo' => \1 },
+ )
+ },
+ qr/should start with \@, \%, or \$/,
+ "error from malformed env"
+);
+
+like(
+ exception {
+ eval_closure(
+ source => 'sub { }',
+ environment => { '$foo' => 1 },
+ )
+ },
+ qr/must be.*reference/,
+ "error from non-ref value"
+);
+
+like(
+ exception { eval_closure(source => '$1++') },
+ qr/Modification of a read-only value/,
+ "gives us compile errors properly"
+);
done_testing;