diff --git a/test/parallel/test-perf-hooks-histogram.js b/test/parallel/test-perf-hooks-histogram.js index f8c373bbd4c4b9..323dbeb153633a 100644 --- a/test/parallel/test-perf-hooks-histogram.js +++ b/test/parallel/test-perf-hooks-histogram.js @@ -6,6 +6,7 @@ const { createHistogram, monitorEventLoopDelay, } = require('perf_hooks'); +const { inspect } = require('util'); { const h = createHistogram(); @@ -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$/ + ); +}