diff options
Diffstat (limited to 'js/console_test.ts')
-rw-r--r-- | js/console_test.ts | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/js/console_test.ts b/js/console_test.ts index 8070ee0f0..a2f9280a1 100644 --- a/js/console_test.ts +++ b/js/console_test.ts @@ -3,8 +3,15 @@ import { assert, assertEquals, test } from "./test_util.ts"; // Some of these APIs aren't exposed in the types and so we have to cast to any // in order to "trick" TypeScript. -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const { Console, stringifyArgs, inspect, write, stdout } = Deno as any; +const { + Console, + customInspect, + stringifyArgs, + inspect, + write, + stdout + // eslint-disable-next-line @typescript-eslint/no-explicit-any +} = Deno as any; function stringify(...args: unknown[]): string { return stringifyArgs(args).replace(/\n$/, ""); @@ -173,6 +180,16 @@ test(function consoleTestStringifyWithDepth(): void { ); }); +test(function consoleTestWithCustomInspector(): void { + class A { + [customInspect](): string { + return "b"; + } + } + + assertEquals(stringify(new A()), "b"); +}); + test(function consoleTestWithIntegerFormatSpecifier(): void { assertEquals(stringify("%i"), "%i"); assertEquals(stringify("%i", 42.0), "42"); |