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/. */
9
Description: 'Tests RegExp attribute global'
15
var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
16
var VERSION = 'no version';
18
var TITLE = 'RegExp: global';
20
writeHeaderToLog('Executing script: global.js');
21
writeHeaderToLog( SECTION + " "+ TITLE);
24
new TestCase ( SECTION, "/xyz/g.global",
28
new TestCase ( SECTION, "/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'))));