Skip to content

Commit 178fe21

Browse files
Lxxyxtargos
authored andcommitted
test: increase coverage for Histogram
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 <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 56bf6c1 commit 178fe21

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/parallel/test-perf-hooks-histogram.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
createHistogram,
77
monitorEventLoopDelay,
88
} = require('perf_hooks');
9+
const { inspect } = require('util');
910

1011
{
1112
const h = createHistogram();
@@ -67,3 +68,18 @@ const {
6768
});
6869
setTimeout(() => mc.port2.postMessage(e), 100);
6970
}
71+
72+
{
73+
const h = createHistogram();
74+
assert(inspect(h, { depth: null }).startsWith('Histogram'));
75+
assert.strictEqual(inspect(h, { depth: -1 }), '[RecordableHistogram]');
76+
}
77+
78+
{
79+
// Tests that RecordableHistogram is impossible to construct manually
80+
const h = createHistogram();
81+
assert.throws(
82+
() => new h.constructor(),
83+
/^TypeError: illegal constructor$/
84+
);
85+
}

0 commit comments

Comments
 (0)