1
/* The contents of this file are subject to the Netscape Public
2
* License Version 1.1 (the "License"); you may not use this file
3
* except in compliance with the License. You may obtain a copy of
4
* the License at http://www.mozilla.org/NPL/
6
* Software distributed under the License is distributed on an "AS
7
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8
* implied. See the License for the specific language governing
9
* rights and limitations under the License.
11
* The Original Code is Mozilla Communicator client code, released March
14
* The Initial Developer of the Original Code is Netscape Communications
15
* Corporation. Portions created by Netscape are
16
* Copyright (C) 1998 Netscape Communications Corporation. All
24
Description: 'Tests regular expressions method compile'
30
var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
31
var VERSION = 'no version';
33
var TITLE = 'RegExp: compile';
35
writeHeaderToLog('Executing script: compile.js');
36
writeHeaderToLog( SECTION + " "+ TITLE);
39
var testcases = new Array();
41
var regularExpression = new RegExp();
43
regularExpression.compile("[0-9]{3}x[0-9]{4}","i");
45
testcases[count++] = new TestCase ( SECTION,
46
"(compile '[0-9]{3}x[0-9]{4}','i')",
47
String(["456X7890"]), String('234X456X7890'.match(regularExpression)));
49
testcases[count++] = new TestCase ( SECTION,
50
"source of (compile '[0-9]{3}x[0-9]{4}','i')",
51
"[0-9]{3}x[0-9]{4}", regularExpression.source);
53
testcases[count++] = new TestCase ( SECTION,
54
"global of (compile '[0-9]{3}x[0-9]{4}','i')",
55
false, regularExpression.global);
57
testcases[count++] = new TestCase ( SECTION,
58
"ignoreCase of (compile '[0-9]{3}x[0-9]{4}','i')",
59
true, regularExpression.ignoreCase);
61
regularExpression.compile("[0-9]{3}X[0-9]{3}","g");
63
testcases[count++] = new TestCase ( SECTION,
64
"(compile '[0-9]{3}X[0-9]{3}','g')",
65
String(["234X456"]), String('234X456X7890'.match(regularExpression)));
67
testcases[count++] = new TestCase ( SECTION,
68
"source of (compile '[0-9]{3}X[0-9]{3}','g')",
69
"[0-9]{3}X[0-9]{3}", regularExpression.source);
71
testcases[count++] = new TestCase ( SECTION,
72
"global of (compile '[0-9]{3}X[0-9]{3}','g')",
73
true, regularExpression.global);
75
testcases[count++] = new TestCase ( SECTION,
76
"ignoreCase of (compile '[0-9]{3}X[0-9]{3}','g')",
77
false, regularExpression.ignoreCase);
82
for ( tc=0; tc < testcases.length; tc++ ) {
83
testcases[tc].passed = writeTestCaseResult(
86
testcases[tc].description +" = "+
87
testcases[tc].actual );
88
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";