From e1b61d6794facf2d8da4d13273685dc0a5248aed Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Thu, 24 Sep 2020 02:10:35 +0800 Subject: fix(cli/console): quote non-alphanumeric symbols (#7641) This quotes and escapes symbol descriptions that contains characters outside of the basic alpha-numeric identifier range. --- cli/tests/unit/console_test.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'cli/tests') diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 1163705a9..38bb852f0 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -102,6 +102,32 @@ unitTest( "foo\\n", "foo\\r", "foo\\t", "foo\\v", "foo\\x00" +]`, + ); + assertEquals( + stringify( + [ + Symbol(), + Symbol(""), + Symbol("foo\b"), + Symbol("foo\f"), + Symbol("foo\n"), + Symbol("foo\r"), + Symbol("foo\t"), + Symbol("foo\v"), + Symbol("foo\0"), + ], + ), + `[ + Symbol(), + Symbol(""), + Symbol("foo\\b"), + Symbol("foo\\f"), + Symbol("foo\\n"), + Symbol("foo\\r"), + Symbol("foo\\t"), + Symbol("foo\\v"), + Symbol("foo\\x00") ]`, ); assertEquals( @@ -247,7 +273,7 @@ unitTest(function consoleTestStringifyCircular(): void { ); assertEquals(stringify(new WeakSet()), "WeakSet { [items unknown] }"); assertEquals(stringify(new WeakMap()), "WeakMap { [items unknown] }"); - assertEquals(stringify(Symbol(1)), "Symbol(1)"); + assertEquals(stringify(Symbol(1)), `Symbol("1")`); assertEquals(stringify(null), "null"); assertEquals(stringify(undefined), "undefined"); assertEquals(stringify(new Extended()), "Extended { a: 1, b: 2 }"); -- cgit v1.2.3