Debian Codegraph @

rhino/testsrc/tests/ecma_2/RegExp/multiline-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 = 'multiline-001.js';
7
8 /**
9 * File Name: RegExp/multiline-001.js
10 * ECMA Section:
11 * Description: Based on ECMA 2 Draft 7 February 1999
12 *
13 * Date: 19 February 1999
14 */
15
16 var SECTION = "RegExp/multiline-001";
17 var VERSION = "ECMA_2";
18 var TITLE = "RegExp: multiline flag";
19 var BUGNUMBER="343901";
20
21 startTest();
22
23 var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" +
24 "northern flicker\npileated\n";
25
26 AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] );
27
28 AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] );
29
30 test();
31
32
33 function AddRegExpCases
34 ( regexp, pattern, index, matches_array ) {
35
36 // prevent a runtime error
37
38 if ( regexp.exec(pattern) == null || matches_array == null ) {
39 AddTestCase(
40 regexp + ".exec(" + pattern +")",
41 matches_array,
42 regexp.exec(pattern) );
43
44 return;
45 }
46
47 AddTestCase(
48 regexp.toString() + ".exec(" + pattern +").length",
49 matches_array.length,
50 regexp.exec(pattern).length );
51
52 AddTestCase(
53 regexp.toString() + ".exec(" + pattern +").index",
54 index,
55 regexp.exec(pattern).index );
56
57 AddTestCase(
58 regexp + ".exec(" + pattern +").input",
59 pattern,
60 regexp.exec(pattern).input );
61
62
63 for ( var matches = 0; matches < matches_array.length; matches++ ) {
64 AddTestCase(
65 regexp + ".exec(" + pattern +")[" + matches +"]",
66 matches_array[matches],
67 regexp.exec(pattern)[matches] );
68 }
69 }