summaryrefslogtreecommitdiff
path: root/t/Eval.pm
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2014-02-06 22:09:40 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2014-02-06 22:09:40 +0000
commit3621e4956cb037811317b0195d3248108c6658c3 (patch)
tree3b72d0c777a6299cb8e96bfdc856487b7358f605 /t/Eval.pm
downloadModule-Runtime-tarball-master.tar.gz
Module-Runtime-0.014HEADModule-Runtime-0.014master
Diffstat (limited to 't/Eval.pm')
-rw-r--r--t/Eval.pm41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/Eval.pm b/t/Eval.pm
new file mode 100644
index 0000000..bbd49e5
--- /dev/null
+++ b/t/Eval.pm
@@ -0,0 +1,41 @@
+package t::Eval;
+
+use warnings;
+use strict;
+
+use Test::More;
+
+sub _ok_no_eval() {
+ my $lastsub = "";
+ my $i = 0;
+ while(1) {
+ my @c = caller($i);
+ unless(@c) {
+ ok 0;
+ diag "failed to find main program in stack trace";
+ return;
+ }
+ my $sub = $c[3];
+ if($sub eq "main::eval_test") {
+ ok 1;
+ return;
+ }
+ my $type = $sub ne "(eval)" ? "subroutine" :
+ $c[7] ? "require" :
+ defined($c[6]) ? "string eval" : "block eval";
+ if($type =~ /eval/ && !($lastsub eq "t::Eval::BEGIN" &&
+ $type eq "block eval")) {
+ ok 0;
+ diag "have $type between module and main program";
+ return;
+ }
+ $lastsub = $sub;
+ $i++;
+ }
+}
+
+BEGIN { _ok_no_eval(); }
+_ok_no_eval();
+sub import { _ok_no_eval(); }
+
+1;