diff options
| author | Cliff Click <cliffc@acm.org> | 2025-05-06 13:44:10 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-07-08 20:29:09 -0700 |
| commit | 664761624f4b0e3d6d1593b99e576854beec5949 (patch) | |
| tree | edff0e36e07cdc5aa82c8f7d144d68c52d5a4365 /src/test/java/com/seaofnodes/simple/Chapter15Test.java | |
| parent | 018379b0cf4e286ceacb1e39f34dd80f770e381e (diff) | |
| download | Simple-linear-chapter23.tar.gz Simple-linear-chapter23.zip | |
Chapter 23: Methods and Revisiting Typeslinear-chapter23
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter15Test.java')
| -rw-r--r-- | src/test/java/com/seaofnodes/simple/Chapter15Test.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter15Test.java b/src/test/java/com/seaofnodes/simple/Chapter15Test.java index a98e62d8..6ba4e2b1 100644 --- a/src/test/java/com/seaofnodes/simple/Chapter15Test.java +++ b/src/test/java/com/seaofnodes/simple/Chapter15Test.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import org.junit.Test; +import org.junit.Ignore; import static org.junit.Assert.*; public class Chapter15Test { @@ -49,7 +50,7 @@ output[i] = 1; return output; """); code.parse().opto(); - assertEquals("return [u8];", code.print()); + assertEquals("return []u8;", code.print()); assertEquals("\u0001", Eval2.eval(code, 0)); } @@ -101,8 +102,8 @@ A?[] !a = new A?[2]; return a; """); code.parse().opto(); - assertEquals("return [*A?];", code.print()); - assertEquals("*A {int !i; }?[ null,null]", Eval2.eval(code, 0)); + assertEquals("return []*A?;", code.print()); + assertEquals("*A {i64 !i; }?[ null,null]", Eval2.eval(code, 0)); } @Test @@ -174,7 +175,7 @@ return root; """); code.parse().opto(); assertEquals("return Tree;", code.print()); - assertEquals("Tree{_kids=*Tree?[ Tree{_kids=null},null]}", Eval2.eval(code, 0)); + assertEquals("Tree{_kids=*Tree {*[]*Tree?? !_kids; }?[ Tree{_kids=null},null]}", Eval2.eval(code, 0)); } @Test @@ -212,12 +213,12 @@ return ary[1] * 1000 + ary[3]; // 1 * 1000 + 6 assertEquals("1006", Eval2.eval(code, 4)); } - @Test + @Test @Ignore public void sieveOEratosthenes() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/sieve.smp")); CodeGen code = new CodeGen(src+"return sieve(arg);"); code.parse().opto(); - assertEquals("return [u32];", code.print()); + assertEquals("return []u32;", code.print()); assertEquals("u32[ 2,3,5,7,11,13,17,19]",Eval2.eval(code, 20)); } @@ -254,9 +255,10 @@ return new flt; CodeGen code = new CodeGen( """ flt is = new int[2]; +return is; """); - try { code.parse().opto(); fail(); } - catch( Exception e ) { assertEquals("Type *[int] is not of declared type flt",e.getMessage()); } + try { code.parse().opto().typeCheck(); fail(); } + catch( Exception e ) { assertEquals("Type *[]i64 is not of declared type flt",e.getMessage()); } } @Test |
