From 658289861e8d971cd9e449e66a749c9c2d65f623 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 10 Aug 2026 11:11:18 -0700 Subject: Chapter 31: Software Drawing, Time, and Graphical Games Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: Symious <14933944+symious@users.noreply.github.com> Co-authored-by: Jun Kawasaki Co-authored-by: Claude Opus 5 --- .../java/com/seaofnodes/simple/SchedulingTest.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/test/java/com/seaofnodes/simple/SchedulingTest.java (limited to 'src/test/java/com/seaofnodes/simple/SchedulingTest.java') diff --git a/src/test/java/com/seaofnodes/simple/SchedulingTest.java b/src/test/java/com/seaofnodes/simple/SchedulingTest.java new file mode 100644 index 00000000..16e12b0f --- /dev/null +++ b/src/test/java/com/seaofnodes/simple/SchedulingTest.java @@ -0,0 +1,47 @@ +package com.seaofnodes.simple; + +import org.junit.Test; + +public class SchedulingTest { + @Test public void nativeFoldedLoadsWithLaterOperands() throws Exception { + TestC.runSYS(""" + val compare_noInline={ i64[] a, int flag -> + i64 x=a[0]; + i64 y=flag ? a[1] : a[2]; + return x==y; + }; + val add_noInline={ i64[] a, int flag -> + i64 x=a[0]; + i64 y=flag ? a[1] : a[2]; + return x+y; + }; + val main={ -> + val a=new i64[3]; a[0]=17; a[1]=17; a[2]=23; + if(!compare_noInline(a,1) || compare_noInline(a,0)) return 1; + if(add_noInline(a,1)!=34 || add_noInline(a,0)!=40) return 2; + return 0; + }; + ""","scheduleLaterOperands","",-1); + } + + @Test public void nativeLoadsAcrossWrites() throws Exception { + TestC.runSYS(""" + val change_noInline={ i64[] a -> a[0]=a[1]; return a[0]; }; + val compare_noInline={ i64[] a -> + i64 x=a[0]; + return x==change_noInline(a); + }; + val add_noInline={ i64[] a -> + i64 x=a[0]; + return x+change_noInline(a); + }; + val main={ -> + val a=new i64[2]; a[0]=17; a[1]=23; + if(compare_noInline(a)) return 1; + a[0]=17; a[1]=29; + if(add_noInline(a)!=46) return 2; + return 0; + }; + ""","scheduleAcrossWrites","",-1); + } +} -- cgit v1.2.3