diff options
Diffstat (limited to 'chapter21/src/test/java/com')
| -rw-r--r-- | chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java index e2a79b8f..f3075a68 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java @@ -62,4 +62,22 @@ return sqrt(farg) + sqrt(farg+2.0); testCPU(src,"riscv" , "SystemV",17,null); testCPU(src,"arm" , "SystemV",18,null); } + + @Test + public void testArray1() { + String src = + """ + int[] !ary = new int[arg]; + // Fill [0,1,2,3,4,...] + for( int i=0; i<ary#; i++ ) + ary[i] = i; + // Fill [0,1,3,6,10,...] + for( int i=0; i<ary#-1; i++ ) + ary[i+1] += ary[i]; + return ary[1] * 1000 + ary[3]; // 1 * 1000 + 6 + """; + testCPU(src,"x86_64_v2", "SystemV",3,"return .[];"); + testCPU(src,"riscv" , "SystemV",1,"return (add,.[],(mul,.[],1000));"); + testCPU(src,"arm" , "SystemV",1,"return (add,.[],(muli,.[]));"); + } } |
