From f86e5fc4370fb21c39109bcf388e0f25963b1832 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 30 May 2018 04:03:52 +0000 Subject: [PATCH] benchmark: refactor benchmark/assert/throws.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a minor refactor of benchmark/assert/throws.js to reduce exceptions that need to be made for lint compliance. PR-URL: https://github.com/nodejs/node/pull/21030 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- benchmark/assert/throws.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/benchmark/assert/throws.js b/benchmark/assert/throws.js index 2409d19206e353..a8a7bd4509e1ca 100644 --- a/benchmark/assert/throws.js +++ b/benchmark/assert/throws.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common.js'); -const assert = require('assert'); +const { throws, doesNotThrow } = require('assert'); const bench = common.createBenchmark(main, { n: [1e6], @@ -14,8 +14,8 @@ const bench = common.createBenchmark(main, { }); function main({ n, method }) { - const throws = () => { throw new TypeError('foobar'); }; - const doesNotThrow = () => { return 'foobar'; }; + const throwError = () => { throw new TypeError('foobar'); }; + const doNotThrowError = () => { return 'foobar'; }; const regExp = /foobar/; const message = 'failure'; var i; @@ -26,30 +26,28 @@ function main({ n, method }) { case 'doesNotThrow': bench.start(); for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-syntax - assert.doesNotThrow(doesNotThrow); + doesNotThrow(doNotThrowError); } bench.end(n); break; case 'throws': bench.start(); for (i = 0; i < n; ++i) { - // eslint-disable-next-line no-restricted-syntax - assert.throws(throws); + throws(throwError); } bench.end(n); break; case 'throws_TypeError': bench.start(); for (i = 0; i < n; ++i) { - assert.throws(throws, TypeError, message); + throws(throwError, TypeError, message); } bench.end(n); break; case 'throws_RegExp': bench.start(); for (i = 0; i < n; ++i) { - assert.throws(throws, regExp, message); + throws(throwError, regExp, message); } bench.end(n); break;