diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-08-04 11:22:03 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-08-04 11:22:03 -0700 |
commit | 38be3d0038ef87b22af88f80db1fbeb0292ce53b (patch) | |
tree | ec90a2d8674378fb4a23f38d89acb799c3881bc3 /dist | |
parent | c56ed9f6dbe3d89129c7f5a37b28d4fc398561e4 (diff) | |
download | perl-38be3d0038ef87b22af88f80db1fbeb0292ce53b.tar.gz |
Don’t let list const modification affect future retvals
In commit f99a5f08f203, I inadvertently made modifications to val-
ues return by list ‘constants’ affect what values are returned sub-
sequently.
It’s for this type of situation that PADTMP exists (values are never
referenced, but copied). So use it.
This is similar to 5608dcc62, which fixed #3105.
Diffstat (limited to 'dist')
-rw-r--r-- | dist/constant/t/constant.t | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/dist/constant/t/constant.t b/dist/constant/t/constant.t index 78f21ac2c2..111a8e1275 100644 --- a/dist/constant/t/constant.t +++ b/dist/constant/t/constant.t @@ -9,7 +9,7 @@ END { @warnings && print STDERR join "\n- ", "accumulated warnings:", @warnings use strict; -use Test::More tests => 104; +use Test::More tests => 105; my $TB = Test::More->builder; BEGIN { use_ok('constant'); } @@ -392,7 +392,7 @@ SKIP: { # Test that list constants are also immutable. This only works under # 5.19.3 and later. SKIP: { - skip "fails under 5.19.2 and earlier", 2 if $] < 5.019003; + skip "fails under 5.19.2 and earlier", 3 if $] < 5.019003; local $TODO = "disabled for now; breaks CPAN; see perl #119045"; use constant constant_list => 1..2; for (constant_list) { @@ -401,4 +401,16 @@ SKIP: { like $@, qr/^Modification of a read-only value attempted at /, "list constant has constant elements ($num)"; } + undef $TODO; + # Whether values are modifiable or no, modifying them should not affect + # future return values. + my @values; + for(1..2) { + for ((constant_list)[0]) { + push @values, $_; + eval {$_++}; + } + } + is $values[1], $values[0], + 'modifying list const elements does not affect future retavls'; } |