mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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: https://github.com/nodejs/node/pull/36755 Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
1 parent
10da5c1104
commit
db38cf27c2
1 file changed
+17
@@ -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;
|
||||
@@ -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'));
|
||||
|
||||
Reference in new issue
Block a user