Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/flags.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 = 'flags.js';
7
8 /**
9 Filename: regexp.js
10 Description: 'Tests regular expressions using flags "i" and "g"'
11
12 Author: Nick Lerissa
13 Date: March 10, 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 = 'regular expression flags with flags "i" and "g"';
20
21 writeHeaderToLog('Executing script: flags.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24
25 // testing optional flag 'i'
26 new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(/fghijk/i)",
27 String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(/fghijk/i)));
28
29 new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(new RegExp('fghijk','i'))",
30 String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(new RegExp("fghijk","i"))));
31
32 // testing optional flag 'g'
33 new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(/x./g)",
34 String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(/x./g)));
35
36 new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(new RegExp('x.','g'))",
37 String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(new RegExp('x.','g'))));
38
39 // testing optional flags 'g' and 'i'
40 new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./gi)",
41 String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./gi)));
42
43 new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','gi'))",
44 String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','gi'))));
45
46 new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./ig)",
47 String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./ig)));
48
49 new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','ig'))",
50 String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','ig'))));
51
52
53 test();
54