|
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 |
|
7 /** |
|
8 Filename: global.js |
|
9 Description: 'Tests RegExp attribute global' |
|
10 |
|
11 Author: Nick Lerissa |
|
12 Date: March 13, 1998 |
|
13 */ |
|
14 |
|
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'; |
|
19 |
|
20 writeHeaderToLog('Executing script: global.js'); |
|
21 writeHeaderToLog( SECTION + " "+ TITLE); |
|
22 |
|
23 // /xyz/g.global |
|
24 new TestCase ( SECTION, "/xyz/g.global", |
|
25 true, /xyz/g.global); |
|
26 |
|
27 // /xyz/.global |
|
28 new TestCase ( SECTION, "/xyz/.global", |
|
29 false, /xyz/.global); |
|
30 |
|
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))); |
|
34 |
|
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))); |
|
38 |
|
39 // '123 456 789'.match(/\d+/) |
|
40 new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)", |
|
41 String(["123"]), String('123 456 789'.match(/\d+/))); |
|
42 |
|
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); |
|
46 |
|
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); |
|
50 |
|
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')))); |
|
54 |
|
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')))); |
|
58 |
|
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')))); |
|
62 |
|
63 test(); |