summaryrefslogtreecommitdiff
path: root/cli/tests/unit/console_test.ts
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-04-27 11:54:47 +0200
committerGitHub <noreply@github.com>2021-04-27 11:54:47 +0200
commit83770e898e365579dcc30650f706116a312bd9f6 (patch)
tree8e7559a8437166cde7043ed88c74ca376cd3aaad /cli/tests/unit/console_test.ts
parent4fa0e9c652a43516f717b30d9932cb9f64716b09 (diff)
fix(console): circular customInspect (#10338)
Diffstat (limited to 'cli/tests/unit/console_test.ts')
-rw-r--r--cli/tests/unit/console_test.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts
index d7c4fd0cb..a43bfdba3 100644
--- a/cli/tests/unit/console_test.ts
+++ b/cli/tests/unit/console_test.ts
@@ -342,6 +342,14 @@ unitTest(function consoleTestStringifyCircular(): void {
stringify({ str: 1, [Symbol.for("sym")]: 2, [Symbol.toStringTag]: "TAG" }),
'TAG { str: 1, [Symbol(sym)]: 2, [Symbol(Symbol.toStringTag)]: "TAG" }',
);
+ assertEquals(
+ stringify({
+ [Deno.customInspect]: function () {
+ return Deno.inspect(this);
+ },
+ }),
+ "[Circular]",
+ );
// test inspect is working the same
assertEquals(stripColor(Deno.inspect(nestedObj)), nestedObjExpected);
});
@@ -878,12 +886,19 @@ unitTest(function consoleTestWithCustomInspectorError(): void {
}
}
+ const a = new A();
assertThrows(
- () => stringify(new A()),
+ () => stringify(a),
Error,
"BOOM",
"Custom inspect won't attempt to parse if user defined function throws",
);
+ assertThrows(
+ () => stringify(a),
+ Error,
+ "BOOM",
+ "Inpsect should fail and maintain a clear CTX_STACK",
+ );
});
unitTest(function consoleTestWithCustomInspectFunction(): void {