Skip to content

Commit 9ada68b

Browse 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

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎benchmark/assert/throws.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

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

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

1616
functionmain({ n, method }){
17-
constthrows=()=>{thrownewTypeError('foobar');};
18-
constdoesNotThrow=()=>{return'foobar';};
17+
constthrowError=()=>{thrownewTypeError('foobar');};
18+
constdoNotThrowError=()=>{return'foobar';};
1919
constregExp=/foobar/;
2020
constmessage='failure';
2121
vari;
@@ -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)