From cf719152b01a68bc65f80842799b4c6be0299d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 29 Nov 2016 20:35:30 +0100 Subject: [PATCH] test: refactor test-crypto-timing-safe-equal Add RegExp arguments to throws assertions. PR-URL: https://github.com/nodejs/node/pull/9843 Reviewed-By: Rich Trott Reviewed-By: Teddy Katz Reviewed-By: Luigi Pinca --- test/sequential/test-crypto-timing-safe-equal.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-crypto-timing-safe-equal.js b/test/sequential/test-crypto-timing-safe-equal.js index 6e15a577188cc3..9c4265a672cc0f 100644 --- a/test/sequential/test-crypto-timing-safe-equal.js +++ b/test/sequential/test-crypto-timing-safe-equal.js @@ -23,12 +23,15 @@ assert.strictEqual( assert.throws(function() { crypto.timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2])); -}, 'should throw when given buffers with different lengths'); +}, /^TypeError: Input buffers must have the same length$/, + 'should throw when given buffers with different lengths'); assert.throws(function() { crypto.timingSafeEqual('not a buffer', Buffer.from([1, 2])); -}, 'should throw if the first argument is not a buffer'); +}, /^TypeError: First argument must be a buffer$/, + 'should throw if the first argument is not a buffer'); assert.throws(function() { crypto.timingSafeEqual(Buffer.from([1, 2]), 'not a buffer'); -}, 'should throw if the second argument is not a buffer'); +}, /^TypeError: Second argument must be a buffer$/, + 'should throw if the second argument is not a buffer');