From 2d1208556ad09844407c484b1e23887e3ade97c7 Mon Sep 17 00:00:00 2001 From: Steven Guerrero Date: Thu, 14 Jan 2021 14:18:51 -0500 Subject: fix: don't swallow customInspect exceptions (#9095) --- cli/tests/unit/console_test.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'cli/tests/unit/console_test.ts') diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 6f37c8050..64345be84 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -12,6 +12,7 @@ import { assert, assertEquals, assertStringIncludes, + assertThrows, unitTest, } from "./test_util.ts"; import { stripColor } from "../../../std/fmt/colors.ts"; @@ -834,19 +835,11 @@ unitTest(function consoleTestWithCustomInspectorError(): void { } } - assertEquals(stringify(new A()), "A {}"); - - class B { - constructor(public field: { a: string }) {} - [customInspect](): string { - return this.field.a; - } - } - - assertEquals(stringify(new B({ a: "a" })), "a"); - assertEquals( - stringify(B.prototype), - "B { [Symbol(Deno.customInspect)]: [Function: [Deno.customInspect]] }", + assertThrows( + () => stringify(new A()), + Error, + "BOOM", + "Custom inspect won't attempt to parse if user defined function throws", ); }); -- cgit v1.2.3