* Print \x and \u escapes in strings and regexes lowercase
Theoretically, we would want to do this for escapes int identifiers as
well. However, neither flow nor babylon preserves escapes in
identifiers. For example, `\u0061.\u{0061}` cannot be distinguished from
`a.a`. Nobody uses such escapes in real code anyway. It could also be
considered a feature that such escapes are converted to real unicode
characters.
* Update snapshots
* Normalize escapes in template literals
* Update snapshots
49 lines
548 B
JavaScript
49 lines
548 B
JavaScript
[
|
|
"abc",
|
|
'abc',
|
|
|
|
'\'',
|
|
|
|
'"',
|
|
'\"',
|
|
'\\"',
|
|
|
|
"'",
|
|
"\'",
|
|
"\\'",
|
|
|
|
"'\"",
|
|
'\'"',
|
|
|
|
'\\',
|
|
"\\",
|
|
|
|
'\0',
|
|
'🐶',
|
|
|
|
'\uD801\uDC28',
|
|
];
|
|
|
|
// Normalization of \x and \u escapes:
|
|
|
|
// Basic case.
|
|
"a\xAaAb\uB1cDE";
|
|
`a\xAaAb\uB1cDE`;
|
|
|
|
// ES2015 unicode escapes.
|
|
"\u{1Fa3}";
|
|
`\u{1Fa3}`;
|
|
"\u{00000000A0}";
|
|
`\u{00000000A0}`;
|
|
|
|
// Leaves other escapes alone.
|
|
"\B\S";
|
|
`\B\S`;
|
|
|
|
// Handles escaped backslashes.
|
|
"\\xAB\\\xAB\\\\xAB\B\\\B\u1234";
|
|
`\\xAB\\\xAB\\\\xAB\B\\\B\u1234`;
|
|
|
|
// Mix of everything.
|
|
"\xF0"`a\uaBcD${'\xFdE'}\\\u{00AbCdE}`;
|