Skip to content

Commit

Permalink
test: replace forEach with for...of
Browse files Browse the repository at this point in the history
Replace `Array.prototype.forEach()` with `for...of` in
`test/parallel/test-fs-readv-sync.js` and
`test/parallel/test-fs-readv.js`.

PR-URL: #50787
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
  • Loading branch information
Ospite Privilegiato authored and richardlau committed Mar 25, 2024
1 parent e9080a9 commit a98102a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions test/parallel/test-fs-readv-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ const wrongInputs = [false, 'test', {}, [{}], ['sdf'], null, undefined];
{
const fd = fs.openSync(filename, 'r');

wrongInputs.forEach((wrongInput) => {
for (const wrongInput of wrongInputs) {
assert.throws(
() => fs.readvSync(fd, wrongInput, null), {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
}
);
});
}

fs.closeSync(fd);
}

{
// fs.readv with wrong fd argument
wrongInputs.forEach((wrongInput) => {
for (const wrongInput of wrongInputs) {
assert.throws(
() => fs.readvSync(wrongInput),
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
}
);
});
}
}
9 changes: 4 additions & 5 deletions test/parallel/test-fs-readv.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,27 @@ const wrongInputs = [false, 'test', {}, [{}], ['sdf'], null, undefined];
fs.writeFileSync(filename, exptectedBuff);
const fd = fs.openSync(filename, 'r');


wrongInputs.forEach((wrongInput) => {
for (const wrongInput of wrongInputs) {
assert.throws(
() => fs.readv(fd, wrongInput, null, common.mustNotCall()), {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
}
);
});
}

fs.closeSync(fd);
}

{
// fs.readv with wrong fd argument
wrongInputs.forEach((wrongInput) => {
for (const wrongInput of wrongInputs) {
assert.throws(
() => fs.readv(wrongInput, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
}
);
});
}
}

0 comments on commit a98102a

Please sign in to comment.