summaryrefslogtreecommitdiff
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
parent83bc7cc22d7ace761b6d1be565e2dc71d556d31e (diff)
downloadSimple-8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9.tar.gz
Simple-8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9.zip
Add testRedeclareVar in all later chapters
-rw-r--r--chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter05/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter06/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter07/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter08/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter10/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter11/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter12/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter13/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter14/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter15/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter16/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter17/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
-rw-r--r--chapter18/src/test/java/com/seaofnodes/simple/Chapter03Test.java10
15 files changed, 150 insertions, 0 deletions
diff --git a/chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index 950d87fe..fc8e97b6 100644
--- a/chapter04/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter04/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();
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();
diff --git a/chapter06/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter06/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index 33e2e824..10b67f5f 100644
--- a/chapter06/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter06/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();
diff --git a/chapter07/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter07/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index 33e2e824..1e67cef5 100644
--- a/chapter07/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter07/src/test/java/com/seaofnodes/simple/Chapter03Test.java
@@ -54,6 +54,16 @@ public class Chapter03Test {
assertEquals("Undefined name 'a'",e.getMessage());
}
}
+
+ @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() {
diff --git a/chapter08/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter08/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c76df903..64ff153e 100644
--- a/chapter08/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter08/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();
diff --git a/chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index a243beb1..2246b927 100644
--- a/chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter09/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();
diff --git a/chapter10/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter10/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c76df903..64ff153e 100644
--- a/chapter10/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter10/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();
diff --git a/chapter11/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter11/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c76df903..64ff153e 100644
--- a/chapter11/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter11/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();
diff --git a/chapter12/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter12/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c76df903..64ff153e 100644
--- a/chapter12/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter12/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();
diff --git a/chapter13/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter13/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c76df903..64ff153e 100644
--- a/chapter13/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter13/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();
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
@@ -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();
diff --git a/chapter15/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter15/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c76df903..64ff153e 100644
--- a/chapter15/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter15/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();
diff --git a/chapter16/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter16/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c76df903..64ff153e 100644
--- a/chapter16/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter16/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();
diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index 4525918c..2de0b46e 100644
--- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter17/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();
diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index a7fc3ae5..825235cc 100644
--- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter03Test.java
@@ -51,6 +51,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 CodeGen("int a=1; int b=2; int !c=0; { int b=3; c=a+b;").parse();