summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2013-06-26 00:59:09 +0200
committerYves Orton <demerphq@gmail.com>2013-06-26 01:01:22 +0200
commit31108f3ee208f24233c8e0552036baa0d75dfa81 (patch)
tree40370a6368af56e42d8c36fa148da1a730465ddb /t
parentf1e1b256c5c1773d90e828cca6323c53fa23391b (diff)
downloadperl-31108f3ee208f24233c8e0552036baa0d75dfa81.tar.gz
Add tests for a backreference following a literal, which is a different codepath
/\87/ is parsed through a different code path than /foo\87/ so we test that they both work properly when there are sufficient capture buffers defined. We test the fail cases in the re/re_tests corpus, but the success cases are easier managed in re/pat.t.
Diffstat (limited to 't')
-rw-r--r--t/re/pat.t24
1 files changed, 13 insertions, 11 deletions
diff --git a/t/re/pat.t b/t/re/pat.t
index 99d719d015..8793f944b1 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -20,7 +20,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 570; # Update this when adding/deleting tests.
+plan tests => 670; # Update this when adding/deleting tests.
run_tests() unless caller;
@@ -1366,17 +1366,19 @@ EOP
{
# if we have 87 capture buffers defined then \87 should refer to the 87th.
# test that this is true for 1..100
- my $str= "aa";
for my $i (1..100) {
- my $pat= "a";
- $pat= "($pat)" for 1 .. $i;
- $pat.="\\$i";
- eval {
- ok($str=~/$pat/,"\\$i works with $i buffers");
- 1;
- } or do {
- ok(0,"\\$i works with $i buffers");
- };
+ my $capture= "a";
+ $capture= "($capture)" for 1 .. $i;
+ for my $mid ("","b") {
+ my $str= "a${mid}a";
+ my $backref= "\\$i";
+ eval {
+ ok($str=~/$capture$mid$backref/,"\\$i works with $i buffers '$str'=~/...$mid$backref/");
+ 1;
+ } or do {
+ is("$@","","\\$i works with $i buffers works with $i buffers '$str'=~/...$mid$backref/");
+ };
+ }
}
}