Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 /**
8 Filename: global.js
9 Description: 'Tests RegExp attribute global'
11 Author: Nick Lerissa
12 Date: March 13, 1998
13 */
15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
16 var VERSION = 'no version';
17 startTest();
18 var TITLE = 'RegExp: global';
20 writeHeaderToLog('Executing script: global.js');
21 writeHeaderToLog( SECTION + " "+ TITLE);
23 // /xyz/g.global
24 new TestCase ( SECTION, "/xyz/g.global",
25 true, /xyz/g.global);
27 // /xyz/.global
28 new TestCase ( SECTION, "/xyz/.global",
29 false, /xyz/.global);
31 // '123 456 789'.match(/\d+/g)
32 new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)",
33 String(["123","456","789"]), String('123 456 789'.match(/\d+/g)));
35 // '123 456 789'.match(/(\d+)/g)
36 new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)",
37 String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g)));
39 // '123 456 789'.match(/\d+/)
40 new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)",
41 String(["123"]), String('123 456 789'.match(/\d+/)));
43 // (new RegExp('[a-z]','g')).global
44 new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global",
45 true, (new RegExp('[a-z]','g')).global);
47 // (new RegExp('[a-z]','i')).global
48 new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global",
49 false, (new RegExp('[a-z]','i')).global);
51 // '123 456 789'.match(new RegExp('\\d+','g'))
52 new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))",
53 String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g'))));
55 // '123 456 789'.match(new RegExp('(\\d+)','g'))
56 new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))",
57 String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g'))));
59 // '123 456 789'.match(new RegExp('\\d+','i'))
60 new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))",
61 String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i'))));
63 test();