Skip to content

Commit a683626

Browse files
committed
fixup! util: add depth 2 test cases
See #60684 (comment)
1 parent 83db54c commit a683626

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

test/parallel/test-util-inspect.js

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,36 +2642,50 @@ assert.strictEqual(
26422642
const thrower = Object.defineProperty({}, 'foo', recursivelyThrowingErrorDesc);
26432643

26442644
assert.strictEqual(
2645-
inspect(thrower, { getters: true, depth: 2 }),
2645+
inspect(thrower, { getters: true, depth: 1 }),
26462646
'{\n' +
26472647
' foo: [Getter: <Inspection threw ([object Error] {\n' +
2648-
' stack: [Getter/Setter: <Inspection threw ([object Error] {\n' +
2649-
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2650-
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2651-
' name: [Getter: <Inspection threw ([Error])>],\n' +
2652-
' message: [Getter: <Inspection threw ([Error])>]\n' +
2653-
' })>],\n' +
2654-
' cause: [Getter: <Inspection threw ([object Error] {\n' +
2655-
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2656-
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2657-
' name: [Getter: <Inspection threw ([Error])>],\n' +
2658-
' message: [Getter: <Inspection threw ([Error])>]\n' +
2659-
' })>],\n' +
2660-
' name: [Getter: <Inspection threw ([object Error] {\n' +
2661-
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2662-
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2663-
' name: [Getter: <Inspection threw ([Error])>],\n' +
2664-
' message: [Getter: <Inspection threw ([Error])>]\n' +
2665-
' })>],\n' +
2666-
' message: [Getter: <Inspection threw ([object Error] {\n' +
2667-
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2668-
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2669-
' name: [Getter: <Inspection threw ([Error])>],\n' +
2670-
' message: [Getter: <Inspection threw ([Error])>]\n' +
2671-
' })>]\n' +
2648+
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2649+
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2650+
' name: [Getter: <Inspection threw ([Error])>],\n' +
2651+
' message: [Getter: <Inspection threw ([Error])>]\n' +
26722652
' })>]\n' +
26732653
'}'
26742654
);
2655+
2656+
[{ getters: true, depth: 2 }, { getters: true }].forEach((options) => {
2657+
assert.strictEqual(
2658+
inspect(thrower, options),
2659+
'{\n' +
2660+
' foo: [Getter: <Inspection threw ([object Error] {\n' +
2661+
' stack: [Getter/Setter: <Inspection threw ([object Error] {\n' +
2662+
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2663+
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2664+
' name: [Getter: <Inspection threw ([Error])>],\n' +
2665+
' message: [Getter: <Inspection threw ([Error])>]\n' +
2666+
' })>],\n' +
2667+
' cause: [Getter: <Inspection threw ([object Error] {\n' +
2668+
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2669+
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2670+
' name: [Getter: <Inspection threw ([Error])>],\n' +
2671+
' message: [Getter: <Inspection threw ([Error])>]\n' +
2672+
' })>],\n' +
2673+
' name: [Getter: <Inspection threw ([object Error] {\n' +
2674+
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2675+
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2676+
' name: [Getter: <Inspection threw ([Error])>],\n' +
2677+
' message: [Getter: <Inspection threw ([Error])>]\n' +
2678+
' })>],\n' +
2679+
' message: [Getter: <Inspection threw ([object Error] {\n' +
2680+
' stack: [Getter/Setter: <Inspection threw ([Error])>],\n' +
2681+
' cause: [Getter: <Inspection threw ([Error])>],\n' +
2682+
' name: [Getter: <Inspection threw ([Error])>],\n' +
2683+
' message: [Getter: <Inspection threw ([Error])>]\n' +
2684+
' })>]\n' +
2685+
' })>]\n' +
2686+
'}'
2687+
);
2688+
});
26752689
}
26762690

26772691
// Property getter throwing an error whose own getters throw that same error (infinite recursion).

0 commit comments

Comments
 (0)