diff options
| author | fuhsnn <66062782+fuhsnn@users.noreply.github.com> | 2026-09-29 17:37:41 +0800 |
|---|---|---|
| committer | fuhsnn <66062782+fuhsnn@users.noreply.github.com> | 2026-09-29 17:37:41 +0800 |
| commit | 23481970c0115bf86f08c89b3916285b78311b8d (patch) | |
| tree | 052fee43de656a562809bb61466386922db27a1d | |
| parent | 41be002e89358649da46c33c8245aa786afdad6a (diff) | |
| download | Simple-23481970c0115bf86f08c89b3916285b78311b8d.tar.gz Simple-23481970c0115bf86f08c89b3916285b78311b8d.zip | |
Add same constant phi merge test
21 files changed, 315 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/chapter10/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter10/src/test/java/com/seaofnodes/simple/Chapter05Test.java index 35e54fa9..3d75ed03 100644 --- a/chapter10/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter10/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 8d15493f..b01ffe0a 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 8d15493f..b01ffe0a 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 9d154413..70f4ccea 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 9d154413..70f4ccea 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 9d154413..70f4ccea 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 b5920125..81ff2244 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()); |
