Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/global.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 = 'global.js';
7
8 /**
9 Filename: global.js
10 Description: 'Tests RegExp attribute global'
11
12 Author: Nick Lerissa
13 Date: March 13, 1998
14 */
15
16 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
17 var VERSION = 'no version';
18 startTest();
19 var TITLE = 'RegExp: global';
20
21 writeHeaderToLog('Executing script: global.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 // /xyz/g.global
25 new TestCase ( SECTION, "/xyz/g.global",
26 true, /xyz/g.global);
27
28 // /xyz/.global
29 new TestCase ( SECTION, "/xyz/.global",
30 false, /xyz/.global);
31
32 // '123 456 789'.match(/\d+/g)
33 new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)",
34 String(["123","456","789"]), String('123 456 789'.match(/\d+/g)));
35
36 // '123 456 789'.match(/(\d+)/g)
37 new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)",
38 String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g)));
39
40 // '123 456 789'.match(/\d+/)
41 new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)",
42 String(["123"]), String('123 456 789'.match(/\d+/)));
43
44 // (new RegExp('[a-z]','g')).global
45 new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global",
46 true, (new RegExp('[a-z]','g')).global);
47
48 // (new RegExp('[a-z]','i')).global
49 new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global",
50 false, (new RegExp('[a-z]','i')).global);
51
52 // '123 456 789'.match(new RegExp('\\d+','g'))
53 new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))",
54 String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g'))));
55
56 // '123 456 789'.match(new RegExp('(\\d+)','g'))
57 new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))",
58 String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g'))));
59
60 // '123 456 789'.match(new RegExp('\\d+','i'))
61 new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))",
62 String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i'))));
63
64 test();