Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/compile.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 = 'compile.js';
7
8 /**
9 Filename: compile.js
10 Description: 'Tests regular expressions method compile'
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 = 'RegExp: compile';
20
21 writeHeaderToLog('Executing script: compile.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 var regularExpression = new RegExp();
25
26 regularExpression.compile("[0-9]{3}x[0-9]{4}","i");
27
28 new TestCase ( SECTION,
29 "(compile '[0-9]{3}x[0-9]{4}','i')",
30 String(["456X7890"]), String('234X456X7890'.match(regularExpression)));
31
32 new TestCase ( SECTION,
33 "source of (compile '[0-9]{3}x[0-9]{4}','i')",
34 "[0-9]{3}x[0-9]{4}", regularExpression.source);
35
36 new TestCase ( SECTION,
37 "global of (compile '[0-9]{3}x[0-9]{4}','i')",
38 false, regularExpression.global);
39
40 new TestCase ( SECTION,
41 "ignoreCase of (compile '[0-9]{3}x[0-9]{4}','i')",
42 true, regularExpression.ignoreCase);
43
44 regularExpression.compile("[0-9]{3}X[0-9]{3}","g");
45
46 new TestCase ( SECTION,
47 "(compile '[0-9]{3}X[0-9]{3}','g')",
48 String(["234X456"]), String('234X456X7890'.match(regularExpression)));
49
50 new TestCase ( SECTION,
51 "source of (compile '[0-9]{3}X[0-9]{3}','g')",
52 "[0-9]{3}X[0-9]{3}", regularExpression.source);
53
54 new TestCase ( SECTION,
55 "global of (compile '[0-9]{3}X[0-9]{3}','g')",
56 true, regularExpression.global);
57
58 new TestCase ( SECTION,
59 "ignoreCase of (compile '[0-9]{3}X[0-9]{3}','g')",
60 false, regularExpression.ignoreCase);
61
62
63 test();