diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-11-10 05:13:27 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-11-10 05:13:27 -0600 |
commit | fe890fb97648df1253becf110e4e4dfa3c2c8015 (patch) | |
tree | b007c3cbfd5efe61754da18a46880337b82c236b /t/11-line-differences.t | |
parent | 09e99c47aa98facc78b39e4931c12527a393dd48 (diff) | |
download | eval-closure-fe890fb97648df1253becf110e4e4dfa3c2c8015.tar.gz eval-closure-fe890fb97648df1253becf110e4e4dfa3c2c8015.zip |
use Devel::Hints where possible
this will avoid breaking memoization when generating coderefs with
descriptions, and should be more robust and useful
Diffstat (limited to 't/11-line-differences.t')
-rw-r--r-- | t/11-line-differences.t | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/t/11-line-differences.t b/t/11-line-differences.t new file mode 100644 index 0000000..4dd3625 --- /dev/null +++ b/t/11-line-differences.t @@ -0,0 +1,61 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Requires 'Test::Output'; + +use Eval::Closure; + +{ + my $code = eval_closure( + source => 'sub { warn "foo" }', + description => 'bar', + ); + { local $TODO = $] < 5.010 ? "line numbers from #line are slightly different" : undef; + stderr_is { $code->() } "foo at bar line 1.\n", "got the right line"; + } +} + +{ + my $code = eval_closure( + source => <<'SOURCE', + sub { + + warn "foo"; + + } +SOURCE + description => 'bar', + ); + { local $TODO = $] < 5.010 ? "line numbers from #line are slightly different" : undef; + stderr_is { $code->() } "foo at bar line 1.\n", "got the right line"; + } +} + +{ + my $code = eval_closure( + source => <<'SOURCE', + + sub { + warn "foo"; + } +SOURCE + description => 'bar', + ); + { local $TODO = $] < 5.010 ? "line numbers from #line are slightly different" : undef; + stderr_is { $code->() } "foo at bar line 1.\n", "got the right line"; + } +} + +{ + my $code = eval_closure( + source => '$sub', + environment => { '$sub' => \sub { warn "foo" } }, + description => 'bar', + ); + { local $TODO = $] < 5.010 ? "#line can't adjust line numbers inside non-evaled subs" : undef; + stderr_is { $code->() } "foo at bar line 1.\n", "got the right line"; + } +} + +done_testing; |