summaryrefslogtreecommitdiff
path: root/chapter04/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'chapter04/src/test/java/com')
-rw-r--r--chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java b/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java
index 988e3608..8cc78af0 100644
--- a/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java
+++ b/chapter04/src/test/java/com/seaofnodes/simple/Chapter04Test.java
@@ -99,6 +99,20 @@ public class Chapter04Test {
}
@Test
+ public void testChapter4Bug1() {
+ Parser parser = new Parser("int a=arg+1; int b=a; b=1; return a+2; #showGraph;", TypeInteger.BOT);
+ ReturnNode ret = parser.parse();
+ assertEquals("return (Proj_3+3);", ret.print());
+ }
+
+ @Test
+ public void testChapter4Bug2() {
+ Parser parser = new Parser("int a=arg+1; a=a; return a; #showGraph;", TypeInteger.BOT);
+ ReturnNode ret = parser.parse();
+ assertEquals("return (Proj_3+1);", ret.print());
+ }
+
+ @Test
public void testVarDecl() {
Parser parser = new Parser("int a=1; return a;");
ReturnNode ret = parser.parse();
@@ -135,6 +149,13 @@ public class Chapter04Test {
assertEquals("return 8;", ret.print());
}
+ @Test
+ public void testSelfAssign() {
+ exceptionRule.expect(RuntimeException.class);
+ exceptionRule.expectMessage("Undefined name 'a'");
+ new Parser("int a=a; return a;").parse();
+ }
+
@Test
public void testChapter2ParseGrammar() {