summaryrefslogtreecommitdiff
path: root/chapter21/src/test/java/com/seaofnodes
diff options
context:
space:
mode:
Diffstat (limited to 'chapter21/src/test/java/com/seaofnodes')
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java2
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java3
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java31
-rw-r--r--chapter21/src/test/java/com/seaofnodes/simple/progs/jig.smp11
4 files changed, 21 insertions, 26 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java
index 787dfd4c..bce75c81 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java
+++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java
@@ -5,10 +5,8 @@ import com.seaofnodes.simple.codegen.CodeGen;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
-import static org.junit.Assert.fail;
public class Chapter19Test {
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java
index 664620a8..83902b6d 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java
+++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java
@@ -12,7 +12,6 @@ import static org.junit.Assert.*;
public class Chapter20Test {
- //-3834621514626535010L
@Test
public void testJig() {
CodeGen code = new CodeGen("return 0;");
@@ -66,7 +65,7 @@ val sqrt = { int x ->
};
return sqrt(arg) + sqrt(arg+2);
""";
- testCPU(src,"x86_64_v2", "SystemV",23,null);
+ testCPU(src,"x86_64_v2", "Win64" ,23,null);
testCPU(src,"riscv" , "SystemV",19,null);
testCPU(src,"arm" , "SystemV",19,null);
}
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
index 19be4569..f3b2c26d 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
+++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java
@@ -15,7 +15,7 @@ public class Chapter21Test {
@Test @Ignore
public void testJig() throws IOException {
String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/jig.smp"));
- testCPU(src,"x86_64_v2", "SystemV",-1,null);
+ testCPU(src,"x86_64_v2", "Win64",-1,null);
testCPU(src,"riscv" , "SystemV",-1,null);
testCPU(src,"arm" , "SystemV",-1,null);
}
@@ -38,6 +38,13 @@ public class Chapter21Test {
testCPU(src,"arm" , "SystemV",0,"return (ori,arg);");
}
+ @Test public void testInfinite() {
+ String src = "struct S { int i; }; S !s = new S; while(1) s.i++;";
+ testCPU(src,"x86_64_v2", "SystemV",0,"return Top;");
+ testCPU(src,"riscv" , "SystemV",2,"return Top;");
+ testCPU(src,"arm" , "SystemV",2,"return Top;");
+ }
+
@Test
public void testArray1() throws IOException {
String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/array1.smp"));
@@ -58,7 +65,7 @@ public class Chapter21Test {
public void testNewtonFloat() throws IOException {
String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp"))
+ "flt farg = arg; return test_sqrt(farg) + test_sqrt(farg+2.0);";
- testCPU(src,"x86_64_v2", "SystemV",39,null);
+ testCPU(src,"x86_64_v2", "Win64" ,39,null);
testCPU(src,"riscv" , "SystemV",18,null);
testCPU(src,"arm" , "SystemV",19,null);
}
@@ -71,6 +78,16 @@ public class Chapter21Test {
testCPU(src,"arm" , "SystemV",10,"return mov(mov(S));");
}
+ @Test
+ public void testString() throws IOException {
+ String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/stringHash.smp"));
+ testCPU(src,"x86_64_v2", "SystemV", 9,null);
+ testCPU(src,"riscv" , "SystemV", 5,null);
+ testCPU(src,"arm" , "SystemV", 6,null);
+ }
+
+ @Test public void testStringExport() throws IOException { TestC.run("stringHash"); }
+
@Test public void testNewtonExport() throws IOException {
String result = """
0 0.000000
@@ -87,16 +104,6 @@ public class Chapter21Test {
TestC.run("newtonFloat",result);
}
- @Test
- public void testString() throws IOException {
- String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/stringHash.smp"));
- testCPU(src,"x86_64_v2", "SystemV", 9,null);
- testCPU(src,"riscv" , "SystemV", 5,null);
- testCPU(src,"arm" , "SystemV", 6,null);
- }
-
- @Test public void testStringExport() throws IOException { TestC.run("stringHash"); }
-
@Test public void testSieve() throws IOException {
// The primes
int[] primes = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, };
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/progs/jig.smp b/chapter21/src/test/java/com/seaofnodes/simple/progs/jig.smp
index 3d01f80f..64c15dd7 100644
--- a/chapter21/src/test/java/com/seaofnodes/simple/progs/jig.smp
+++ b/chapter21/src/test/java/com/seaofnodes/simple/progs/jig.smp
@@ -1,11 +1,2 @@
// -*- mode: java; -*-
-while(0) {
- int v0=0;
- while(1>>arg+0>>>0<=0) {
- v0=1+arg/0;
- while(1)
- if(0/--v0+arg) 0;
- v0=-21;
- }
-}
-while(0) {}
+val allocIA = { int N -> return new u32[N]; };