summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-01-04 18:41:14 -0600
committerJesse Luehrs <doy@tozt.net>2012-01-04 18:41:14 -0600
commit38311155f8bfb2ee335d4ac122ad148c83ea252e (patch)
tree1ad8c4dacc0a6cf26f7c01446cb4d3247273bbf5
parent96faf963aa8703449037aa46af1394a0e7831dc2 (diff)
downloadcircular-require-38311155f8bfb2ee335d4ac122ad148c83ea252e.tar.gz
circular-require-38311155f8bfb2ee335d4ac122ad148c83ea252e.zip
make this fix more general
-rw-r--r--lib/circular/require.pm9
-rw-r--r--t/eval.t11
-rw-r--r--t/eval/Bar.pm6
-rw-r--r--t/eval/Foo.pm3
4 files changed, 24 insertions, 5 deletions
diff --git a/lib/circular/require.pm b/lib/circular/require.pm
index 6a92b7b..3c65846 100644
--- a/lib/circular/require.pm
+++ b/lib/circular/require.pm
@@ -75,12 +75,11 @@ sub _require {
local $loaded_from{$string_file} = $previous_file;
local $previous_file = $string_file;
my $ret;
- # XXX ugh, base.pm checks against the regex
+ # ugh, base.pm checks against the regex
# /^Can't locate .*? at \(eval / to see if it should suppress the error
- # but we're not in an eval anymore... fake it for now, but this will
- # definitely break if some other module that overrides CORE::require tries
- # to do the same thing
- if (caller eq 'base') {
+ # but we're not in an eval anymore
+ # fake it up so that this looks the same
+ if (defined((caller(1))[6])) {
my $mod = _pm2mod($file);
$ret = $saved_require_hook
? $saved_require_hook->($file)
diff --git a/t/eval.t b/t/eval.t
new file mode 100644
index 0000000..d9ce952
--- /dev/null
+++ b/t/eval.t
@@ -0,0 +1,11 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use lib 't/eval';
+use Test::More;
+
+no circular::require;
+
+use_ok('Foo');
+
+done_testing;
diff --git a/t/eval/Bar.pm b/t/eval/Bar.pm
new file mode 100644
index 0000000..10b8543
--- /dev/null
+++ b/t/eval/Bar.pm
@@ -0,0 +1,6 @@
+package Bar;
+sub import {
+ eval "require Baz";
+ die $@ unless $@ =~ /\(eval /;
+}
+1;
diff --git a/t/eval/Foo.pm b/t/eval/Foo.pm
new file mode 100644
index 0000000..1558402
--- /dev/null
+++ b/t/eval/Foo.pm
@@ -0,0 +1,3 @@
+package Foo;
+use Bar;
+1;