aboutsummaryrefslogtreecommitdiff
path: root/javatests
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2018-06-12 15:34:56 -0700
committerLiam Miller-Cushon <cushon@google.com>2018-06-12 19:44:49 -0700
commit2877e200fc13561bc5171efbdb5e69cb07b4845b (patch)
tree6d71c478c0e3c8dfcf81cc37d77331d453b8cb9b /javatests
parent45f1a55053d6958dcf6b781a98c0a08bb0cf35f9 (diff)
downloadturbine-2877e200fc13561bc5171efbdb5e69cb07b4845b.tar.gz
Don't hang if we run out of input while seeking for matching `)` or `}`
MOE_MIGRATED_REVID=200292694
Diffstat (limited to 'javatests')
-rw-r--r--javatests/com/google/turbine/parse/ParseErrorTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/javatests/com/google/turbine/parse/ParseErrorTest.java b/javatests/com/google/turbine/parse/ParseErrorTest.java
index 0ec6208..c728c8a 100644
--- a/javatests/com/google/turbine/parse/ParseErrorTest.java
+++ b/javatests/com/google/turbine/parse/ParseErrorTest.java
@@ -122,6 +122,38 @@ public class ParseErrorTest {
}
}
+ @Test
+ public void dropParens() {
+ String input = "enum E { ONE(";
+ try {
+ Parser.parse(input);
+ fail("expected parsing to fail");
+ } catch (TurbineError e) {
+ assertThat(e.getMessage())
+ .isEqualTo(
+ lines(
+ "<>:1: error: unexpected end of input", //
+ "enum E { ONE(",
+ " ^"));
+ }
+ }
+
+ @Test
+ public void dropBlocks() {
+ String input = "class T { Object f = new Object() {";
+ try {
+ Parser.parse(input);
+ fail("expected parsing to fail");
+ } catch (TurbineError e) {
+ assertThat(e.getMessage())
+ .isEqualTo(
+ lines(
+ "<>:1: error: unexpected end of input", //
+ "class T { Object f = new Object() {",
+ " ^"));
+ }
+ }
+
private static String lines(String... lines) {
return Joiner.on(System.lineSeparator()).join(lines);
}