Fix off-by-one error preventing empty string literals (#361)
This commit is contained in:
Родитель
aa12229c7b
Коммит
d6b42466eb
|
@ -444,11 +444,10 @@ export function createScanner(source: string | SourceFile, onError = throwOnErro
|
|||
if (tripleQuoted) {
|
||||
tokenFlags |= TokenFlags.TripleQuoted;
|
||||
quoteLength = 3;
|
||||
position += 2;
|
||||
closing = '"""';
|
||||
}
|
||||
|
||||
position += quoteLength;
|
||||
|
||||
scanUntil(
|
||||
(ch) => {
|
||||
if (isEscaping) {
|
||||
|
|
|
@ -145,6 +145,10 @@ describe("scanner", () => {
|
|||
strictEqual(scanner.getTokenValue(), expectedValue);
|
||||
}
|
||||
|
||||
it("scans empty strings", () => {
|
||||
scanString('""', "");
|
||||
});
|
||||
|
||||
it("scans strings single-line strings with escape sequences", () => {
|
||||
scanString('"Hello world \\r\\n \\t \\" \\\\ !"', 'Hello world \r\n \t " \\ !');
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче