]>
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 AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] );
21 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] );
22 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] );
23 AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]);
24 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] );
28 function AddRegExpCases(
29 regexp
, str_regexp
, pattern
, str_pattern
, length
, index
, matches_array
) {
31 // prevent a runtime error
33 if ( regexp
.exec(pattern
) == null || matches_array
== null ) {
35 str_regexp
+ ".exec(" + pattern
+")",
37 regexp
.exec(pattern
) );
43 str_regexp
+ ".exec(" + str_pattern
+").length",
45 regexp
.exec(pattern
).length
);
48 str_regexp
+ ".exec(" + str_pattern
+").index",
50 regexp
.exec(pattern
).index
);
53 str_regexp
+ ".exec(" + str_pattern
+").input",
55 regexp
.exec(pattern
).input
);
57 for ( var matches
= 0; matches
< matches_array
.length
; matches
++ ) {
59 str_regexp
+ ".exec(" + str_pattern
+")[" + matches
+"]",
60 matches_array
[matches
],
61 regexp
.exec(pattern
)[matches
] );