]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_2/regexp/ignoreCase.js
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
23 Filename: ignoreCase.js
24 Description: 'Tests RegExp attribute ignoreCase'
30 var SECTION
= 'As described in Netscape doc "Whats new in JavaScript 1.2"';
31 var VERSION
= 'no version';
33 var TITLE
= 'RegExp: ignoreCase';
35 writeHeaderToLog('Executing script: ignoreCase.js');
36 writeHeaderToLog( SECTION
+ " "+ TITLE
);
39 var testcases
= new Array();
42 testcases
[count
++] = new TestCase ( SECTION
, "/xyz/i.ignoreCase",
43 true, /xyz/i.ignoreCase
);
46 testcases
[count
++] = new TestCase ( SECTION
, "/xyz/.ignoreCase",
47 false, /xyz/.ignoreCase
);
49 // 'ABC def ghi'.match(/[a-z]+/ig)
50 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(/[a-z]+/ig)",
51 String(["ABC","def","ghi"]), String('ABC def ghi'.match(/[a-z]+/ig)));
53 // 'ABC def ghi'.match(/[a-z]+/i)
54 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(/[a-z]+/i)",
55 String(["ABC"]), String('ABC def ghi'.match(/[a-z]+/i)));
57 // 'ABC def ghi'.match(/([a-z]+)/ig)
58 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(/([a-z]+)/ig)",
59 String(["ABC","def","ghi"]), String('ABC def ghi'.match(/([a-z]+)/ig)));
61 // 'ABC def ghi'.match(/([a-z]+)/i)
62 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(/([a-z]+)/i)",
63 String(["ABC","ABC"]), String('ABC def ghi'.match(/([a-z]+)/i)));
65 // 'ABC def ghi'.match(/[a-z]+/)
66 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(/[a-z]+/)",
67 String(["def"]), String('ABC def ghi'.match(/[a-z]+/)));
69 // (new RegExp('xyz','i')).ignoreCase
70 testcases
[count
++] = new TestCase ( SECTION
, "(new RegExp('xyz','i')).ignoreCase",
71 true, (new RegExp('xyz','i')).ignoreCase
);
73 // (new RegExp('xyz')).ignoreCase
74 testcases
[count
++] = new TestCase ( SECTION
, "(new RegExp('xyz')).ignoreCase",
75 false, (new RegExp('xyz')).ignoreCase
);
77 // 'ABC def ghi'.match(new RegExp('[a-z]+','ig'))
78 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(new RegExp('[a-z]+','ig'))",
79 String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('[a-z]+','ig'))));
81 // 'ABC def ghi'.match(new RegExp('[a-z]+','i'))
82 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(new RegExp('[a-z]+','i'))",
83 String(["ABC"]), String('ABC def ghi'.match(new RegExp('[a-z]+','i'))));
85 // 'ABC def ghi'.match(new RegExp('([a-z]+)','ig'))
86 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(new RegExp('([a-z]+)','ig'))",
87 String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','ig'))));
89 // 'ABC def ghi'.match(new RegExp('([a-z]+)','i'))
90 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(new RegExp('([a-z]+)','i'))",
91 String(["ABC","ABC"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','i'))));
93 // 'ABC def ghi'.match(new RegExp('[a-z]+'))
94 testcases
[count
++] = new TestCase ( SECTION
, "'ABC def ghi'.match(new RegExp('[a-z]+'))",
95 String(["def"]), String('ABC def ghi'.match(new RegExp('[a-z]+'))));
99 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
100 testcases
[tc
].passed
= writeTestCaseResult(
101 testcases
[tc
].expect
,
102 testcases
[tc
].actual
,
103 testcases
[tc
].description
+" = "+
104 testcases
[tc
].actual
);
105 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
108 return ( testcases
);