summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-05-30 19:00:51 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-05-30 19:00:51 -0700
commitf6a9f8a45e0553298d2b10c734f5826f1ba7730f (patch)
tree4b0b0f7eb0287dfb26bf5483afe3653ec14cad64 /t
parent1ffdc07ca785ef0cec11dad494fa4b9670382300 (diff)
downloadperl-f6a9f8a45e0553298d2b10c734f5826f1ba7730f.tar.gz
[perl #72706] Test recursive substr lvalue
Diffstat (limited to 't')
-rw-r--r--t/op/sub_lval.t20
1 files changed, 19 insertions, 1 deletions
diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t
index 28d67631ac..c87b4840b9 100644
--- a/t/op/sub_lval.t
+++ b/t/op/sub_lval.t
@@ -3,7 +3,7 @@ BEGIN {
@INC = '../lib';
require './test.pl';
}
-plan tests=>91;
+plan tests=>97;
sub a : lvalue { my $a = 34; ${\(bless \$a)} } # Return a temporary
sub b : lvalue { ${\shift} }
@@ -582,6 +582,24 @@ is ($Tie_Array::val[0], "value");
};
&$r(0) = 7;
is $to_modify, 7, 'recursive lvalue sub';
+
+ # Recursive with substr [perl #72706]
+ my $val = '';
+ my $pie;
+ $pie = sub :lvalue {
+ my $depth = shift;
+ return &$pie($depth) if $depth--;
+ substr $val, 0;
+ };
+ for my $depth (0, 1, 2) {
+ my $value = "Good $depth";
+ eval {
+ &$pie($depth) = $value;
+ };
+ is($@, '', "recursive lvalue substr return depth $depth");
+ is($val, $value,
+ "value assigned to recursive lvalue substr (depth $depth)");
+ }
}
{ # bug #23790