summaryrefslogtreecommitdiff
path: root/chapter05/src/test/java/com/seaofnodes
diff options
context:
space:
mode:
authortannal <tannal2409@gmail.com>2025-01-19 21:52:02 +0800
committerCliff Click <cliffc@acm.org>2025-01-19 11:35:22 -0800
commit8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9 (patch)
tree122f2422d573608e15925b03af1d09828942f74b /chapter05/src/test/java/com/seaofnodes
parent83bc7cc22d7ace761b6d1be565e2dc71d556d31e (diff)
downloadSimple-8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9.tar.gz
Simple-8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9.zip
Add testRedeclareVar in all later chapters
Diffstat (limited to 'chapter05/src/test/java/com/seaofnodes')
-rw-r--r--chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index 407fbe48..adbfba84 100644
--- a/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java
@@ -56,6 +56,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 {
new Parser("int a=1; int b=2; int c=0; { int b=3; c=a+b;").parse();