Skip to content

Commit 1bc0ade

Browse files
committed
Fix ECMA 262 regex whitespace tests.
Looks like there was a bug at the time of introduction due to #285 Per ECMA 262 specification: https://www.ecma-international.org/ecma-262/10.0/index.html#sec-characterclassescape `\S` refers to `\s`: > # Section 21.2.2.12: > The production `CharacterClassEscape::S` evaluates as follows: > 1. Return the set of all characters not included in the set returned > by `CharacterClassEscape::s`. `\s` refers to `WhiteSpace`: > The production `CharacterClassEscape::s` evaluates as follows: > 1. Return the set of characters containing the characters that are on > the right-hand side of the WhiteSpace or LineTerminator > productions. `WhiteSpace` includes NBSP (**U00A0**): https://www.ecma-international.org/ecma-262/10.0/index.html#prod-WhiteSpace That is the exact opposite of what the current test was checking for. Also, `WhiteSpace` includes any other Unicode "Space_Separator" code points. That's not a new addition, same was true in version 6.0: * https://www.ecma-international.org/ecma-262/6.0/index.html#sec-characterclassescape * https://www.ecma-international.org/ecma-262/6.0/index.html#sec-white-space
1 parent 536ec07 commit 1bc0ade

File tree

4 files changed

+377
-17
lines changed

4 files changed

+377
-17
lines changed

tests/draft2019-09/optional/format/ecmascript-regex.json

+94-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
]
174174
},
175175
{
176-
"description": "ECMA 262 \\s matches ascii whitespace only",
176+
"description": "ECMA 262 \\s matches whitespace",
177177
"schema": {
178178
"type": "string",
179179
"pattern": "^\\s$"
@@ -185,14 +185,59 @@
185185
"valid": true
186186
},
187187
{
188-
"description": "latin-1 non-breaking-space does not match (unlike e.g. Python)",
188+
"description": "Character tabulation matches",
189+
"data": "\t",
190+
"valid": true
191+
},
192+
{
193+
"description": "Line tabulation matches",
194+
"data": "\u000b",
195+
"valid": true
196+
},
197+
{
198+
"description": "Form feed matches",
199+
"data": "\u000c",
200+
"valid": true
201+
},
202+
{
203+
"description": "latin-1 non-breaking-space matches",
189204
"data": "\u00a0",
205+
"valid": true
206+
},
207+
{
208+
"description": "zero-width whitespace matches",
209+
"data": "\ufeff",
210+
"valid": true
211+
},
212+
{
213+
"description": "line feed matches (line terminator)",
214+
"data": "\u000a",
215+
"valid": true
216+
},
217+
{
218+
"description": "paragraph separator matches (line terminator)",
219+
"data": "\u2029",
220+
"valid": true
221+
},
222+
{
223+
"description": "EM SPACE matches (Space_Separator)",
224+
"data": "\u2003",
225+
"valid": true
226+
},
227+
{
228+
"description": "Non-whitespace control does not match",
229+
"data": "\u0001",
230+
"valid": false
231+
},
232+
{
233+
"description": "Non-whitespace does not match",
234+
"data": "\u2013",
190235
"valid": false
191236
}
192237
]
193238
},
194239
{
195-
"description": "ECMA 262 \\S matches everything but ascii whitespace",
240+
"description": "ECMA 262 \\S matches everything but whitespace",
196241
"schema": {
197242
"type": "string",
198243
"pattern": "^\\S$"
@@ -204,8 +249,53 @@
204249
"valid": false
205250
},
206251
{
207-
"description": "latin-1 non-breaking-space matches (unlike e.g. Python)",
252+
"description": "Character tabulation does not match",
253+
"data": "\t",
254+
"valid": false
255+
},
256+
{
257+
"description": "Line tabulation does not match",
258+
"data": "\u000b",
259+
"valid": false
260+
},
261+
{
262+
"description": "Form feed does not match",
263+
"data": "\u000c",
264+
"valid": false
265+
},
266+
{
267+
"description": "latin-1 non-breaking-space does not match",
208268
"data": "\u00a0",
269+
"valid": false
270+
},
271+
{
272+
"description": "zero-width whitespace does not match",
273+
"data": "\ufeff",
274+
"valid": false
275+
},
276+
{
277+
"description": "line feed does not match (line terminator)",
278+
"data": "\u000a",
279+
"valid": false
280+
},
281+
{
282+
"description": "paragraph separator does not match (line terminator)",
283+
"data": "\u2029",
284+
"valid": false
285+
},
286+
{
287+
"description": "EM SPACE does not match (Space_Separator)",
288+
"data": "\u2003",
289+
"valid": false
290+
},
291+
{
292+
"description": "Non-whitespace control matches",
293+
"data": "\u0001",
294+
"valid": true
295+
},
296+
{
297+
"description": "Non-whitespace matches",
298+
"data": "\u2013",
209299
"valid": true
210300
}
211301
]

