use strict;
use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Eval::Closure;
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,
use strict;
use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Eval::Closure;
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"
+ );
}
{
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;
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;