diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-06-09 21:01:42 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-06-09 21:01:42 +0000 |
commit | 1b20cd17751091e44beebad6f2f7034a08eaa442 (patch) | |
tree | 38ec17ef74f8777c4538d150486291149faaabc5 /t/op/array.t | |
parent | 83bf042f79af6208af0620b081ee65543ecfed9f (diff) | |
download | perl-1b20cd17751091e44beebad6f2f7034a08eaa442.tar.gz |
$r = do {my @a; \$#a}; $$r = 503 # is also naughty and now warns
p4raw-id: //depot/perl@24784
Diffstat (limited to 't/op/array.t')
-rwxr-xr-x | t/op/array.t | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/t/op/array.t b/t/op/array.t index 16a3df5bca..956a934290 100755 --- a/t/op/array.t +++ b/t/op/array.t @@ -7,7 +7,7 @@ BEGIN { require 'test.pl'; -plan (88); +plan (91); # # @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them @@ -277,13 +277,20 @@ is ($got, ''); like($@, qr/Modification of non-creatable array value attempted, subscript -1/, "\$a[-1] = 0"); } -{ +sub test_arylen { + my $ref = shift; local $^W = 1; - my $a = \$#{[]}; - is ($$a, undef, "\$# on freed array is undef"); + is ($$ref, undef, "\$# on freed array is undef"); my @warn; local $SIG{__WARN__} = sub {push @warn, "@_"}; - $$a = 1000; + $$ref = 1000; is (scalar @warn, 1); like ($warn[0], qr/^Attempt to set length of freed array/); } + +{ + my $a = \$#{[]}; + # Need a new statement to make it go out of scope + test_arylen ($a); + test_arylen (do {my @a; \$#a}); +} |