|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | const common = require('../common.js'); |
4 | | -const assert = require('assert'); |
| 4 | +const { throws, doesNotThrow } = require('assert'); |
5 | 5 |
|
6 | 6 | const bench = common.createBenchmark(main, { |
7 | 7 | n: [1e6], |
@@ -14,8 +14,8 @@ const bench = common.createBenchmark(main, { |
14 | 14 | }); |
15 | 15 |
|
16 | 16 | 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'; }; |
19 | 19 | const regExp = /foobar/; |
20 | 20 | const message = 'failure'; |
21 | 21 | var i; |
@@ -26,30 +26,28 @@ function main({ n, method }) { |
26 | 26 | case 'doesNotThrow': |
27 | 27 | bench.start(); |
28 | 28 | for (i = 0; i < n; ++i) { |
29 | | - // eslint-disable-next-line no-restricted-syntax |
30 | | - assert.doesNotThrow(doesNotThrow); |
| 29 | + doesNotThrow(doNotThrowError); |
31 | 30 | } |
32 | 31 | bench.end(n); |
33 | 32 | break; |
34 | 33 | case 'throws': |
35 | 34 | bench.start(); |
36 | 35 | for (i = 0; i < n; ++i) { |
37 | | - // eslint-disable-next-line no-restricted-syntax |
38 | | - assert.throws(throws); |
| 36 | + throws(throwError); |
39 | 37 | } |
40 | 38 | bench.end(n); |
41 | 39 | break; |
42 | 40 | case 'throws_TypeError': |
43 | 41 | bench.start(); |
44 | 42 | for (i = 0; i < n; ++i) { |
45 | | - assert.throws(throws, TypeError, message); |
| 43 | + throws(throwError, TypeError, message); |
46 | 44 | } |
47 | 45 | bench.end(n); |
48 | 46 | break; |
49 | 47 | case 'throws_RegExp': |
50 | 48 | bench.start(); |
51 | 49 | for (i = 0; i < n; ++i) { |
52 | | - assert.throws(throws, regExp, message); |
| 50 | + throws(throwError, regExp, message); |
53 | 51 | } |
54 | 52 | bench.end(n); |
55 | 53 | break; |
|