summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2006-11-13 19:59:32 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-11-14 06:59:03 +0000
commit542fa716385f08c64e1dc5ef1d9ceacf2ee69d29 (patch)
tree3b7f267de643be37d6de28ee0b22c24bd6a857e2 /t
parentc8e599d3a7f82b1ac9916859e455d8fd113f5731 (diff)
downloadperl-542fa716385f08c64e1dc5ef1d9ceacf2ee69d29.tar.gz
Allow negative indexing in recursive patterns
Message-ID: <9b18b3110611130959k1fdd2485yd8eb1cd428de570a@mail.gmail.com> p4raw-id: //depot/perl@29267
Diffstat (limited to 't')
-rwxr-xr-xt/op/pat.t21
-rw-r--r--t/op/re_tests3
2 files changed, 21 insertions, 3 deletions
diff --git a/t/op/pat.t b/t/op/pat.t
index 0bc0eb675c..333165d185 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -3991,8 +3991,23 @@ for my $c ("z", "\0", "!", chr(254), chr(256)) {
for ("ABC","BAX") {
ok(/A (*THEN) X | B (*THEN) C/x,"Simple (*THEN) test");
}
-}
-
+}
+
+{
+ my $parens=qr/(\((?:[^()]++|(?-1))*+\))/;
+ local $_='foo((2*3)+4-3) + bar(2*(3+4)-1*(2-3))';
+ my ($all,$one,$two)=('','','');
+ if (/foo $parens \s* \+ \s* bar $parens/x) {
+ $all=$&;
+ $one=$1;
+ $two=$2;
+ }
+ iseq($one, '((2*3)+4-3)');
+ iseq($two, '(2*(3+4)-1*(2-3))');
+ iseq($all, 'foo((2*3)+4-3) + bar(2*(3+4)-1*(2-3))');
+ iseq($all, $_);
+}
+
#-------------------------------------------------------------------
# Keep the following tests last -- they may crash perl
@@ -4019,4 +4034,4 @@ ok((q(a)x 100) =~ /^(??{'(.)'x 100})/,
# Put new tests above the line, not here.
# Don't forget to update this!
-BEGIN { print "1..1341\n" };
+BEGIN { print "1..1345\n" };
diff --git a/t/op/re_tests b/t/op/re_tests
index 99c68243e5..078caa94be 100644
--- a/t/op/re_tests
+++ b/t/op/re_tests
@@ -1186,3 +1186,6 @@ a*(*F) aaaab n - -
(A(A|B(*ACCEPT)|C)D)(E) AB y $1 AB
(A(A|B(*ACCEPT)|C)D)(E) ACDE y $1$2$3 ACDCE
+(a)(?:(?-1)|(?+1))(b) aab y $&-$1-$2 aab-a-b
+(a)(?:(?-1)|(?+1))(b) abb y $&-$1-$2 abb-a-b
+(a)(?:(?-1)|(?+1))(b) acb n - -