aboutsummaryrefslogtreecommitdiff
path: root/javatests
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2018-12-14 15:36:51 -0800
committerLiam Miller-Cushon <cushon@google.com>2019-01-28 21:35:24 -0800
commit49fc8eaf64a247dc8e93127e7bb9344a1c7d5c6d (patch)
treed7d5195be5670a18093d53aeba597880ef86fecf /javatests
parent31a1bf1ff7a7b2c216249a53fb5415f18dd94e46 (diff)
downloadturbine-49fc8eaf64a247dc8e93127e7bb9344a1c7d5c6d.tar.gz
Report diagnostics for unterminated expressions at the beginning of the expression instead of at the end of the file, which is probably farther from the problem.
MOE_MIGRATED_REVID=225615449
Diffstat (limited to 'javatests')
-rw-r--r--javatests/com/google/turbine/parse/ParseErrorTest.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/javatests/com/google/turbine/parse/ParseErrorTest.java b/javatests/com/google/turbine/parse/ParseErrorTest.java
index 53864ef..d1eb9c4 100644
--- a/javatests/com/google/turbine/parse/ParseErrorTest.java
+++ b/javatests/com/google/turbine/parse/ParseErrorTest.java
@@ -202,6 +202,23 @@ public class ParseErrorTest {
}
}
+ @Test
+ public void unterminatedExpr() {
+ String input = "class T { String s = hello + world }";
+ try {
+ Parser.parse(input);
+ fail("expected parsing to fail");
+ } catch (TurbineError e) {
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo(
+ lines(
+ "<>:1: error: unterminated expression, expected ';' not found", //
+ "class T { String s = hello + world }",
+ " ^"));
+ }
+ }
+
private static String lines(String... lines) {
return Joiner.on(System.lineSeparator()).join(lines);
}