From 8879820a8f475feb6355c9d496d4481689ca7542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= <andre.bargull@gmail.com> Date: Fri, 17 Aug 2018 07:48:42 -0700 Subject: [PATCH] Make RegExp/CharacterClassEscapes tests faster across all engines --- harness/regExpUtils.js | 11 +++++---- ...racter-class-digit-class-escape-flags-u.js | 23 +++++++------------ ...it-class-escape-plus-quantifier-flags-u.js | 23 +++++++------------ ...lass-digit-class-escape-plus-quantifier.js | 23 +++++++------------ .../character-class-digit-class-escape.js | 23 +++++++------------ ...er-class-non-digit-class-escape-flags-u.js | 23 +++++++------------ ...it-class-escape-plus-quantifier-flags-u.js | 23 +++++++------------ ...-non-digit-class-escape-plus-quantifier.js | 23 +++++++------------ .../character-class-non-digit-class-escape.js | 23 +++++++------------ ...ass-non-whitespace-class-escape-flags-u.js | 23 +++++++------------ ...ce-class-escape-plus-quantifier-flags-u.js | 23 +++++++------------ ...whitespace-class-escape-plus-quantifier.js | 23 +++++++------------ ...acter-class-non-whitespace-class-escape.js | 23 +++++++------------ ...ter-class-non-word-class-escape-flags-u.js | 23 +++++++------------ ...rd-class-escape-plus-quantifier-flags-u.js | 23 +++++++------------ ...s-non-word-class-escape-plus-quantifier.js | 23 +++++++------------ .../character-class-non-word-class-escape.js | 23 +++++++------------ ...r-class-whitespace-class-escape-flags-u.js | 23 +++++++------------ ...ce-class-escape-plus-quantifier-flags-u.js | 23 +++++++------------ ...whitespace-class-escape-plus-quantifier.js | 23 +++++++------------ ...character-class-whitespace-class-escape.js | 23 +++++++------------ ...aracter-class-word-class-escape-flags-u.js | 23 +++++++------------ ...rd-class-escape-plus-quantifier-flags-u.js | 23 +++++++------------ ...class-word-class-escape-plus-quantifier.js | 23 +++++++------------ .../character-class-word-class-escape.js | 23 +++++++------------ 25 files changed, 199 insertions(+), 364 deletions(-) diff --git a/harness/regExpUtils.js b/harness/regExpUtils.js index 362a6d1660..2abfee3890 100644 --- a/harness/regExpUtils.js +++ b/harness/regExpUtils.js @@ -7,17 +7,20 @@ description: | function buildString({ loneCodePoints, ranges }) { const CHUNK_SIZE = 10000; - let result = String.fromCodePoint(...loneCodePoints); - for (const [start, end] of ranges) { + let result = Reflect.apply(String.fromCodePoint, null, loneCodePoints); + for (let i = 0; i < ranges.length; i++) { + const range = ranges[i]; + const start = range[0]; + const end = range[1]; const codePoints = []; for (let length = 0, codePoint = start; codePoint <= end; codePoint++) { codePoints[length++] = codePoint; if (length === CHUNK_SIZE) { - result += String.fromCodePoint(...codePoints); + result += Reflect.apply(String.fromCodePoint, null, codePoints); codePoints.length = length = 0; } } - result += String.fromCodePoint(...codePoints); + result += Reflect.apply(String.fromCodePoint, null, codePoints); } return result; } diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-flags-u.js index 652ef43764..068e805782 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\d/ug; const matchingRange = /[0-9]/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier-flags-u.js index 8683600954..b50ccca0c2 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\d+/ug; const matchingRange = /[0-9]+/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier.js index 20d6b38be5..9463332f41 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape-plus-quantifier.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\d+/g; const matchingRange = /[0-9]+/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape.js index d3aef45b72..1d1a24bbb2 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-digit-class-escape.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\d/g; const matchingRange = /[0-9]/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-flags-u.js index ead3d68d80..4728762a40 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\D/ug; const matchingRange = /[\0-\/:-\u{10FFFF}]/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier-flags-u.js index 5c02690bc2..726d595714 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\D+/ug; const matchingRange = /[\0-\/:-\u{10FFFF}]+/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier.js index 960d9cff64..56a61ec444 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape-plus-quantifier.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\D+/g; const matchingRange = /[\0-\/:-\uFFFF]+/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape.js index 85b1dcc5ea..4da365aeb7 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-digit-class-escape.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\D/g; const matchingRange = /[\0-\/:-\uFFFF]/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-flags-u.js index eda913b7a9..75f85b7ab4 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\S/ug; const matchingRange = /[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\u{10FFFF}]/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier-flags-u.js index 8e21a55ac5..ce20f50295 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\S+/ug; const matchingRange = /[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\u{10FFFF}]+/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier.js index f7cc4a3b65..95e37779a2 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape-plus-quantifier.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\S+/g; const matchingRange = /[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\uFFFF]+/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape.js index 3bca8ae499..7b6dc6a875 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-whitespace-class-escape.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\S/g; const matchingRange = /[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\uFFFF]/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-flags-u.js index 3da454aaa0..b1e689dafc 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\W/ug; const matchingRange = /[\0-\/:-@\[-\^`\{-\u{10FFFF}]/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier-flags-u.js index 7e7faad7f5..23e7c1fec2 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\W+/ug; const matchingRange = /[\0-\/:-@\[-\^`\{-\u{10FFFF}]+/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier.js index 41ffa539dd..412b05287c 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape-plus-quantifier.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\W+/g; const matchingRange = /[\0-\/:-@\[-\^`\{-\uFFFF]+/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape.js index ca476084fd..99051f994c 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-non-word-class-escape.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\W/g; const matchingRange = /[\0-\/:-@\[-\^`\{-\uFFFF]/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-flags-u.js index 82bb95029b..0cfd5f7daa 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\s/ug; const matchingRange = /[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier-flags-u.js index 7a3b57ddf6..fc3c1c28ea 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\s+/ug; const matchingRange = /[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier.js index e1084ff531..3f03f1a8eb 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape-plus-quantifier.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\s+/g; const matchingRange = /[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape.js index d1a3fdacd8..d31b85699b 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-whitespace-class-escape.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\s/g; const matchingRange = /[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-flags-u.js index 0b8b183b35..d7406fe450 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\w/ug; const matchingRange = /[0-9A-Z_a-z]/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier-flags-u.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier-flags-u.js index d82442617a..10978d7b93 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier-flags-u.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier-flags-u.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0x10ffff / 0x10000); - -for (let codePoint = 0; codePoint < 0x10FFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0x10FFFF]]}); const re = /\w+/ug; const matchingRange = /[0-9A-Z_a-z]+/ug; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier.js index bafffd776f..82884b7333 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape-plus-quantifier.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\w+/g; const matchingRange = /[0-9A-Z_a-z]+/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, diff --git a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape.js b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape.js index cba30b0692..d5f87b9e69 100644 --- a/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape.js +++ b/test/built-ins/RegExp/CharacterClassEscapes/character-class-word-class-escape.js @@ -33,15 +33,10 @@ info: | The production CharacterClassEscape :: W evaluates as follows: Return the set of all characters not included in the set returned by CharacterClassEscape :: w. features: [String.fromCodePoint] +includes: [regExpUtils.js] ---*/ -const chunks = []; -const totalChunks = Math.ceil(0xffff / 0x10000); - -for (let codePoint = 0; codePoint < 0xFFFF; codePoint++) { - // split strings to avoid a super long one; - chunks[codePoint % totalChunks] += String.fromCodePoint(codePoint); -} +const str = buildString({loneCodePoints: [], ranges: [[0, 0xFFFF]]}); const re = /\w/g; const matchingRange = /[0-9A-Z_a-z]/g; @@ -52,16 +47,14 @@ function matching(str) { return str.replace(re, '') === str.replace(matchingRange, ''); } -for (const str of chunks) { - if (!matching(str)) { - // Error, let's find out where - for (const char of str) { - if (!matching(char)) { - errors.push('0x' + char.codePointAt(0).toString(16)); - } +if (!matching(str)) { + // Error, let's find out where + for (const char of str) { + if (!matching(char)) { + errors.push('0x' + char.codePointAt(0).toString(16)); } } -}; +} assert.sameValue( errors.length, -- GitLab