update template literal parsing to properly handle newlines

This commit is contained in:
Sebastian McKenzie
2015-06-05 09:36:37 +01:00
parent f3acedbf08
commit 02a6feed73
3 changed files with 17 additions and 15 deletions

View File

@@ -813,7 +813,7 @@ test("`\\n\\r\\b\\v\\t\\f\\\n\\\r\n`", {
type: "TemplateLiteral",
quasis: [{
type: "TemplateElement",
value: {raw: "\\n\\r\\b\\v\\t\\f\\\n\\\r\n", cooked: "\n\r\b\u000b\t\f"},
value: {raw: "\\n\\r\\b\\v\\t\\f\\\n\\\n", cooked: "\n\r\b\u000b\t\f"},
tail: true,
loc: {
start: {line: 1, column: 1},
@@ -841,7 +841,7 @@ test("`\\n\\r\\b\\v\\t\\f\\\n\\\r\n`", {
locations: true
});
test("`\n\r\n`", {
test("`\n\r\n\r`", {
type: "Program",
body: [{
type: "ExpressionStatement",
@@ -849,27 +849,27 @@ test("`\n\r\n`", {
type: "TemplateLiteral",
quasis: [{
type: "TemplateElement",
value: {raw: "\n\r\n", cooked: "\n\n"},
value: {raw: "\n\n\n", cooked: "\n\n\n"},
tail: true,
loc: {
start: {line: 1, column: 1},
end: {line: 3, column: 0}
end: {line: 4, column: 0}
}
}],
expressions: [],
loc: {
start: {line: 1, column: 0},
end: {line: 3, column: 1}
end: {line: 4, column: 1}
}
},
loc: {
start: {line: 1, column: 0},
end: {line: 3, column: 1}
end: {line: 4, column: 1}
}
}],
loc: {
start: {line: 1, column: 0},
end: {line: 3, column: 1}
end: {line: 4, column: 1}
}
}, {
ecmaVersion: 6,
@@ -14134,8 +14134,6 @@ test('function normal(x, y = 10) {}', {
}]
}, {ecmaVersion: 6});
test("'use strict'; function f([x,,z]) {}", {}, {ecmaVersion: 6});
// test preserveParens option with arrow functions
test("() => 42", {
type: "Program",