mirror of
https://github.com/RGBCube/serenity
synced 2025-07-15 13:37:35 +00:00

For example, "property.br\u{64}wn" should resolve to "property.brown". To support this behavior, this commit changes the Token class to hold both the evaluated identifier name and a view into the original source for the unevaluated name. There are some contexts in which identifiers are not allowed to contain Unicode escape sequences; for example, export statements of the form "export {} from foo.js" forbid escapes in the identifier "from". The test file is added to .prettierignore because prettier will replace all escaped Unicode sequences with their unescaped value.
19 lines
585 B
JavaScript
19 lines
585 B
JavaScript
test("basic escapes", () => {
|
||
var foo = {};
|
||
foo.brown = 12389;
|
||
|
||
expect(foo.brown).toBe(12389);
|
||
expect(foo.br\u006fwn).toBe(12389);
|
||
expect(foo.br\u{6f}wn).toBe(12389);
|
||
expect(foo.\u{62}\u{72}\u{6f}\u{77}\u{6e}).toBe(12389);
|
||
});
|
||
|
||
test("non-ascii escapes", () => {
|
||
var foo = {};
|
||
foo.𝓑𝓻𝓸𝔀𝓷 = 12389;
|
||
|
||
expect(foo.𝓑𝓻𝓸𝔀𝓷).toBe(12389);
|
||
expect(foo.𝓑𝓻\ud835\udcf8𝔀𝓷).toBe(12389);
|
||
expect(foo.𝓑𝓻\u{1d4f8}𝔀𝓷).toBe(12389);
|
||
expect(foo.\u{1d4d1}\u{1d4fb}\u{1d4f8}\u{1d500}\u{1d4f7}).toBe(12389);
|
||
});
|