diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-10-31 16:24:41 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-10-31 16:24:41 -0500 |
commit | 01b68b64a3f85bdf4615d74d357a4e8735ead106 (patch) | |
tree | 84928d9da70adc3efb9a0a514c0962b53d66aede /t/10-errors.t | |
parent | 53b0abc5127b2a28344d9c17caefefcbebbee11b (diff) | |
download | eval-closure-01b68b64a3f85bdf4615d74d357a4e8735ead106.tar.gz eval-closure-01b68b64a3f85bdf4615d74d357a4e8735ead106.zip |
convert to Test::Fatal
Diffstat (limited to 't/10-errors.t')
-rw-r--r-- | t/10-errors.t | 82 |
1 files changed, 46 insertions, 36 deletions
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; |