diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-09-24 02:10:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-23 14:10:35 -0400 |
commit | e1b61d6794facf2d8da4d13273685dc0a5248aed (patch) | |
tree | 2e0d1bc091c56e2c04305d3e09f230dc33fd8260 /cli/tests/unit/console_test.ts | |
parent | 3ac9f1e209c3bb10cbb3c0a49077877a5bc5e2eb (diff) |
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.
Diffstat (limited to 'cli/tests/unit/console_test.ts')
-rw-r--r-- | cli/tests/unit/console_test.ts | 28 |
1 files changed, 27 insertions, 1 deletions
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 @@ -106,6 +106,32 @@ unitTest( ); 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( + stringify( { "foo\b": "bar\n", "bar\r": "baz\t", "qux\0": "qux\0" }, ), `{ "foo\\b": "bar\\n", "bar\\r": "baz\\t", "qux\\x00": "qux\\x00" }`, @@ -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 }"); |