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 807e99b

Browse filesBrowse files
edsadrItalo A. Casas
authored andcommitted
test: validate errors in test-buffer-indexof
* validate errors in assert.throws * use arrow functions PR-URL: #10752 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 32da59a commit 807e99b
Copy full SHA for 807e99b

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎test/parallel/test-buffer-indexof.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-indexof.js
+12-7Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,20 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
337337
}
338338
}
339339

340-
assert.throws(function() {
341-
b.indexOf(function() { });
342-
});
343-
assert.throws(function() {
340+
const argumentExpected =
341+
/^TypeError: "val" argument must be string, number or Buffer$/;
342+
343+
assert.throws(() => {
344+
b.indexOf(() => { });
345+
}, argumentExpected);
346+
347+
assert.throws(() => {
344348
b.indexOf({});
345-
});
346-
assert.throws(function() {
349+
}, argumentExpected);
350+
351+
assert.throws(() => {
347352
b.indexOf([]);
348-
});
353+
}, argumentExpected);
349354

350355
// All code for handling encodings is shared between Buffer.indexOf and
351356
// Buffer.lastIndexOf, so only testing the separate lastIndexOf semantics.

0 commit comments

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