diff options
22 files changed, 330 insertions, 0 deletions
diff --git a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 31ca56a0..674e2ba9 100644 --- a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -132,6 +132,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 31ca56a0..674e2ba9 100644 --- a/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter06/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -132,6 +132,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 5bb67817..d6c91a4a 100644 --- a/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter07/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -132,6 +132,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 68d379a1..fa9a5e37 100644 --- a/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter08/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 6ad3af15..2c869033 100644 --- a/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter09/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter10a/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter10a/src/test/java/com/seaofnodes/simple/Chapter05Test.java index aefb3a5c..cf7bd6cf 100644 --- a/chapter10a/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter10a/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter10b/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter10b/src/test/java/com/seaofnodes/simple/Chapter05Test.java index aefb3a5c..cf7bd6cf 100644 --- a/chapter10b/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter10b/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 91efc3d6..7beeb4d9 100644 --- a/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter11/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 91efc3d6..7beeb4d9 100644 --- a/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter12/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java index ca7bb482..cd646126 100644 --- a/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter13/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java index ca7bb482..cd646126 100644 --- a/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter14/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java index ca7bb482..cd646126 100644 --- a/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter15/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java index ca7bb482..cd646126 100644 --- a/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter16/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 9afb8f28..7ea75f49 100644 --- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -133,6 +133,21 @@ return a;"""); } @Test + public void testMergeSameCon() { + Parser parser = new Parser( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + StopNode ret = parser.parse(); + assertEquals("return 3;", ret.toString()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.toString()); diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java index f4db5624..ff60c695 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { StopNode stop = new Parser("return true;").parse(); assertEquals("return 1;",stop.ret().print()); diff --git a/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 86ec4136..7a9414a2 100644 --- a/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter19/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -134,6 +134,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); assertEquals("return 1;",code.print()); diff --git a/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java index a584ad5a..70cc6121 100644 --- a/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter20/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -135,6 +135,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); assertEquals("return 1;",code.print()); diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -135,6 +135,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); assertEquals("return 1;",code.print()); diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -135,6 +135,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); assertEquals("return 1;",code.print()); diff --git a/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter23/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -135,6 +135,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); assertEquals("return 1;",code.print()); diff --git a/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java index d1dfd216..6ff4ac95 100644 --- a/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter24/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -135,6 +135,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); assertEquals("return 1;",code.print()); diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 6ac08fda..79af6ae7 100644 --- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -138,6 +138,21 @@ return a; } @Test + public void testMergeSameCon() { + CodeGen code = new CodeGen( +""" +int a=arg; +if( arg==1 ) + a=3; +else + a=3; +return a; +"""); + code.parse().opto(); + assertEquals("return 3;", code.print()); + } + + @Test public void testTrue() { CodeGen code = new CodeGen("return true;").parse(); assertEquals("return 1;",code.print()); |
