diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-15 16:11:39 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-15 16:11:39 -0800 |
| commit | 9fe7c6f9697b5bbf3041261fdc60040e75cc674f (patch) | |
| tree | d92a8ff20ed984938d90ad8917b4d67fba9fb745 /chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java | |
| parent | f0a6c6757a795b8e186de0076836a87acef59fa7 (diff) | |
| download | Simple-ch32.tar.gz Simple-ch32.zip | |
Split off chapter 31ch32
Ch 32 will be focused on compiler performance issues.
Diffstat (limited to 'chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java')
| -rw-r--r-- | chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java b/chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java new file mode 100644 index 00000000..dbbe353a --- /dev/null +++ b/chapter32/src/test/java/com/seaofnodes/simple/FloatNegationNativeTest.java @@ -0,0 +1,21 @@ +package com.seaofnodes.simple; + +import org.junit.Test; + +public class FloatNegationNativeTest extends TestC { + @Test public void negateRuntimeValues() throws Exception { + // Keep negation out of constant folding, including both signs of zero. + runSYS(""" + val neg_noInline={f64 x -> -x;}; + val main={ -> + if( neg_noInline(2.5)!=-2.5 || neg_noInline(-3.75)!=3.75 ) return 1; + if( 1.0/neg_noInline(0.0)!=-1e300*1e300 ) return 2; + if( 1.0/neg_noInline(-0.0)!=1e300*1e300 ) return 3; + if( neg_noInline(1e300*1e300)!=-1e300*1e300 ) return 4; + f64 nan=neg_noInline(1e300*1e300-1e300*1e300); + if( nan==nan ) return 5; + return 0; + }; + ""","floatNegation","",-1); + } +} |
