]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/RegExp/hex-001.js
2 * File Name: RegExp/hex-001.js
3 * ECMA Section: 15.7.3.1
4 * Description: Based on ECMA 2 Draft 7 February 1999
5 * Positive test cases for constructing a RegExp object
6 * Author: christine@netscape.com
7 * Date: 19 February 1999
9 var SECTION
= "RegExp/hex-001";
10 var VERSION
= "ECMA_2";
11 var TITLE
= "RegExp patterns that contain HexicdecimalEscapeSequences";
15 // These examples come from 15.7.1, HexidecimalEscapeSequence
17 AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] );
18 AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] );
19 // Invalid hex escapes are syntax error; these are covered in the sputnik test suite.
20 // AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] );
22 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] );
23 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] );
24 AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]);
25 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] );
29 function AddRegExpCases(
30 regexp
, str_regexp
, pattern
, str_pattern
, length
, index
, matches_array
) {
32 // prevent a runtime error
34 if ( regexp
.exec(pattern
) == null || matches_array
== null ) {
36 str_regexp
+ ".exec(" + pattern
+")",
38 regexp
.exec(pattern
) );
44 str_regexp
+ ".exec(" + str_pattern
+").length",
46 regexp
.exec(pattern
).length
);
49 str_regexp
+ ".exec(" + str_pattern
+").index",
51 regexp
.exec(pattern
).index
);
54 str_regexp
+ ".exec(" + str_pattern
+").input",
56 regexp
.exec(pattern
).input
);
58 for ( var matches
= 0; matches
< matches_array
.length
; matches
++ ) {
60 str_regexp
+ ".exec(" + str_pattern
+")[" + matches
+"]",
61 matches_array
[matches
],
62 regexp
.exec(pattern
)[matches
] );