From d3ffe6f9a935888233283962ce077ec25a01bec9 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Wed, 1 Nov 2023 22:08:30 +0800 Subject: Bail out unclosed block (#25) * Report unclosed block in parsing * Fix tests * Resolve comments and rebase onto chapter5 * Test `isEOF` after consume whitespaces --- chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'chapter04/src/test/java/com/seaofnodes') diff --git a/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java b/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java index 4782e568..ed999039 100644 --- a/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java +++ b/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java @@ -277,4 +277,11 @@ public class Chapter04Test { // this test used to fail in chapter 1 assertEquals("return -100;", new Parser("return -100;").parse().print()); } + + @Test + public void testBad6() { + exceptionRule.expect(RuntimeException.class); + exceptionRule.expectMessage("Syntax error, expected }:"); + new Parser("int a=1; int b=2; int c=0; { int b=3; c=a+b;").parse(); + } } -- cgit v1.2.3