Skip to content

Commit 2fbbdc1

Browse files
committed
Fixed handling of indentation with line continuations
1 parent 4b2092b commit 2fbbdc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+557
-17
lines changed

graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/BasicTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,11 @@ public void multipleStatements() {
10331033
checkSyntaxErrorMessage("a = 1\nb = 1", "multiple statements found while compiling a single statement", InputType.SINGLE);
10341034
}
10351035

1036+
@Test
1037+
public void lineContinuationInIndent() {
1038+
checkIndentationErrorMessage("\n \\\n (\\\n \\ ", "unexpected indent");
1039+
}
1040+
10361041
private void checkScopeAndTree() throws Exception {
10371042
File testFile = getTestFileFromTestAndTestMethod();
10381043
checkScopeFromFile(testFile, false);

graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/ParserTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void checkSyntaxErrorMessage(String source, String expectedMessage, Input
148148
assertTrue("Expected Error.", errorCallback.hasErrors());
149149
TestErrorCallbackImpl.Error error = errorCallback.getErrors().get(0);
150150
assertSame("Expected SyntaxError not " + error.getType(), error.getType(), ErrorCallback.ErrorType.Syntax);
151-
assertEquals("The expected message:\n\"" + expectedMessage + "\"\n was not found. The message is: \n\"" + error.getMessage() + "\"", error.getMessage(), expectedMessage);
151+
assertEquals(expectedMessage, error.getMessage());
152152
}
153153

154154
public void checkDeprecationWarning(String source, String expectedMessage) {
@@ -177,7 +177,7 @@ public void checkIndentationErrorMessage(String source, String expectedMessage)
177177
assertTrue("Expected Error.", errorCallback.hasErrors());
178178
TestErrorCallbackImpl.Error error = errorCallback.getErrors().get(0);
179179
assertSame("Expected IndentationError not " + error.getType(), error.getType(), ErrorCallback.ErrorType.Indentation);
180-
assertEquals("The expected message:\n\"" + expectedMessage + "\"\n was not found. The message is: \n\"" + error.getMessage() + "\"", error.getMessage(), expectedMessage);
180+
assertEquals(expectedMessage, error.getMessage());
181181
}
182182

183183
public void checkTreeFromFile(File testFile, boolean goldenFileNextToTestFile) throws Exception {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Module[0, 4]
2+
BYTES[0, 4] Value: <unprintable value>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Module[0, 6]
2+
Dict[0, 6]
3+
Values:
4+
Key: LONG[1, 2] Value: 1
5+
Val: LONG[4, 5] Value: 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Module[0, 23]
2+
DictComp[0, 23]
3+
Key: Tuple[1, 5]
4+
Values:
5+
Name[2, 3] Value: "a"
6+
Value: Name[7, 8] Value: "b"
7+
ComprehensionTy[10, 22]
8+
Target:
9+
Tuple[14, 17] Context: Store
10+
Values:
11+
Name[14, 15] Value: "a" Store
12+
Name[16, 17] Value: "b" Store
13+
Iterator: Name[21, 22] Value: "y"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Module[0, 3]
2+
ELLIPSIS[0, 3] Value: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Module[0, 9]
2+
JoinedStr[0, 9]
3+
Values:
4+
RAW[2, 3] Value: "a"
5+
FormattedValue[4, 7]
6+
Value: Name[1, 2] Value: "b"
7+
Conversion: 114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Module[0, 45]
2+
JoinedStr[0, 45]
3+
Values:
4+
RAW[4, 15] Value: "First line."
5+
FormattedValue[16, 27]
6+
Value:
7+
BinOp[5, 12]
8+
Op: Add
9+
LHS: Name[5, 7] Value: "v1"
10+
RHS: Name[10, 12] Value: "v2"
11+
Conversion: -1
12+
RAW[28, 42] Value: "\nAnother line."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Module[0, 5]
2+
BOOLEAN[0, 5] Value: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Module[0, 17]
2+
GeneratorExp[0, 17]
3+
Element:
4+
Tuple[1, 5]
5+
Values:
6+
Name[2, 3] Value: "a"
7+
ComprehensionTy[6, 16]
8+
Target: Name[10, 11] Value: "a" Store
9+
Iterator: Name[15, 16] Value: "b"

0 commit comments

Comments
 (0)