From a33315aaa70884c10968669c31adf3c6bb142e72 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Tue, 22 Sep 2020 23:10:02 +0800 Subject: fix(cli/console): quote object symbol keys that are invalid identifiers (#7553) --- cli/tests/unit/console_test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cli/tests/unit') diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 97f4ce0d2..483ecfab6 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -110,6 +110,24 @@ unitTest( ), `{ "foo\\b": "bar\\n", "bar\\r": "baz\\t", "qux\\x00": "qux\\x00" }`, ); + assertEquals( + stringify( + { + [Symbol("foo\b")]: `Symbol("foo\n")`, + [Symbol("bar\n")]: `Symbol("bar\n")`, + [Symbol("bar\r")]: `Symbol("bar\r")`, + [Symbol("baz\t")]: `Symbol("baz\t")`, + [Symbol("qux\0")]: `Symbol("qux\0")`, + }, + ), + `{ + Symbol("foo\\b"): 'Symbol("foo\\n\")', + Symbol("bar\\n"): 'Symbol("bar\\n\")', + Symbol("bar\\r"): 'Symbol("bar\\r\")', + Symbol("baz\\t"): 'Symbol("baz\\t\")', + Symbol("qux\\x00"): 'Symbol(\"qux\\x00")' +}`, + ); assertEquals( stringify(new Set(["foo\n", "foo\r", "foo\0"])), `Set { "foo\\n", "foo\\r", "foo\\x00" }`, -- cgit v1.2.3