From 612818d04399ef706df3df5ac94e6ef7e633cff7 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Tue, 19 Sep 2023 12:24:19 -0600 Subject: fix(cli): ensure that an exception in getOwnPropertyDescriptor('constructor') doesn't break Deno.inspect (#20568) Fixes #20561 --- cli/tests/unit/console_test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (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 7dac7ca77..d8990559e 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -1051,6 +1051,18 @@ Deno.test(function consoleTestWithCustomInspectorUsingInspectFunc() { assertEquals(stringify(new A()), "b { c: 1 }"); }); +Deno.test(function consoleTestWithConstructorError() { + const obj = new Proxy({}, { + getOwnPropertyDescriptor(_target, name) { + if (name == "constructor") { + throw "yikes"; + } + return undefined; + }, + }); + assertEquals(Deno.inspect(obj), "{}"); +}); + Deno.test(function consoleTestWithCustomInspectorError() { class A { [customInspect](): never { -- cgit v1.2.3