From d832d2bfd1f0487181f96bdecd7a28968a150fac Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 25 Jun 2021 16:19:18 +0900 Subject: chore(ext/console): deprecate Deno.customInspect (#10035) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartek IwaƄczuk --- cli/tests/unit/console_test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'cli/tests') diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 8013da152..edb1b245f 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -17,7 +17,7 @@ import { } from "./test_util.ts"; import { stripColor } from "../../../test_util/std/fmt/colors.ts"; -const customInspect = Deno.customInspect; +const customInspect = Symbol.for("Deno.customInspect"); const { Console, cssToAnsi: cssToAnsi_, @@ -879,6 +879,18 @@ unitTest(function consoleTestWithCustomInspector(): void { assertEquals(stringify(new A()), "b"); }); +unitTest(function consoleTestWithCustomInspectorUsingInspectFunc(): void { + class A { + [customInspect]( + inspect: (v: unknown, opts?: Deno.InspectOptions) => string, + ): string { + return "b " + inspect({ c: 1 }); + } + } + + assertEquals(stringify(new A()), "b { c: 1 }"); +}); + unitTest(function consoleTestWithCustomInspectorError(): void { class A { [customInspect](): never { -- cgit v1.2.3