tests/draft4/optional/ecmascript-regex.json

+94-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
]
174174
},
175175
{
176-
"description": "ECMA 262 \\s matches ascii whitespace only",
176+
"description": "ECMA 262 \\s matches whitespace",
177177
"schema": {
178178
"type": "string",
179179
"pattern": "^\\s$"
@@ -185,14 +185,59 @@
185185
"valid": true
186186
},
187187
{
188-
"description": "latin-1 non-breaking-space does not match (unlike e.g. Python)",
188+
"description": "Character tabulation matches",
189+
"data": "\t",
190+
"valid": true
191+
},
192+
{
193+
"description": "Line tabulation matches",
194+
"data": "\u000b",
195+
"valid": true
196+
},
197+
{
198+
"description": "Form feed matches",
199+
"data": "\u000c",
200+
"valid": true
201+
},
202+
{
203+
"description": "latin-1 non-breaking-space matches",
189204
"data": "\u00a0",
205+
"valid": true
206+
},
207+
{
208+
"description": "zero-width whitespace matches",
209+
"data": "\ufeff",
210+
"valid": true
211+
},
212+
{
213+
"description": "line feed matches (line terminator)",
214+
"data": "\u000a",
215+
"valid": true
216+
},
217+
{
218+
"description": "paragraph separator matches (line terminator)",
219+
"data": "\u2029",
220+
"valid": true
221+
},
222+
{
223+
"description": "EM SPACE matches (Space_Separator)",
224+
"data": "\u2003",
225+
"valid": true
226+
},
227+
{
228+
"description": "Non-whitespace control does not match",
229+
"data": "\u0001",
230+
"valid": false
231+
},
232+
{
233+
"description": "Non-whitespace does not match",
234+
"data": "\u2013",
190235
"valid": false
191236
}
192237
]
193238
},
194239
{
195-
"description": "ECMA 262 \\S matches everything but ascii whitespace",
240+
"description": "ECMA 262 \\S matches everything but whitespace",
196241
"schema": {
197242
"type": "string",
198243
"pattern": "^\\S$"
@@ -204,8 +249,53 @@
204249
"valid": false
205250
},
206251
{
207-
"description": "latin-1 non-breaking-space matches (unlike e.g. Python)",
252+
"description": "Character tabulation does not match",
253+
"data": "\t",
254+
"valid": false
255+
},
256+
{
257+
"description": "Line tabulation does not match",
258+
"data": "\u000b",
259+
"valid": false
260+
},
261+
{
262+
"description": "Form feed does not match",
263+
"data": "\u000c",
264+
"valid": false
265+
},
266+
{
267+
"description": "latin-1 non-breaking-space does not match",
208268
"data": "\u00a0",
269+
"valid": false
270+
},
271+
{
272+
"description": "zero-width whitespace does not match",
273+
"data": "\ufeff",
274+
"valid": false
275+
},
276+
{
277+
"description": "line feed does not match (line terminator)",
278+
"data": "\u000a",
279+
"valid": false
280+
},
281+
{
282+
"description": "paragraph separator does not match (line terminator)",
283+
"data": "\u2029",
284+
"valid": false
285+
},
286+
{
287+
"description": "EM SPACE does not match (Space_Separator)",
288+
"data": "\u2003",
289+
"valid": false
290+
},
291+
{
292+
"description": "Non-whitespace control matches",
293+
"data": "\u0001",
294+
"valid": true
295+
},
296+
{
297+
"description": "Non-whitespace matches",
298+
"data": "\u2013",
209299
"valid": true
210300
}
211301
]

