1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * pschwartau@netscape.com
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 * Date: 17 September 2001
42 * SUMMARY: Regression test for Bugzilla bug 100199
43 * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199
45 * The empty character class [] is a valid RegExp construct: the condition
46 * that a given character belong to a set containing no characters. As such,
47 * it can never be met and is always FALSE. Similarly, [^] is a condition
48 * that matches any given character and is always TRUE.
50 * Neither one of these conditions should cause syntax errors in a RegExp.
52 //-----------------------------------------------------------------------------
53 var gTestfile = 'regress-100199.js';
55 var BUGNUMBER = 100199;
56 var summary = '[], [^] are valid RegExp conditions. Should not cause errors -';
58 var statusmessages = new Array();
60 var patterns = new Array();
62 var strings = new Array();
64 var actualmatches = new Array();
65 var expectedmatch = '';
66 var expectedmatches = new Array();
71 status = inSection(1);
72 actualmatch = string.match(pattern);
77 status = inSection(2);
78 actualmatch = string.match(pattern);
83 status = inSection(3);
84 actualmatch = string.match(pattern);
89 status = inSection(4);
90 actualmatch = string.match(pattern);
95 status = inSection(5);
96 actualmatch = string.match(pattern);
101 status = inSection(6);
102 actualmatch = string.match(pattern);
103 expectedmatch = null;
107 status = inSection(7);
108 actualmatch = string.match(pattern);
109 expectedmatch = null;
113 status = inSection(8);
114 actualmatch = string.match(pattern);
115 expectedmatch = null;
119 status = inSection(9);
120 actualmatch = string.match(pattern);
121 expectedmatch = null;
127 status = inSection(10);
128 actualmatch = string.match(pattern);
129 expectedmatch = null;
133 status = inSection(11);
134 actualmatch = string.match(pattern);
135 expectedmatch = null;
139 status = inSection(12);
140 actualmatch = string.match(pattern);
141 expectedmatch = null;
145 status = inSection(13);
146 actualmatch = string.match(pattern);
147 expectedmatch = null;
151 status = inSection(14);
152 actualmatch = string.match(pattern);
153 expectedmatch = null;
157 status = inSection(15);
158 actualmatch = string.match(pattern);
159 expectedmatch = null;
163 status = inSection(16);
164 actualmatch = string.match(pattern);
165 expectedmatch = null;
169 status = inSection(17);
170 actualmatch = string.match(pattern);
171 expectedmatch = null;
175 status = inSection(18);
176 actualmatch = string.match(pattern);
177 expectedmatch = null;
183 status = inSection(19);
184 actualmatch = string.match(pattern);
185 expectedmatch = Array('a');
189 status = inSection(20);
190 actualmatch = string.match(pattern);
191 expectedmatch = null; //there are no characters to test against the condition
195 status = inSection(21);
196 actualmatch = string.match(pattern);
197 expectedmatch = Array('/');
201 status = inSection(22);
202 actualmatch = string.match(pattern);
203 expectedmatch = Array('[');
207 status = inSection(23);
208 actualmatch = string.match(pattern);
209 expectedmatch = Array('[');
213 status = inSection(24);
214 actualmatch = string.match(pattern);
215 expectedmatch = Array(']');
219 status = inSection(25);
220 actualmatch = string.match(pattern);
221 expectedmatch = Array('[');
225 status = inSection(26);
226 actualmatch = string.match(pattern);
227 expectedmatch = Array('[');
231 status = inSection(27);
232 actualmatch = string.match(pattern);
233 expectedmatch = Array(']');
239 status = inSection(28);
240 actualmatch = string.match(pattern);
241 expectedmatch = Array('ab');
245 status = inSection(29);
246 actualmatch = string.match(pattern);
247 expectedmatch = null; //there are no characters to test against the condition
251 status = inSection(30);
252 actualmatch = string.match(pattern);
253 expectedmatch = Array('a[');
257 status = inSection(31);
258 actualmatch = string.match(pattern);
259 expectedmatch = Array('a]');
263 status = inSection(32);
264 actualmatch = string.match(pattern);
265 expectedmatch = Array('a[');
269 status = inSection(33);
270 actualmatch = string.match(pattern);
271 expectedmatch = Array('a[');
275 status = inSection(34);
276 actualmatch = string.match(pattern);
277 expectedmatch = Array('a]');
283 //-----------------------------------------------------------------------------
285 //-----------------------------------------------------------------------------
291 statusmessages[i] = status;
292 patterns[i] = pattern;
294 actualmatches[i] = actualmatch;
295 expectedmatches[i] = expectedmatch;
303 printBugNumber(BUGNUMBER);
304 printStatus (summary);
305 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);