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 9ada68b

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
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: #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>
1 parent b8470b9 commit 9ada68b
Copy full SHA for 9ada68b

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎benchmark/assert/throws.js‎

Copy file name to clipboardExpand all lines: benchmark/assert/throws.js
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const assert = require('assert');
4+
const { throws, doesNotThrow } = require('assert');
55

66
const bench = common.createBenchmark(main, {
77
n: [1e6],
@@ -14,8 +14,8 @@ const bench = common.createBenchmark(main, {
1414
});
1515

1616
function main({ n, method }) {
17-
const throws = () => { throw new TypeError('foobar'); };
18-
const doesNotThrow = () => { return 'foobar'; };
17+
const throwError = () => { throw new TypeError('foobar'); };
18+
const doNotThrowError = () => { return 'foobar'; };
1919
const regExp = /foobar/;
2020
const message = 'failure';
2121
var i;
@@ -26,30 +26,28 @@ function main({ n, method }) {
2626
case 'doesNotThrow':
2727
bench.start();
2828
for (i = 0; i < n; ++i) {
29-
// eslint-disable-next-line no-restricted-syntax
30-
assert.doesNotThrow(doesNotThrow);
29+
doesNotThrow(doNotThrowError);
3130
}
3231
bench.end(n);
3332
break;
3433
case 'throws':
3534
bench.start();
3635
for (i = 0; i < n; ++i) {
37-
// eslint-disable-next-line no-restricted-syntax
38-
assert.throws(throws);
36+
throws(throwError);
3937
}
4038
bench.end(n);
4139
break;
4240
case 'throws_TypeError':
4341
bench.start();
4442
for (i = 0; i < n; ++i) {
45-
assert.throws(throws, TypeError, message);
43+
throws(throwError, TypeError, message);
4644
}
4745
bench.end(n);
4846
break;
4947
case 'throws_RegExp':
5048
bench.start();
5149
for (i = 0; i < n; ++i) {
52-
assert.throws(throws, regExp, message);
50+
throws(throwError, regExp, message);
5351
}
5452
bench.end(n);
5553
break;

0 commit comments

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