summaryrefslogtreecommitdiffstats
path: root/js/src/tests/js1_2/regexp/global.js
blob: 442374cd9572a55126f79f5c728c37be69d58eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


/**
   Filename:     global.js
   Description:  'Tests RegExp attribute global'

   Author:       Nick Lerissa
   Date:         March 13, 1998
*/

var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
var VERSION = 'no version';
startTest();
var TITLE = 'RegExp: global';

writeHeaderToLog('Executing script: global.js');
writeHeaderToLog( SECTION + " "+ TITLE);

// /xyz/g.global
new TestCase ( SECTION, "/xyz/g.global",
	       true, /xyz/g.global);

// /xyz/.global
new TestCase ( SECTION, "/xyz/.global",
	       false, /xyz/.global);

// '123 456 789'.match(/\d+/g)
new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)",
	       String(["123","456","789"]), String('123 456 789'.match(/\d+/g)));

// '123 456 789'.match(/(\d+)/g)
new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)",
	       String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g)));

// '123 456 789'.match(/\d+/)
new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)",
	       String(["123"]), String('123 456 789'.match(/\d+/)));

// (new RegExp('[a-z]','g')).global
new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global",
	       true, (new RegExp('[a-z]','g')).global);

// (new RegExp('[a-z]','i')).global
new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global",
	       false, (new RegExp('[a-z]','i')).global);

// '123 456 789'.match(new RegExp('\\d+','g'))
new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))",
	       String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g'))));

// '123 456 789'.match(new RegExp('(\\d+)','g'))
new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))",
	       String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g'))));

// '123 456 789'.match(new RegExp('\\d+','i'))
new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))",
	       String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i'))));

test();