| 1 |
// Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
info: | |
| 6 |
Parentheses of the form ( Disjunction ) serve both to group the components of the Disjunction pattern together and to save the result of the match. |
| 7 |
The result can be used either in a backreference (\ followed by a nonzero decimal number), |
| 8 |
referenced in a replace string, |
| 9 |
or returned as part of an array from the regular expression matching function |
| 10 |
es5id: 15.10.2.8_A3_T15 |
| 11 |
description: "see bug http:bugzilla.mozilla.org/show_bug.cgi?id=119909" |
| 12 |
---*/ |
| 13 |
|
| 14 |
var __strOriginal = "hello"; |
| 15 |
var __openParen = '('; |
| 16 |
var __closeParen = ')'; |
| 17 |
var __pattern = ''; |
| 18 |
var numParens = 200; |
| 19 |
|
| 20 |
for (var i=0; i<numParens; i++) |
| 21 |
__pattern += __openParen; |
| 22 |
|
| 23 |
__pattern += __strOriginal; |
| 24 |
|
| 25 |
for (i=0; i<numParens; i++) |
| 26 |
__pattern += __closeParen; |
| 27 |
|
| 28 |
var __re = new RegExp(__pattern); |
| 29 |
|
| 30 |
var __executed = __re.exec(__strOriginal); |
| 31 |
|
| 32 |
var __expected = []; |
| 33 |
for (var i=0; i<=numParens; i++) |
| 34 |
__expected.push(__strOriginal); |
| 35 |
__expected.index = 0; |
| 36 |
__expected.input = __strOriginal; |
| 37 |
|
| 38 |
//CHECK#1 |
| 39 |
if (__executed.length !== __expected.length) { |
| 40 |
$ERROR('#1: __re = new RegExp(__pattern); __executed = __re.exec(__strOriginal); __executed.length === ' + __expected.length + '. Actual: ' + __executed.length); |
| 41 |
} |
| 42 |
|
| 43 |
//CHECK#2 |
| 44 |
if (__executed.index !== __expected.index) { |
| 45 |
$ERROR('#2: __re = new RegExp(__pattern); __executed = __re.exec(__strOriginal); __executed.index === ' + __expected.index + '. Actual: ' + __executed.index); |
| 46 |
} |
| 47 |
|
| 48 |
//CHECK#3 |
| 49 |
if (__executed.input !== __expected.input) { |
| 50 |
$ERROR('#3: __re = new RegExp(__pattern); __executed = __re.exec(__strOriginal); __executed.input === ' + __expected.input + '. Actual: ' + __executed.input); |
| 51 |
} |
| 52 |
|
| 53 |
//CHECK#4 |
| 54 |
for(var index=0; index<__expected.length; index++) { |
| 55 |
if (__executed[index] !== __expected[index]) { |
| 56 |
$ERROR('#4: __re = new RegExp(__pattern); __executed = __re.exec(__strOriginal); __executed[' + index + '] === ' + __expected[index] + '. Actual: ' + __executed[index]); |
| 57 |
} |
| 58 |
} |