Skip to content

Commit db38cf2

Browse files
emilsiverviktargos
authored andcommitted
test: increase inspect coverage
1. Truncate output for Primitives with 1 character left Refs: https://coverage.nodejs.org/coverage-0b6d3070a176d437/lib/internal/util/inspect.js.html#L1359 2. Truncate output for ArrayBuffers using plural or singular bytes Refs: https://coverage.nodejs.org/coverage-0b6d3070a176d437/lib/internal/util/inspect.js.html#L1465 PR-URL: #36755 Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 10da5c1 commit db38cf2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/parallel/test-util-inspect.js

+17
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ assert(!/Object/.test(
210210
'ArrayBuffer { (detached), byteLength: 0 }');
211211
}
212212

213+
// Truncate output for ArrayBuffers using plural or singular bytes
214+
{
215+
const ab = new ArrayBuffer(3);
216+
assert.strictEqual(util.inspect(ab, { showHidden: true, maxArrayLength: 2 }),
217+
'ArrayBuffer { [Uint8Contents]' +
218+
': <00 00 ... 1 more byte>, byteLength: 3 }');
219+
assert.strictEqual(util.inspect(ab, { showHidden: true, maxArrayLength: 1 }),
220+
'ArrayBuffer { [Uint8Contents]' +
221+
': <00 ... 2 more bytes>, byteLength: 3 }');
222+
}
223+
213224
// Now do the same checks but from a different context.
214225
{
215226
const showHidden = false;
@@ -2915,6 +2926,12 @@ assert.strictEqual(
29152926
assert.strictEqual(inspect(undetectable), '{}');
29162927
}
29172928

2929+
// Truncate output for Primitives with 1 character left
2930+
{
2931+
assert.strictEqual(util.inspect('bl', { maxStringLength: 1 }),
2932+
"'b'... 1 more character");
2933+
}
2934+
29182935
{
29192936
const x = 'a'.repeat(1e6);
29202937
assert(util.inspect(x).endsWith('... 990000 more characters'));

0 commit comments

Comments
 (0)