diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-02-22 15:19:34 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-02-22 15:19:34 +0000 |
commit | ccdda9cbebc935188ca88f492ce8739de41d890a (patch) | |
tree | 97e8f6073c2c97e495690a6f5435de8aafd95714 /t/op/magic.t | |
parent | e638587ce5c7e6f5bb569dca7be9a47a83a97b9d (diff) | |
download | perl-ccdda9cbebc935188ca88f492ce8739de41d890a.tar.gz |
Avoid loading modules for %! and %+ on meeting %{"foo::!"} and %{"foo::+"}
Previously, just %{"foo::!"} would not trigger a load of Errno, but
${"foo::!"}; %{"foo::!"}; would, due to the different code paths taken through
Perl_gv_fetchpvn_flags(). As the modules themselves are responsible for calling
tie on the relevant global variables, there never was a problem with the wrong
variables *getting* their behaviour. However, the attempted load of the XS
module Tie::Hash::NamedCapture for %{"foo::-} meant that t/op/leaky-magic.t
would not pass under minitest. This commit resolves that failure.
Diffstat (limited to 't/op/magic.t')
-rw-r--r-- | t/op/magic.t | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/t/op/magic.t b/t/op/magic.t index 6951850e0f..6701cf77cf 100644 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -12,7 +12,7 @@ BEGIN { use warnings; use Config; -plan (tests => 83); +plan (tests => 87); $Is_MSWin32 = $^O eq 'MSWin32'; $Is_NetWare = $^O eq 'NetWare'; @@ -445,6 +445,25 @@ SKIP: { ok ${"!"}{ENOENT}; } +# Check that we don't auto-load packages +foreach (['powie::!', 'Errno'], + ['powie::+', 'Tie::Hash::NamedCapture']) { + my ($symbol, $package) = @$_; + foreach my $scalar_first ('', '$$symbol;') { + my $desc = qq{Referencing %{"$symbol"}}; + $desc .= qq{ after mentioning \${"$symbol"}} if $scalar_first; + $desc .= " doesn't load $package"; + + fresh_perl_is(<<"EOP", 0, {}, $desc); +use strict qw(vars subs); +my \$symbol = '$symbol'; +$scalar_first; +1 if %{\$symbol}; +print scalar %${package}::; +EOP + } +} + is $^S, 0; eval { is $^S,1 }; eval " BEGIN { ok ! defined \$^S } "; |