Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45e7b10

Browse filesBrowse files
tniessenRafaelGSS
authored andcommitted
test: fix 'checks' validation test for checkPrime
This test had two problems: * The first argument was a number in both cases, which is what caused the (expected) ERR_INVALID_ARG_TYPE error -- the validity of the 'checks' option was not actually verified at all. Thus, the first argument should be valid for this particular test. * The function returned by common.mustNotCall() was passed to assert.throws() as a third argument instead of being passed to checkPrime() as a third argument. (Isn't JavaScript great?) This again led to the (expected) ERR_INVALID_ARG_TYPE error, but again, the validity of the 'checks' option was not verified. Fix both issues by ensuring that all arguments except the 'checks' option are valid. Refs: #36997 PR-URL: #47139 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 5749dfa commit 45e7b10
Copy full SHA for 45e7b10

File tree

Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-crypto-prime.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-prime.js
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,16 @@ generatePrime(
229229
});
230230
});
231231

232-
['hello', {}, []].forEach((i) => {
233-
assert.throws(() => checkPrime(2, { checks: i }), {
234-
code: 'ERR_INVALID_ARG_TYPE'
235-
}, common.mustNotCall());
236-
assert.throws(() => checkPrimeSync(2, { checks: i }), {
237-
code: 'ERR_INVALID_ARG_TYPE'
232+
for (const checks of ['hello', {}, []]) {
233+
assert.throws(() => checkPrime(2n, { checks }, common.mustNotCall()), {
234+
code: 'ERR_INVALID_ARG_TYPE',
235+
message: /checks/
238236
});
239-
});
237+
assert.throws(() => checkPrimeSync(2n, { checks }), {
238+
code: 'ERR_INVALID_ARG_TYPE',
239+
message: /checks/
240+
});
241+
}
240242

241243
assert(!checkPrimeSync(Buffer.from([0x1])));
242244
assert(checkPrimeSync(Buffer.from([0x2])));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.