]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/RegExp/octal-003.js
2 * File Name: RegExp/octal-003.js
4 * Description: Based on ECMA 2 Draft 7 February 1999
5 * Simple test cases for matching OctalEscapeSequences.
6 * Author: christine@netscape.com
7 * Date: 19 February 1999
9 * Revised: 02 August 2002
10 * Author: pschwartau@netscape.com
12 * WHY: the original test expected the regexp /.\011/
13 * to match 'a' + String.fromCharCode(0) + '11'
15 * This is incorrect: the string is a 4-character string consisting of
16 * the characters <'a'>, <nul>, <'1'>, <'1'>. By contrast, the \011 in the
17 * regexp should be parsed as a single token: it is the octal escape sequence
18 * for the horizontal tab character '\t' === '\u0009' === '\x09' === '\011'.
20 * So the regexp consists of 2 characters: <any-character>, <'\t'>.
21 * There is no match between the regexp and the string.
23 * See the testcase ecma_3/RegExp/octal-002.js for an elaboration.
26 var SECTION
= "RegExp/octal-003.js";
27 var VERSION
= "ECMA_2";
28 var TITLE
= "RegExp patterns that contain OctalEscapeSequences";
29 var BUGNUMBER
="http://scopus/bugsplat/show_bug.cgi?id=346132";
33 AddRegExpCases( /.\011/, "/\\011/", "a" + String
.fromCharCode(0) + "11", "a\\011", 0, null );
37 function AddRegExpCases(
38 regexp
, str_regexp
, pattern
, str_pattern
, index
, matches_array
) {
40 // prevent a runtime error
42 if ( regexp
.exec(pattern
) == null || matches_array
== null ) {
44 regexp
+ ".exec(" + str_pattern
+")",
46 regexp
.exec(pattern
) );
51 str_regexp
+ ".exec(" + str_pattern
+").length",
53 regexp
.exec(pattern
).length
);
56 str_regexp
+ ".exec(" + str_pattern
+").index",
58 regexp
.exec(pattern
).index
);
61 str_regexp
+ ".exec(" + str_pattern
+").input",
63 escape(regexp
.exec(pattern
).input
) );
66 str_regexp
+ ".exec(" + str_pattern
+").toString()",
67 matches_array
.toString(),
68 escape(regexp
.exec(pattern
).toString()) );
70 var limit
= matches_array
.length
> regexp
.exec(pattern
).length
71 ? matches_array
.length
72 : regexp
.exec(pattern
).length
;
74 for ( var matches
= 0; matches
< limit
; matches
++ ) {
76 str_regexp
+ ".exec(" + str_pattern
+")[" + matches
+"]",
77 matches_array
[matches
],
78 escape(regexp
.exec(pattern
)[matches
]) );