Files
test-repo/tests/strings/strings.js
T
Simon Lydell 7148184d65 Print \x and \u escapes in strings and regexes lowercase (#522)
* 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
2017-01-31 06:56:26 -08:00

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}`;