]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/RegExp/exec-002.js
2 * File Name: RegExp/exec-002.js
3 * ECMA Section: 15.7.5.3
4 * Description: Based on ECMA 2 Draft 7 February 1999
6 * Test cases provided by rogerl@netscape.com
8 * Author: christine@netscape.com
9 * Date: 19 February 1999
11 var SECTION
= "RegExp/exec-002";
12 var VERSION
= "ECMA_2";
13 var TITLE
= "RegExp.prototype.exec(string)";
18 * for each test case, verify:
19 * - type of object returned
20 * - length of the returned array
21 * - value of lastIndex
24 * - value of the array indices
98 ["adcaxc", "axc", "x"] );
126 'xx\"makudonarudo\"yy',
128 ["\"makudonarudo\"", "o"] );
138 function AddRegExpCases(
139 regexp
, pattern
, index
, matches_array
) {
141 // prevent a runtime error
143 if ( regexp
.exec(pattern
) == null || matches_array
== null ) {
145 regexp
+ ".exec(" + pattern
+")",
147 regexp
.exec(pattern
) );
152 regexp
+ ".exec(" + pattern
+").length",
153 matches_array
.length
,
154 regexp
.exec(pattern
).length
);
157 regexp
+ ".exec(" + pattern
+").index",
159 regexp
.exec(pattern
).index
);
162 regexp
+ ".exec(" + pattern
+").input",
164 regexp
.exec(pattern
).input
);
167 regexp
+ ".exec(" + pattern
+").toString()",
168 matches_array
.toString(),
169 regexp
.exec(pattern
).toString() );
171 var limit = matches_array.length > regexp.exec(pattern).length
172 ? matches_array.length
173 : regexp.exec(pattern).length;
175 for ( var matches = 0; matches < limit; matches++ ) {
177 regexp + ".exec(" + pattern +")[" + matches +"]",
178 matches_array[matches],
179 regexp.exec(pattern)[matches] );