| 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_T23 |
| 11 |
description: > |
| 12 |
Execute /(A)?(A.*)/.exec("zxcasd;fl\\\ ^AAAaaAAaaaf;lrlrzs") and |
| 13 |
check results |
| 14 |
---*/ |
| 15 |
|
| 16 |
var __string = "zxcasd;fl\\\ ^AAAaaAAaaaf;lrlrzs"; |
| 17 |
|
| 18 |
var __executed = /(A)?(A.*)/.exec(__string); |
| 19 |
|
| 20 |
var __expected = ["AAAaaAAaaaf;lrlrzs","A","AAaaAAaaaf;lrlrzs"]; |
| 21 |
__expected.index = 13; |
| 22 |
__expected.input = __string; |
| 23 |
|
| 24 |
//CHECK#1 |
| 25 |
if (__executed.length !== __expected.length) { |
| 26 |
$ERROR('#1: __string = "zxcasd;fl\\\ ^AAAaaAAaaaf;lrlrzs"; __executed = /(A)?(A.*)/.exec(__string); __executed.length === ' + __expected.length + '. Actual: ' + __executed.length); |
| 27 |
} |
| 28 |
|
| 29 |
//CHECK#2 |
| 30 |
if (__executed.index !== __expected.index) { |
| 31 |
$ERROR('#2: __string = "zxcasd;fl\\\ ^AAAaaAAaaaf;lrlrzs"; __executed = /(A)?(A.*)/.exec(__string); __executed.index === ' + __expected.index + '. Actual: ' + __executed.index); |
| 32 |
} |
| 33 |
|
| 34 |
//CHECK#3 |
| 35 |
if (__executed.input !== __expected.input) { |
| 36 |
$ERROR('#3: __string = "zxcasd;fl\\\ ^AAAaaAAaaaf;lrlrzs"; __executed = /(A)?(A.*)/.exec(__string); __executed.input === ' + __expected.input + '. Actual: ' + __executed.input); |
| 37 |
} |
| 38 |
|
| 39 |
//CHECK#4 |
| 40 |
for(var index=0; index<__expected.length; index++) { |
| 41 |
if (__executed[index] !== __expected[index]) { |
| 42 |
$ERROR('#4: __string = "zxcasd;fl\\\ ^AAAaaAAaaaf;lrlrzs"; __executed = /(A)?(A.*)/.exec(__string); __executed[' + index + '] === ' + __expected[index] + '. Actual: ' + __executed[index]); |
| 43 |
} |
| 44 |
} |