From 83bc7cc22d7ace761b6d1be565e2dc71d556d31e Mon Sep 17 00:00:00 2001 From: tannal Date: Sun, 19 Jan 2025 00:21:18 +0800 Subject: Add a test for redefining variables in chapter 3 --- .../src/test/java/com/seaofnodes/simple/Chapter03Test.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'chapter03') diff --git a/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java index bdb1d9ea..3b8b3449 100644 --- a/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java +++ b/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java @@ -54,6 +54,16 @@ public class Chapter03Test { } } + @Test + public void testRedeclareVar() { + try { + new Parser("int a=1; int b=2; int c=0; int b=3; c=a+b;").parse(); + fail(); + } catch( RuntimeException e ) { + assertEquals("Redefining name 'b'",e.getMessage()); + } + } + @Test public void testBad1() { try { -- cgit v1.2.3