|
@@ -1,5 +1,11 @@
|
|
/*
|
|
/*
|
|
These tests deliberately produce syntax errors to check what line the parser thinks we're on.
|
|
These tests deliberately produce syntax errors to check what line the parser thinks we're on.
|
|
|
|
+Note that line numbers are higher than you might expect as the parsed code is:
|
|
|
|
+
|
|
|
|
+function anonymous(
|
|
|
|
+) {
|
|
|
|
+<code>
|
|
|
|
+}
|
|
|
|
|
|
⚠ PLEASE MAKE SURE TO NOT LET YOUR EDITOR REMOVE THE LS/PS LINE TERMINATORS!
|
|
⚠ PLEASE MAKE SURE TO NOT LET YOUR EDITOR REMOVE THE LS/PS LINE TERMINATORS!
|
|
*/
|
|
*/
|
|
@@ -7,31 +13,31 @@ These tests deliberately produce syntax errors to check what line the parser thi
|
|
test("LINE FEED is a line terminator", () => {
|
|
test("LINE FEED is a line terminator", () => {
|
|
expect(() => {
|
|
expect(() => {
|
|
Function("\n\n@");
|
|
Function("\n\n@");
|
|
- }).toThrowWithMessage(SyntaxError, "line: 3, column: 1");
|
|
|
|
|
|
+ }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
|
|
});
|
|
});
|
|
|
|
|
|
test("CARRIAGE RETURN is a line terminator", () => {
|
|
test("CARRIAGE RETURN is a line terminator", () => {
|
|
expect(() => {
|
|
expect(() => {
|
|
Function("\r\r@");
|
|
Function("\r\r@");
|
|
- }).toThrowWithMessage(SyntaxError, "line: 3, column: 1");
|
|
|
|
|
|
+ }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
|
|
});
|
|
});
|
|
|
|
|
|
test("LINE SEPARATOR is a line terminator", () => {
|
|
test("LINE SEPARATOR is a line terminator", () => {
|
|
expect(() => {
|
|
expect(() => {
|
|
Function("
@");
|
|
Function("
@");
|
|
- }).toThrowWithMessage(SyntaxError, "line: 3, column: 1");
|
|
|
|
|
|
+ }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
|
|
});
|
|
});
|
|
|
|
|
|
test("PARAGRAPH SEPARATOR is a line terminator", () => {
|
|
test("PARAGRAPH SEPARATOR is a line terminator", () => {
|
|
expect(() => {
|
|
expect(() => {
|
|
Function("
@");
|
|
Function("
@");
|
|
- }).toThrowWithMessage(SyntaxError, "line: 3, column: 1");
|
|
|
|
|
|
+ }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
|
|
});
|
|
});
|
|
|
|
|
|
test("CR LF is counted as only one line terminator", () => {
|
|
test("CR LF is counted as only one line terminator", () => {
|
|
expect(() => {
|
|
expect(() => {
|
|
Function("\r\n\r\n@");
|
|
Function("\r\n\r\n@");
|
|
- }).toThrowWithMessage(SyntaxError, "line: 3, column: 1");
|
|
|
|
|
|
+ }).toThrowWithMessage(SyntaxError, "line: 5, column: 1");
|
|
});
|
|
});
|
|
|
|
|
|
test("LF/CR are not allowed in string literal", () => {
|
|
test("LF/CR are not allowed in string literal", () => {
|
|
@@ -49,7 +55,7 @@ test("LS/PS are allowed in string literal", () => {
|
|
test("line terminators can be mixed (but please don't)", () => {
|
|
test("line terminators can be mixed (but please don't)", () => {
|
|
expect(() => {
|
|
expect(() => {
|
|
Function("\r
\r\n
\n\r@");
|
|
Function("\r
\r\n
\n\r@");
|
|
- }).toThrowWithMessage(SyntaxError, "line: 7, column: 1");
|
|
|
|
|
|
+ }).toThrowWithMessage(SyntaxError, "line: 9, column: 1");
|
|
});
|
|
});
|
|
|
|
|
|
test("all line terminators are valid for line continuations", () => {
|
|
test("all line terminators are valid for line continuations", () => {
|