From 8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9 Mon Sep 17 00:00:00 2001 From: tannal Date: Sun, 19 Jan 2025 21:52:02 +0800 Subject: Add testRedeclareVar in all later chapters --- .../src/test/java/com/seaofnodes/simple/Chapter03Test.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'chapter14/src/test/java/com') diff --git a/chapter14/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter14/src/test/java/com/seaofnodes/simple/Chapter03Test.java index c76df903..64ff153e 100644 --- a/chapter14/src/test/java/com/seaofnodes/simple/Chapter03Test.java +++ b/chapter14/src/test/java/com/seaofnodes/simple/Chapter03Test.java @@ -55,6 +55,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