Skip to content
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
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
  • Loading branch information
emilsivervik committed Jan 6, 2021
commit 9e907b996b6f4a2a2c0e28478a79e2357f4bce2d
17 changes: 17 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ assert(!/Object/.test(
'ArrayBuffer { (detached), byteLength: 0 }');
}

// Truncate output for ArrayBuffers using plural or singular bytes
{
const ab = new ArrayBuffer(3);
assert.strictEqual(util.inspect(ab, { showHidden: true, maxArrayLength: 2 }),
'ArrayBuffer { [Uint8Contents]' +
': <00 00 ... 1 more byte>, byteLength: 3 }');
assert.strictEqual(util.inspect(ab, { showHidden: true, maxArrayLength: 1 }),
'ArrayBuffer { [Uint8Contents]' +
': <00 ... 2 more bytes>, byteLength: 3 }');
}

// Now do the same checks but from a different context.
{
const showHidden = false;
Expand Down Expand Up @@ -2915,6 +2926,12 @@ assert.strictEqual(
assert.strictEqual(inspect(undetectable), '{}');
}

// Truncate output for Primitives with 1 character left
{
assert.strictEqual(util.inspect('bl', { maxStringLength: 1 }),
"'b'... 1 more character");
}

{
const x = 'a'.repeat(1e6);
assert(util.inspect(x).endsWith('... 990000 more characters'));
Expand Down