From ccb322db6d1f14c3013bacb01dcb064a3f7fa28f Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 14 Jul 2019 10:15:10 -0400 Subject: 420857 - Part 1: Report the position of opening brace for missing brace error in function body. --- .../jit-test/tests/parser/missing-closing-brace.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 js/src/jit-test/tests/parser/missing-closing-brace.js (limited to 'js/src/jit-test') diff --git a/js/src/jit-test/tests/parser/missing-closing-brace.js b/js/src/jit-test/tests/parser/missing-closing-brace.js new file mode 100644 index 000000000..4512ad133 --- /dev/null +++ b/js/src/jit-test/tests/parser/missing-closing-brace.js @@ -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]); -- cgit v1.2.3