summaryrefslogtreecommitdiff
path: root/cli/js/console_test.ts
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-10-28 15:29:15 -0700
committerRy Dahl <ry@tinyclouds.org>2019-10-28 18:29:15 -0400
commit2f0f236d5656fa2d89a8e1571d03c4bda5f10d38 (patch)
tree1437e129e3d82434e563ed80c571cfd90ccbdf08 /cli/js/console_test.ts
parentf484776384ad7df35ab7626b7a673f3902a6cfaa (diff)
Prevent customInspect error from crashing console (#3226)
Diffstat (limited to 'cli/js/console_test.ts')
-rw-r--r--cli/js/console_test.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/js/console_test.ts b/cli/js/console_test.ts
index 903e65a82..50fe1d66a 100644
--- a/cli/js/console_test.ts
+++ b/cli/js/console_test.ts
@@ -190,6 +190,27 @@ test(function consoleTestWithCustomInspector(): void {
assertEquals(stringify(new A()), "b");
});
+test(function consoleTestWithCustomInspectorError(): void {
+ class A {
+ [customInspect](): string {
+ throw new Error("BOOM");
+ return "b";
+ }
+ }
+
+ 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), "{}");
+});
+
test(function consoleTestWithIntegerFormatSpecifier(): void {
assertEquals(stringify("%i"), "%i");
assertEquals(stringify("%i", 42.0), "42");