420857 - Part 1: Report the position of opening brace for missing brace error in function body.

This commit is contained in:
Gaming4JC 2019-07-14 10:15:10 -04:00 • committed by Roy Tam
commit e5f1edc00c
4 changed files with 71 additions and 6 deletions

View file

@ -0,0 +1,30 @@
function test(source, [lineNumber, columnNumber]) {
let caught = false;
try {
Reflect.parse(source, { source: "foo.js" });
} catch (e) {
assertEq(e.message.includes("missing } "), true);
let notes = getErrorNotes(e);
assertEq(notes.length, 1);
let note = notes[0];
assertEq(note.message, "{ opened at line " + lineNumber + ", column " + columnNumber);
assertEq(note.fileName, "foo.js");
assertEq(note.lineNumber, lineNumber);
assertEq(note.columnNumber, columnNumber);
caught = true;
}
assertEq(caught, true);
}
// Function
test(`
function test1() {
}
function test2() {
if (true) {
//}
}
function test3() {
}
`, [4, 17]);