From 43f2a09f106072727eaceb6134be02c03429b425 Mon Sep 17 00:00:00 2001 From: XmiliaH <45106915+XmiliaH@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:25:56 +0100 Subject: Report unclosed block in parsing (#28) --- .../src/test/java/com/seaofnodes/simple/Chapter05Test.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'chapter05/src/test/java/com/seaofnodes') diff --git a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java index ab956e9f..254f4530 100644 --- a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -429,4 +429,14 @@ return c; // this test used to fail in chapter 1 assertEquals("return -100;", new Parser("return -100;").parse().print()); } + + @Test + public void testBad6() { + try { + new Parser("int a=1; int b=2; int c=0; { int b=3; c=a+b;").parse(); + fail(); + } catch( RuntimeException e ) { + assertEquals("Syntax error, expected }: ",e.getMessage()); + } + } } -- cgit v1.2.3