|
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 var BUGNUMBER = 351463; |
|
8 var summary = 'Treat hyphens as not special adjacent to CharacterClassEscapes in character classes'; |
|
9 var actual = ''; |
|
10 var expect = ''; |
|
11 |
|
12 |
|
13 //----------------------------------------------------------------------------- |
|
14 test(); |
|
15 //----------------------------------------------------------------------------- |
|
16 |
|
17 function test() |
|
18 { |
|
19 enterFunc ('test'); |
|
20 printBugNumber(BUGNUMBER); |
|
21 printStatus (summary); |
|
22 |
|
23 var r; |
|
24 var s = 'a0- z'; |
|
25 |
|
26 r = '([\\d-\\s]+)'; |
|
27 expect = ['0- ', '0- '] + ''; |
|
28 actual = null; |
|
29 |
|
30 try |
|
31 { |
|
32 actual = new RegExp(r).exec(s) + ''; |
|
33 } |
|
34 catch(ex) |
|
35 { |
|
36 actual = ex + ''; |
|
37 } |
|
38 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
39 |
|
40 r = '([\\s-\\d]+)'; |
|
41 expect = ['0- ', '0- '] + ''; |
|
42 actual = null; |
|
43 |
|
44 try |
|
45 { |
|
46 actual = new RegExp(r).exec(s) + ''; |
|
47 } |
|
48 catch(ex) |
|
49 { |
|
50 actual = ex + ''; |
|
51 } |
|
52 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
53 |
|
54 r = '([\\D-\\s]+)'; |
|
55 expect = ['a', 'a'] + ''; |
|
56 actual = null; |
|
57 |
|
58 try |
|
59 { |
|
60 actual = new RegExp(r).exec(s) + ''; |
|
61 } |
|
62 catch(ex) |
|
63 { |
|
64 actual = ex + ''; |
|
65 } |
|
66 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
67 |
|
68 r = '([\\s-\\D]+)'; |
|
69 expect = ['a', 'a'] + ''; |
|
70 actual = null; |
|
71 |
|
72 try |
|
73 { |
|
74 actual = new RegExp(r).exec(s) + ''; |
|
75 } |
|
76 catch(ex) |
|
77 { |
|
78 actual = ex + ''; |
|
79 } |
|
80 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
81 |
|
82 r = '([\\d-\\S]+)'; |
|
83 expect = ['a0-', 'a0-'] + ''; |
|
84 actual = null; |
|
85 |
|
86 try |
|
87 { |
|
88 actual = new RegExp(r).exec(s) + ''; |
|
89 } |
|
90 catch(ex) |
|
91 { |
|
92 actual = ex + ''; |
|
93 } |
|
94 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
95 |
|
96 r = '([\\S-\\d]+)'; |
|
97 expect = ['a0-', 'a0-'] + ''; |
|
98 actual = null; |
|
99 |
|
100 try |
|
101 { |
|
102 actual = new RegExp(r).exec(s) + ''; |
|
103 } |
|
104 catch(ex) |
|
105 { |
|
106 actual = ex + ''; |
|
107 } |
|
108 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
109 |
|
110 r = '([\\D-\\S]+)'; |
|
111 expect = ['a0- z', 'a0- z'] + ''; |
|
112 actual = null; |
|
113 |
|
114 try |
|
115 { |
|
116 actual = new RegExp(r).exec(s) + ''; |
|
117 } |
|
118 catch(ex) |
|
119 { |
|
120 actual = ex + ''; |
|
121 } |
|
122 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
123 |
|
124 r = '([\\S-\\D]+)'; |
|
125 expect = ['a0- z', 'a0- z'] + ''; |
|
126 actual = null; |
|
127 |
|
128 try |
|
129 { |
|
130 actual = new RegExp(r).exec(s) + ''; |
|
131 } |
|
132 catch(ex) |
|
133 { |
|
134 actual = ex + ''; |
|
135 } |
|
136 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
137 |
|
138 // -- |
|
139 |
|
140 r = '([\\w-\\s]+)'; |
|
141 expect = ['a0- z', 'a0- z'] + ''; |
|
142 actual = null; |
|
143 |
|
144 try |
|
145 { |
|
146 actual = new RegExp(r).exec(s) + ''; |
|
147 } |
|
148 catch(ex) |
|
149 { |
|
150 actual = ex + ''; |
|
151 } |
|
152 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
153 |
|
154 r = '([\\s-\\w]+)'; |
|
155 expect = ['a0- z', 'a0- z'] + ''; |
|
156 actual = null; |
|
157 |
|
158 try |
|
159 { |
|
160 actual = new RegExp(r).exec(s) + ''; |
|
161 } |
|
162 catch(ex) |
|
163 { |
|
164 actual = ex + ''; |
|
165 } |
|
166 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
167 |
|
168 r = '([\\W-\\s]+)'; |
|
169 expect = ['- ', '- '] + ''; |
|
170 actual = null; |
|
171 |
|
172 try |
|
173 { |
|
174 actual = new RegExp(r).exec(s) + ''; |
|
175 } |
|
176 catch(ex) |
|
177 { |
|
178 actual = ex + ''; |
|
179 } |
|
180 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
181 |
|
182 r = '([\\s-\\W]+)'; |
|
183 expect = ['- ', '- '] + ''; |
|
184 actual = null; |
|
185 |
|
186 try |
|
187 { |
|
188 actual = new RegExp(r).exec(s) + ''; |
|
189 } |
|
190 catch(ex) |
|
191 { |
|
192 actual = ex + ''; |
|
193 } |
|
194 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
195 |
|
196 r = '([\\w-\\S]+)'; |
|
197 expect = ['a0-', 'a0-'] + ''; |
|
198 actual = null; |
|
199 |
|
200 try |
|
201 { |
|
202 actual = new RegExp(r).exec(s) + ''; |
|
203 } |
|
204 catch(ex) |
|
205 { |
|
206 actual = ex + ''; |
|
207 } |
|
208 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
209 |
|
210 r = '([\\S-\\w]+)'; |
|
211 expect = ['a0-', 'a0-'] + ''; |
|
212 actual = null; |
|
213 |
|
214 try |
|
215 { |
|
216 actual = new RegExp(r).exec(s) + ''; |
|
217 } |
|
218 catch(ex) |
|
219 { |
|
220 actual = ex + ''; |
|
221 } |
|
222 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
223 |
|
224 r = '([\\W-\\S]+)'; |
|
225 expect = ['a0- z', 'a0- z'] + ''; |
|
226 actual = null; |
|
227 |
|
228 try |
|
229 { |
|
230 actual = new RegExp(r).exec(s) + ''; |
|
231 } |
|
232 catch(ex) |
|
233 { |
|
234 actual = ex + ''; |
|
235 } |
|
236 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
237 |
|
238 r = '([\\S-\\W]+)'; |
|
239 expect = ['a0- z', 'a0- z'] + ''; |
|
240 actual = null; |
|
241 |
|
242 try |
|
243 { |
|
244 actual = new RegExp(r).exec(s) + ''; |
|
245 } |
|
246 catch(ex) |
|
247 { |
|
248 actual = ex + ''; |
|
249 } |
|
250 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); |
|
251 |
|
252 |
|
253 exitFunc ('test'); |
|
254 } |