diff options
| author | Cliff Click <cliffc@acm.org> | 2026-07-03 14:14:43 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-07-03 14:14:43 -0700 |
| commit | aa31b718eb0643bd0aaec3487384c396f9ebe975 (patch) | |
| tree | 532a2fa1b499bce5f66e57e5496bc31991d3be0b /chapter24/src/test | |
| parent | 5b04bd29ca5dbbaf55786c03ef0d38b41eef579b (diff) | |
| download | Simple-aa31b718eb0643bd0aaec3487384c396f9ebe975.tar.gz Simple-aa31b718eb0643bd0aaec3487384c396f9ebe975.zip | |
Series of minor fixes
Diffstat (limited to 'chapter24/src/test')
| -rw-r--r-- | chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java | 37 | ||||
| -rw-r--r-- | chapter24/src/test/java/com/seaofnodes/simple/Simple.java | 7 |
2 files changed, 22 insertions, 22 deletions
diff --git a/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java b/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java index 9e230bcd..78b9e7a1 100644 --- a/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java +++ b/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java @@ -16,24 +16,23 @@ public class Chapter22Test { @Test public void testJig() throws IOException { String src = - """ - struct s0 { - bool v1; - i16 v2; - int v3; - i8 v4; - byte v5; - }; - while(new s0.v3) - while(new s0.v5<<new s0.v4) {} - if(0) { - if(0) { - flt !P5ZUD4=new s0.v2; - } - while(0) {} - } - return new s0.v1; - """; +""" +val fib = {int n -> + int temp=0; + int f1=1; + int f2=1; + int i=n; + while( i>1 ){ + temp = f1+f2; + f1=f2; + f2=temp; + i=i-1; + } + return f2; +}; + +fib(10); +"""; testCPU(src,"x86_64_v2", "Win64" ,-1,null); testCPU(src,"riscv" , "SystemV",-1,null); testCPU(src,"arm" , "SystemV",-1,null); @@ -138,7 +137,7 @@ struct Person { val fcn = { Person?[] ps, int x -> if( ps[x] ) ps[x].age++; -}; +}; """; String person = "6\n"; TestC.run(src, "person", null, person, 0); diff --git a/chapter24/src/test/java/com/seaofnodes/simple/Simple.java b/chapter24/src/test/java/com/seaofnodes/simple/Simple.java index 8b275389..be582a64 100644 --- a/chapter24/src/test/java/com/seaofnodes/simple/Simple.java +++ b/chapter24/src/test/java/com/seaofnodes/simple/Simple.java @@ -143,9 +143,10 @@ Options: System.out.printf( "TOTAL COMPILATION TIME: %.3f sec%n", total); } - static String getInput() { - BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - return reader.lines().collect(Collectors.joining("\n")); + static String getInput() throws IOException { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) { + return reader.lines().collect(Collectors.joining("\n")); + } } public static void main(String[] args) throws Exception { |
