diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-10-20 16:17:19 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-10-20 16:17:19 -0500 |
commit | 9736bf12e7521f7d8a4587c6c4be9c47da39c7cf (patch) | |
tree | 4298d9f13f7fdc6066b4d95b95ac559317a9afca /t/10-errors.t | |
parent | b3bd5eb84e7a0251075360a04fd7e76a42815bcd (diff) | |
download | eval-closure-9736bf12e7521f7d8a4587c6c4be9c47da39c7cf.tar.gz eval-closure-9736bf12e7521f7d8a4587c6c4be9c47da39c7cf.zip |
more tests
Diffstat (limited to 't/10-errors.t')
-rw-r--r-- | t/10-errors.t | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/t/10-errors.t b/t/10-errors.t new file mode 100644 index 0000000..d8925ee --- /dev/null +++ b/t/10-errors.t @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Exception; + +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"; + +done_testing; |