summaryrefslogtreecommitdiff
path: root/benchmark/assert
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2018-05-30 04:03:52 +0000
committerRich Trott <rtrott@gmail.com>2018-06-02 05:17:29 +0200
commitf86e5fc4370fb21c39109bcf388e0f25963b1832 (patch)
tree8e322618ce331b06e2f92d30077bd65b463d1020 /benchmark/assert
parentb8f8ca570243bb58337e547f7bf10515cfab0ea5 (diff)
downloadandroid-node-v8-f86e5fc4370fb21c39109bcf388e0f25963b1832.tar.gz
android-node-v8-f86e5fc4370fb21c39109bcf388e0f25963b1832.tar.bz2
android-node-v8-f86e5fc4370fb21c39109bcf388e0f25963b1832.zip
benchmark: refactor benchmark/assert/throws.js
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 <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'benchmark/assert')
-rw-r--r--benchmark/assert/throws.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/benchmark/assert/throws.js b/benchmark/assert/throws.js
index 2409d19206..a8a7bd4509 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;