Skip to content

Commit da57213

Browse files
edsadritaloacasas
authored andcommitted
test: improve the code in test-process-hrtime
* use const instead of var * use assert.strictEqual instead of assert.equal and plain assert * use arrow functions * swap assertions arguments to match the standard * validate the error for assert.throws PR-URL: #10667 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michal Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 17d9a73 commit da57213

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/parallel/test-process-hrtime.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require('../common');
33
var assert = require('assert');
44

55
// the default behavior, return an Array "tuple" of numbers
6-
var tuple = process.hrtime();
6+
const tuple = process.hrtime();
77

88
// validate the default behavior
99
validateTuple(tuple);
@@ -12,16 +12,16 @@ validateTuple(tuple);
1212
validateTuple(process.hrtime(tuple));
1313

1414
// test that only an Array may be passed to process.hrtime()
15-
assert.throws(function() {
15+
assert.throws(() => {
1616
process.hrtime(1);
17-
});
17+
}, /^TypeError: process.hrtime\(\) only accepts an Array tuple$/);
1818

1919
function validateTuple(tuple) {
2020
assert(Array.isArray(tuple));
21-
assert.equal(2, tuple.length);
22-
tuple.forEach(function(v) {
23-
assert.equal('number', typeof v);
24-
assert(isFinite(v));
21+
assert.strictEqual(tuple.length, 2);
22+
tuple.forEach((v) => {
23+
assert.strictEqual(typeof v, 'number');
24+
assert.strictEqual(isFinite(v), true);
2525
});
2626
}
2727

0 commit comments

Comments
 (0)