diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-10-20 16:59:21 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-10-20 16:59:21 -0500 |
commit | 3efcc0874f36b6ce7acf839f017fc789abc40a8c (patch) | |
tree | 4f4cc83a371e9f8a0d0f24ba5ce4081d3ee06504 /t | |
parent | 9736bf12e7521f7d8a4587c6c4be9c47da39c7cf (diff) | |
download | eval-closure-3efcc0874f36b6ce7acf839f017fc789abc40a8c.tar.gz eval-closure-3efcc0874f36b6ce7acf839f017fc789abc40a8c.zip |
allow adding #line directives
Diffstat (limited to 't')
-rw-r--r-- | t/03-description.t | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/03-description.t b/t/03-description.t new file mode 100644 index 0000000..781ec72 --- /dev/null +++ b/t/03-description.t @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Exception; + +use Eval::Closure; + +my $source = <<'SOURCE'; +sub { + Carp::confess("foo") +} +SOURCE + +{ + my $code = eval_closure( + source => $source, + ); + + throws_ok { + $code->(); + } qr/^foo at \(eval \d+\) line 2\n/, + "no location info if context isn't passed"; +} + +{ + my $code = eval_closure( + source => $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"; +} + +done_testing; |