From: Vincent Pit Date: Sun, 18 Apr 2010 16:07:40 +0000 (+0200) Subject: Add a regression test for a bug that appeared while fixing RT #50570 but got re-fixed... X-Git-Tag: v0.20~4 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=87253a0488e3ed6c69d63a8526c99e5bb9c97e59;p=perl%2Fmodules%2Findirect.git Add a regression test for a bug that appeared while fixing RT #50570 but got re-fixed in a4ebcbe07de579d5877df84c114f162f49019724 --- diff --git a/MANIFEST b/MANIFEST index 5ccc288..9cc5beb 100644 --- a/MANIFEST +++ b/MANIFEST @@ -36,3 +36,7 @@ t/lib/indirect/TestRequired3Y.pm t/lib/indirect/TestRequired4/a0.pm t/lib/indirect/TestRequired4/b0.pm t/lib/indirect/TestRequired4/c0.pm +t/lib/indirect/TestRequired5/a0.pm +t/lib/indirect/TestRequired5/b0.pm +t/lib/indirect/TestRequired5/c0.pm +t/lib/indirect/TestRequired5/d0.pm diff --git a/t/30-scope.t b/t/30-scope.t index 7f31ebb..a63bf04 100644 --- a/t/30-scope.t +++ b/t/30-scope.t @@ -6,7 +6,7 @@ use warnings; my $tests; BEGIN { $tests = 18 } -use Test::More tests => (1 + $tests + 1) + 3 + 3 + 3 + 5 + 4 + 2; +use Test::More tests => (1 + $tests + 1) + 3 + 3 + 3 + 5 + 4 + 3; BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} } @@ -161,6 +161,12 @@ sub expect { like $err, qr/^Can't locate object method "new" via package "X"/, 'RT #50570'; } +# This test must be in the topmost scope +BEGIN { eval 'use indirect::TestRequired5::a0' } +my $err = indirect::TestRequired5::a0::error(); +like $err, qr/^Can't locate object method "new" via package "X"/, + 'identifying requires by their eval context pointer is not enough'; + __DATA__ my $a = new P1; diff --git a/t/lib/indirect/TestRequired5/a0.pm b/t/lib/indirect/TestRequired5/a0.pm new file mode 100644 index 0000000..159d4d6 --- /dev/null +++ b/t/lib/indirect/TestRequired5/a0.pm @@ -0,0 +1,9 @@ +package indirect::TestRequired5::a0; +no indirect ":fatal"; +use indirect::TestRequired5::b0; +sub error { + local $@; + indirect::TestRequired5::b0->get; + return $@; +} +1; diff --git a/t/lib/indirect/TestRequired5/b0.pm b/t/lib/indirect/TestRequired5/b0.pm new file mode 100644 index 0000000..b71bde8 --- /dev/null +++ b/t/lib/indirect/TestRequired5/b0.pm @@ -0,0 +1,5 @@ +package indirect::TestRequired5::b0; +sub get { + eval 'require indirect::TestRequired5::c0'; +} +1; diff --git a/t/lib/indirect/TestRequired5/c0.pm b/t/lib/indirect/TestRequired5/c0.pm new file mode 100644 index 0000000..3668c79 --- /dev/null +++ b/t/lib/indirect/TestRequired5/c0.pm @@ -0,0 +1,3 @@ +package indirect::TestRequired5::c0; +require indirect::TestRequired5::d0; +1; diff --git a/t/lib/indirect/TestRequired5/d0.pm b/t/lib/indirect/TestRequired5/d0.pm new file mode 100644 index 0000000..a9b21a8 --- /dev/null +++ b/t/lib/indirect/TestRequired5/d0.pm @@ -0,0 +1,3 @@ +package indirect::TestRequired5::d0; +new X; +1;