Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/S15.10.2.8_A3_T15.js

raw
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 assert.sameValue(
39 __executed.length,
40 __expected.length,
41 'The value of __executed.length is expected to equal the value of __expected.length'
42 );
43
44 assert.sameValue(
45 __executed.index,
46 __expected.index,
47 'The value of __executed.index is expected to equal the value of __expected.index'
48 );
49
50 assert.sameValue(
51 __executed.input,
52 __expected.input,
53 'The value of __executed.input is expected to equal the value of __expected.input'
54 );
55
56 for(var index=0; index<__expected.length; index++) {
57 assert.sameValue(
58 __executed[index],
59 __expected[index],
60 'The value of __executed[index] is expected to equal the value of __expected[index]'
61 );
62 }
63
64 reportCompare(0, 0);