8c88aa7f52d5e757d1a4f9dfecd43437166c212b
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / parserstress / tests / ecma_3 / RegExp / regress-100199.js
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
4  *
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/
9  *
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
13  * License.
14  *
15  * The Original Code is mozilla.org code.
16  *
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.
21  *
22  * Contributor(s):
23  *   pschwartau@netscape.com
24  *
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.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39 /*
40  * Date: 17 September 2001
41  *
42  * SUMMARY: Regression test for Bugzilla bug 100199
43  * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199
44  *
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.
49  *
50  * Neither one of these conditions should cause syntax errors in a RegExp.
51  */
52 //-----------------------------------------------------------------------------
53 var gTestfile = 'regress-100199.js';
54 var i = 0;
55 var BUGNUMBER = 100199;
56 var summary = '[], [^] are valid RegExp conditions. Should not cause errors -';
57 var status = '';
58 var statusmessages = new Array();
59 var pattern = '';
60 var patterns = new Array();
61 var string = '';
62 var strings = new Array();
63 var actualmatch = '';
64 var actualmatches = new Array();
65 var expectedmatch = '';
66 var expectedmatches = new Array();
67
68
69 pattern = /[]/;
70 string = 'abc';
71 status = inSection(1);
72 actualmatch = string.match(pattern);
73 expectedmatch = null;
74 addThis();
75
76 string = '';
77 status = inSection(2);
78 actualmatch = string.match(pattern);
79 expectedmatch = null;
80 addThis();
81
82 string = '[';
83 status = inSection(3);
84 actualmatch = string.match(pattern);
85 expectedmatch = null;
86 addThis();
87
88 string = '/';
89 status = inSection(4);
90 actualmatch = string.match(pattern);
91 expectedmatch = null;
92 addThis();
93
94 string = '[';
95 status = inSection(5);
96 actualmatch = string.match(pattern);
97 expectedmatch = null;
98 addThis();
99
100 string = ']';
101 status = inSection(6);
102 actualmatch = string.match(pattern);
103 expectedmatch = null;
104 addThis();
105
106 string = '[]';
107 status = inSection(7);
108 actualmatch = string.match(pattern);
109 expectedmatch = null;
110 addThis();
111
112 string = '[ ]';
113 status = inSection(8);
114 actualmatch = string.match(pattern);
115 expectedmatch = null;
116 addThis();
117
118 string = '][';
119 status = inSection(9);
120 actualmatch = string.match(pattern);
121 expectedmatch = null;
122 addThis();
123
124
125 pattern = /a[]/;
126 string = 'abc';
127 status = inSection(10);
128 actualmatch = string.match(pattern);
129 expectedmatch = null;
130 addThis();
131
132 string = '';
133 status = inSection(11);
134 actualmatch = string.match(pattern);
135 expectedmatch = null;
136 addThis();
137
138 string = 'a[';
139 status = inSection(12);
140 actualmatch = string.match(pattern);
141 expectedmatch = null;
142 addThis();
143
144 string = 'a[]';
145 status = inSection(13);
146 actualmatch = string.match(pattern);
147 expectedmatch = null;
148 addThis();
149
150 string = '[';
151 status = inSection(14);
152 actualmatch = string.match(pattern);
153 expectedmatch = null;
154 addThis();
155
156 string = ']';
157 status = inSection(15);
158 actualmatch = string.match(pattern);
159 expectedmatch = null;
160 addThis();
161
162 string = '[]';
163 status = inSection(16);
164 actualmatch = string.match(pattern);
165 expectedmatch = null;
166 addThis();
167
168 string = '[ ]';
169 status = inSection(17);
170 actualmatch = string.match(pattern);
171 expectedmatch = null;
172 addThis();
173
174 string = '][';
175 status = inSection(18);
176 actualmatch = string.match(pattern);
177 expectedmatch = null;
178 addThis();
179
180
181 pattern = /[^]/;
182 string = 'abc';
183 status = inSection(19);
184 actualmatch = string.match(pattern);
185 expectedmatch = Array('a');
186 addThis();
187
188 string = '';
189 status = inSection(20);
190 actualmatch = string.match(pattern);
191 expectedmatch = null; //there are no characters to test against the condition
192 addThis();
193
194 string = '\/';
195 status = inSection(21);
196 actualmatch = string.match(pattern);
197 expectedmatch = Array('/');
198 addThis();
199
200 string = '\[';
201 status = inSection(22);
202 actualmatch = string.match(pattern);
203 expectedmatch = Array('[');
204 addThis();
205  
206 string = '[';
207 status = inSection(23);
208 actualmatch = string.match(pattern);
209 expectedmatch = Array('[');
210 addThis();
211
212 string = ']';
213 status = inSection(24);
214 actualmatch = string.match(pattern);
215 expectedmatch = Array(']');
216 addThis();
217
218 string = '[]';
219 status = inSection(25);
220 actualmatch = string.match(pattern);
221 expectedmatch = Array('[');
222 addThis();
223
224 string = '[ ]';
225 status = inSection(26);
226 actualmatch = string.match(pattern);
227 expectedmatch = Array('[');
228 addThis();
229
230 string = '][';
231 status = inSection(27);
232 actualmatch = string.match(pattern);
233 expectedmatch = Array(']');
234 addThis();
235
236
237 pattern = /a[^]/;
238 string = 'abc';
239 status = inSection(28);
240 actualmatch = string.match(pattern);
241 expectedmatch = Array('ab');
242 addThis();
243
244 string = '';
245 status = inSection(29);
246 actualmatch = string.match(pattern);
247 expectedmatch = null; //there are no characters to test against the condition
248 addThis();
249
250 string = 'a[';
251 status = inSection(30);
252 actualmatch = string.match(pattern);
253 expectedmatch = Array('a[');
254 addThis();
255
256 string = 'a]';
257 status = inSection(31);
258 actualmatch = string.match(pattern);
259 expectedmatch = Array('a]');
260 addThis();
261
262 string = 'a[]';
263 status = inSection(32);
264 actualmatch = string.match(pattern);
265 expectedmatch = Array('a[');
266 addThis();
267
268 string = 'a[ ]';
269 status = inSection(33);
270 actualmatch = string.match(pattern);
271 expectedmatch = Array('a[');
272 addThis();
273
274 string = 'a][';
275 status = inSection(34);
276 actualmatch = string.match(pattern);
277 expectedmatch = Array('a]');
278 addThis();
279
280
281
282
283 //-----------------------------------------------------------------------------
284 test();
285 //-----------------------------------------------------------------------------
286
287
288
289 function addThis()
290 {
291   statusmessages[i] = status;
292   patterns[i] = pattern;
293   strings[i] = string;
294   actualmatches[i] = actualmatch;
295   expectedmatches[i] = expectedmatch;
296   i++;
297 }
298
299
300 function test()
301 {
302   enterFunc ('test');
303   printBugNumber(BUGNUMBER);
304   printStatus (summary);
305   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
306   exitFunc ('test');
307 }