Skip to content

Commit 76d70a6

Browse files
committed
test: add util.inspect breakLength regression
1 parent b1e941e commit 76d70a6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/parallel/test-util-inspect.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,25 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
589589
}), "[ 'foo', <1 empty item>, ... 99 more items ]");
590590
}
591591

592+
// `breakLength: Infinity` should force single-line output even if `depth` is
593+
// explicitly set to `Infinity`.
594+
{
595+
const tree = {};
596+
for (let i = 0; i < 5; i++) {
597+
const branch = tree[`field${i}`] = { leaves: {} };
598+
for (let j = 0; j < 5; j++) {
599+
branch.leaves[`leaf${j}`] = new Array(10).fill(`value-${i}-${j}`);
600+
}
601+
}
602+
603+
const options = { breakLength: Infinity, compact: 3 };
604+
const singleLine = util.inspect(tree, options);
605+
assert.strictEqual(singleLine.includes('\n'), false);
606+
607+
const deepOptions = { ...options, depth: Infinity };
608+
assert.strictEqual(util.inspect(tree, deepOptions).includes('\n'), false);
609+
}
610+
592611
// Test for Array constructor in different context.
593612
{
594613
const map = new Map();

0 commit comments

Comments
 (0)