Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use const in for (of) loops so harness code can be used in environments that don't support that #4163

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions harness/regExpUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ function buildString(args) {
const loneCodePoints = args.loneCodePoints;
const ranges = args.ranges;
const CHUNK_SIZE = 10000;
let result = Reflect.apply(String.fromCodePoint, null, loneCodePoints);
let result = String.fromCodePoint.apply(null, loneCodePoints);
for (let i = 0; i < ranges.length; i++) {
const range = ranges[i];
const start = range[0];
const end = range[1];
const codePoints = [];
let range = ranges[i];
let start = range[0];
let end = range[1];
let codePoints = [];
for (let length = 0, codePoint = start; codePoint <= end; codePoint++) {
codePoints[length++] = codePoint;
if (length === CHUNK_SIZE) {
result += Reflect.apply(String.fromCodePoint, null, codePoints);
result += String.fromCodePoint.apply(null, codePoints);
codePoints.length = length = 0;
}
}
result += Reflect.apply(String.fromCodePoint, null, codePoints);
result += String.fromCodePoint.apply(null, codePoints);
}
return result;
}
Expand All @@ -41,17 +41,17 @@ function printCodePoint(codePoint) {

function printStringCodePoints(string) {
const buf = [];
for (const symbol of string) {
const formatted = printCodePoint(symbol.codePointAt(0));
for (let symbol of string) {
let formatted = printCodePoint(symbol.codePointAt(0));
buf.push(formatted);
}
return buf.join(' ');
}

function testPropertyEscapes(regExp, string, expression) {
if (!regExp.test(string)) {
for (const symbol of string) {
const formatted = printCodePoint(symbol.codePointAt(0));
for (let symbol of string) {
let formatted = printCodePoint(symbol.codePointAt(0));
assert(
regExp.test(symbol),
`\`${ expression }\` should match ${ formatted } (\`${ symbol }\`)`
Expand All @@ -70,7 +70,7 @@ function testPropertyOfStrings(args) {
const nonMatchStrings = args.nonMatchStrings;
const allStrings = matchStrings.join('');
if (!regExp.test(allStrings)) {
for (const string of matchStrings) {
for (let string of matchStrings) {
assert(
regExp.test(string),
`\`${ expression }\` should match ${ string } (${ printStringCodePoints(string) })`
Expand All @@ -82,7 +82,7 @@ function testPropertyOfStrings(args) {

const allNonMatchStrings = nonMatchStrings.join('');
if (regExp.test(allNonMatchStrings)) {
for (const string of nonMatchStrings) {
for (let string of nonMatchStrings) {
assert(
!regExp.test(string),
`\`${ expression }\` should not match ${ string } (${ printStringCodePoints(string) })`
Expand Down
Loading