tests/draft6/optional/ecmascript-regex.json

+94-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
]
174174
},
175175
{
176-
"description": "ECMA 262 \\s matches ascii whitespace only",
176+
"description": "ECMA 262 \\s matches whitespace",
177177
"schema": {
178178
"type": "string",
179179
"pattern": "^\\s$"
@@ -185,14 +185,59 @@
185185
"valid": true
186186
},
187187
{
188-
"description": "latin-1 non-breaking-space does not match (unlike e.g. Python)",
188+
"description": "Character tabulation matches",
189+
"data": "\t",
190+
"valid": true
191+
},
192+
{
193+
"description": "Line tabulation matches",
194+
"data": "\u000b",
195+
"valid": true
196+
},
197+
{
198+
"description": "Form feed matches",
199+
"data": "\u000c",
200+
"valid": true
201+
},
202+
{
203+
"description": "latin-1 non-breaking-space matches",
189204
"data": "\u00a0",
205+
"valid": true
206+
},
207+
{
208+
"description": "zero-width whitespace matches",
209+
"data": "\ufeff",
210+
"valid": true
211+
},
212+
{
213+
"description": "line feed matches (line terminator)",
214+
"data": "\u000a",
215+
"valid": true
216+
},
217+
{
218+
"description": "paragraph separator matches (line terminator)",
219+
"data": "\u2029",
220+
"valid": true
221+
},
222+
{
223+
"description": "EM SPACE matches (Space_Separator)",
224+
"data": "\u2003",
225+
"valid": true
226+
},
227+
{
228+
"description": "Non-whitespace control does not match",
229+
"data": "\u0001",
230+
"valid": false
231+
},
232+
{
233+
"description": "Non-whitespace does not match",
234+
"data": "\u2013",
190235
"valid": false
191236
}
192237
]
193238
},
194239
{
195-
"description": "ECMA 262 \\S matches everything but ascii whitespace",
240+
"description": "ECMA 262 \\S matches everything but whitespace",
196241
"schema": {
197242
"type": "string",
198243
"pattern": "^\\S$"
@@ -204,8 +249,53 @@
204249
"valid": false
205250
},
206251
{
207-
"description": "latin-1 non-breaking-space matches (unlike e.g. Python)",
252+
"description": "Character tabulation does not match",
253+
"data": "\t",
254+
"valid": false
255+
},
256+
{
257+
"description": "Line tabulation does not match",
258+
"data": "\u000b",
259+
"valid": false
260+
},
261+
{
262+
"description": "Form feed does not match",
263+
"data": "\u000c",
264+
"valid": false
265+
},
266+
{
267+
"description": "latin-1 non-breaking-space does not match",
208268
"data": "\u00a0",
269+
"valid": false
270+
},
271+
{
272+
"description": "zero-width whitespace does not match",
273+
"data": "\ufeff",
274+
"valid": false
275+
},
276+
{
277+
"description": "line feed does not match (line terminator)",
278+
"data": "\u000a",
279+
"valid": false
280+
},
281+
{
282+
"description": "paragraph separator does not match (line terminator)",
283+
"data": "\u2029",
284+
"valid": false
285+
},
286+
{
287+
"description": "EM SPACE does not match (Space_Separator)",
288+
"data": "\u2003",
289+
"valid": false
290+
},
291+
{
292+
"description": "Non-whitespace control matches",
293+
"data": "\u0001",
294+
"valid": true
295+
},
296+
{
297+
"description": "Non-whitespace matches",
298+
"data": "\u2013",
209299
"valid": true
210300
}
211301
]

0 commit comments

Comments
 (0)