summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/Chapter14Test.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter14Test.java')
-rw-r--r--src/test/java/com/seaofnodes/simple/Chapter14Test.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter14Test.java b/src/test/java/com/seaofnodes/simple/Chapter14Test.java
index 048cb93a..7d7bb25a 100644
--- a/src/test/java/com/seaofnodes/simple/Chapter14Test.java
+++ b/src/test/java/com/seaofnodes/simple/Chapter14Test.java
@@ -59,7 +59,7 @@ while( b ) b = b + 456;// Truncate
return b;
""");
StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop9,123,((Phi_b+456)&255));", stop.toString());
+ assertEquals("return Phi(Loop11,123,((Phi_b+456)&255));", stop.toString());
}
@Test
@@ -93,7 +93,7 @@ return b;
public void testRefLoad() {
Parser parser = new Parser(
"""
-struct Foo { u1 b; }
+struct Foo { u1 b; };
Foo f = new Foo;
f.b = 123;
return f.b;
@@ -166,6 +166,39 @@ return arg;
}
@Test
+ public void testCloneAnd() {
+ Parser parser = new Parser("""
+int v0=0;
+u32 v1 = 1&(1<<arg)&(1<<arg);
+while(arg) v1=-v0;
+while(v1) break;
+return v1;
+""");
+ StopNode stop = parser.parse().iterate();
+ assertEquals("return (Phi(Loop18,((1<<arg)&1),0)&Phi(Loop,Shl,4294967295));", stop.toString());
+ assertEquals(1L, Evaluator.evaluate(stop, 0));
+ }
+
+ @Test
+ public void testAndHigh() {
+ Parser parser = new Parser("""
+int v0=0;
+if(0&0>>>0) {
+ while(0) {
+ u8 v1=0;
+ v0=0>>>0;
+ v1=arg;
+ while(v1+0) {}
+ }
+}
+return v0;
+""");
+ StopNode stop = parser.parse().iterate();
+ assertEquals("return 0;", stop.toString());
+ assertEquals(0L, Evaluator.evaluate(stop, 0));
+ }
+
+ @Test
public void testTypes() {
Parser parser = new Parser(
"""