Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve the code in test-process-hrtime #10667

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/parallel/test-process-hrtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('../common');
const assert = require('assert');

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

// validate the default behavior
validateTuple(tuple);
Expand All @@ -12,16 +12,16 @@ validateTuple(tuple);
validateTuple(process.hrtime(tuple));

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

function validateTuple(tuple) {
assert(Array.isArray(tuple));
assert.equal(2, tuple.length);
tuple.forEach(function(v) {
assert.equal('number', typeof v);
assert(isFinite(v));
assert.strictEqual(tuple.length, 2);
tuple.forEach((v) => {
assert.strictEqual(typeof v, 'number');
assert.strictEqual(isFinite(v), true);
});
}

Expand Down