Debian Codegraph @

rhino/testsrc/tests/ecma_2/RegExp/unicode-001.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'unicode-001.js';
7
8 /**
9 * File Name: RegExp/unicode-001.js
10 * ECMA Section: 15.7.3.1
11 * Description: Based on ECMA 2 Draft 7 February 1999
12 * Positive test cases for constructing a RegExp object
13 * Author: [email protected]
14 * Date: 19 February 1999
15 */
16 var SECTION = "RegExp/unicode-001.js";
17 var VERSION = "ECMA_2";
18 var TITLE = "new RegExp( pattern, flags )";
19
20 startTest();
21
22 // These examples come from 15.7.1, UnicodeEscapeSequence
23
24 AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] );
25 AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] );
26 AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] );
27 AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] );
28
29 AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] );
30 AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] );
31 AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]);
32 AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] );
33
34 test();
35
36 function AddRegExpCases(
37 regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) {
38
39 AddTestCase(
40 str_regexp + " .exec(" + str_pattern +").length",
41 length,
42 regexp.exec(pattern).length );
43
44 AddTestCase(
45 str_regexp + " .exec(" + str_pattern +").index",
46 index,
47 regexp.exec(pattern).index );
48
49 AddTestCase(
50 str_regexp + " .exec(" + str_pattern +").input",
51 pattern,
52 regexp.exec(pattern).input );
53
54 for ( var matches = 0; matches < matches_array.length; matches++ ) {
55 AddTestCase(
56 str_regexp + " .exec(" + str_pattern +")[" + matches +"]",
57 matches_array[matches],
58 regexp.exec(pattern)[matches] );
59 }
60 }