summaryrefslogtreecommitdiff
path: root/t/re/subst.t
diff options
context:
space:
mode:
authorDan Collins <dcollinsn@gmail.com>2016-07-05 19:32:56 -0400
committerYves Orton <demerphq@gmail.com>2016-10-21 09:09:44 +0200
commit1994b2149827c9436ce57a14ec7545e836d1c857 (patch)
tree5a9e51f4893ee00ab32212ac29b4e00d40df898c /t/re/subst.t
parentcf8fa7337dbf6fe40dea123f1758112f579284c2 (diff)
downloadperl-1994b2149827c9436ce57a14ec7545e836d1c857.tar.gz
t/re/subst.t: tests for RT #23624
Diffstat (limited to 't/re/subst.t')
-rw-r--r--t/re/subst.t30
1 files changed, 29 insertions, 1 deletions
diff --git a/t/re/subst.t b/t/re/subst.t
index d32e7b8aef..6224d64ff2 100644
--- a/t/re/subst.t
+++ b/t/re/subst.t
@@ -11,7 +11,7 @@ BEGIN {
require './loc_tools.pl';
}
-plan( tests => 271 );
+plan( tests => 274 );
$_ = 'david';
$a = s/david/rules/r;
@@ -1119,3 +1119,31 @@ SKIP: {
{stderr => 1 },
'[perl #129038 ] s/\xff//l no longer crashes');
}
+
+{
+ # RT #23624 scoping of @+/@- when used with tie()
+ #! /usr/bin/perl -w
+
+ package Tie::Prematch;
+ sub TIEHASH { bless \my $dummy => __PACKAGE__ }
+ sub FETCH { return substr $_[1], 0, $-[0] }
+
+ package main;
+
+ tie my %pre, 'Tie::Prematch';
+ my $foo = 'foobar';
+ $foo =~ s/.ob/$pre{ $foo }/;
+ is($foo, 'ffar', 'RT #23624');
+
+ $foo = 'foobar';
+ $foo =~ s/.ob/tied(%pre)->FETCH($foo)/e;
+ is($foo, 'ffar', 'RT #23624');
+
+ tie %-, 'Tie::Prematch';
+ $foo = 'foobar';
+ $foo =~ s/.ob/$-{$foo}/;
+ is($foo, 'ffar', 'RT #23624');
+
+ undef *Tie::Prematch::TIEHASH;
+ undef *Tie::Prematch::FETCH;
+}