Skip to content

Commit

Permalink
test: increase coverage for Histogram
Browse files Browse the repository at this point in the history
1. custom inspect test case
Refs: https://coverage.nodejs.org/coverage-18e4f405b14b26f9/lib/internal/histogram.js.html#L56

2. tests that RecordableHistogram is impossible to construct manually
Refs: https://coverage.nodejs.org/coverage-18e4f405b14b26f9/lib/internal/histogram.js.html#L132

PR-URL: #38555
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
Lxxyx authored and targos committed May 17, 2021
1 parent 56bf6c1 commit 178fe21
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/parallel/test-perf-hooks-histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
createHistogram,
monitorEventLoopDelay,
} = require('perf_hooks');
const { inspect } = require('util');

{
const h = createHistogram();
Expand Down Expand Up @@ -67,3 +68,18 @@ const {
});
setTimeout(() => mc.port2.postMessage(e), 100);
}

{
const h = createHistogram();
assert(inspect(h, { depth: null }).startsWith('Histogram'));
assert.strictEqual(inspect(h, { depth: -1 }), '[RecordableHistogram]');
}

{
// Tests that RecordableHistogram is impossible to construct manually
const h = createHistogram();
assert.throws(
() => new h.constructor(),
/^TypeError: illegal constructor$/
);
}

0 comments on commit 178fe21

Please sign in to comment.