]>
Commit | Line | Data |
---|---|---|
1 | /** | |
2 | * File Name: RegExp/unicode-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 | |
8 | */ | |
9 | var SECTION = "RegExp/unicode-001.js"; | |
10 | var VERSION = "ECMA_2"; | |
11 | var TITLE = "new RegExp( pattern, flags )"; | |
12 | ||
13 | startTest(); | |
14 | ||
15 | // These examples come from 15.7.1, UnicodeEscapeSequence | |
16 | ||
17 | AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); | |
18 | AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); | |
19 | AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); | |
20 | AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); | |
21 | ||
22 | AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); | |
23 | AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); | |
24 | AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); | |
25 | AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); | |
26 | ||
27 | test(); | |
28 | ||
29 | function AddRegExpCases( | |
30 | regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { | |
31 | ||
32 | AddTestCase( | |
33 | str_regexp + " .exec(" + str_pattern +").length", | |
34 | length, | |
35 | regexp.exec(pattern).length ); | |
36 | ||
37 | AddTestCase( | |
38 | str_regexp + " .exec(" + str_pattern +").index", | |
39 | index, | |
40 | regexp.exec(pattern).index ); | |
41 | ||
42 | AddTestCase( | |
43 | str_regexp + " .exec(" + str_pattern +").input", | |
44 | pattern, | |
45 | regexp.exec(pattern).input ); | |
46 | ||
47 | for ( var matches = 0; matches < matches_array.length; matches++ ) { | |
48 | AddTestCase( | |
49 | str_regexp + " .exec(" + str_pattern +")[" + matches +"]", | |
50 | matches_array[matches], | |
51 | regexp.exec(pattern)[matches] ); | |
52 | } | |
53 | } |