Debian Codegraph @

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