From 9243b9dc518d9ba20288ea0b54a00fb0baa8bfc4 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Wed, 11 Jan 2017 22:14:36 -0500 Subject: [PATCH] test: validate errors in test-buffer-indexof * validate errors in assert.throws * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10752 Backport-PR-URL: https://github.com/nodejs/node/pull/13785 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/parallel/test-buffer-indexof.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js index f4eba91b8abded..977d44ba3d8f05 100644 --- a/test/parallel/test-buffer-indexof.js +++ b/test/parallel/test-buffer-indexof.js @@ -346,15 +346,20 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1); } } -assert.throws(function() { - b.indexOf(function() { }); -}); -assert.throws(function() { +const argumentExpected = + /^TypeError: "val" argument must be string, number or Buffer$/; + +assert.throws(() => { + b.indexOf(() => { }); +}, argumentExpected); + +assert.throws(() => { b.indexOf({}); -}); -assert.throws(function() { +}, argumentExpected); + +assert.throws(() => { b.indexOf([]); -}); +}, argumentExpected); // Test weird offset arguments. // The following offsets coerce to NaN or 0, searching the whole Buffer