From 514b3147bf08817d17aacc492be255621209ec8b Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Wed, 7 Oct 2026 12:37:06 -0700 Subject: RoundF32 actually rounds --- .../java/com/seaofnodes/simple/Chapter18Test.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'chapter18/src/test/java') diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java index c4d5b9ac..0758fbf5 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java @@ -9,6 +9,33 @@ import static org.junit.Assert.fail; import org.junit.Ignore; public class Chapter18Test { + @Test public void testFloatArrays() { + for( String type : new String[]{"flt","f64","f32"} ) { + CodeGen zero = new CodeGen("var a = new "+type+"[arg]; return a[arg-1];") + .parse().opto().typeCheck(); + assertEquals("0.0",Eval2.eval(zero,3)); + // Eval2 does not execute RoundF32 yet; check nonconstant narrowing here. + new CodeGen(type+" x = arg; var a = new "+type+"[arg]; a[0] = x; return a[0];") + .parse().opto().typeCheck(); + } + for( String type : new String[]{"flt","f64"} ) { + CodeGen loop = new CodeGen("var a = new "+type+"[arg]; "+ + "for(int i=0; i