diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-08 14:10:02 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-08 14:10:02 -0800 |
| commit | 06fb5aceeb65a75b1cd643debd667c52fdcafcb9 (patch) | |
| tree | c99813eaf27d98f840245302c4d6e923c964307e /chapter30/src/test/java/com/seaofnodes/simple/RuntimeArgsTest.java | |
| parent | 6560a92433a38825fd1d44d9c66ffba9f26990ff (diff) | |
| download | Simple-ch30.tar.gz Simple-ch30.zip | |
Better error messagesch30
Better error messages.
Buffs to the std lib; getch() to fetch a single character; streaming I/O handles retries, and large sizes, with better error reporting.
Formatted strings.
Default int moved to i32.
TicTacToe, the game.
Diffstat (limited to 'chapter30/src/test/java/com/seaofnodes/simple/RuntimeArgsTest.java')
| -rw-r--r-- | chapter30/src/test/java/com/seaofnodes/simple/RuntimeArgsTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/chapter30/src/test/java/com/seaofnodes/simple/RuntimeArgsTest.java b/chapter30/src/test/java/com/seaofnodes/simple/RuntimeArgsTest.java new file mode 100644 index 00000000..9086e00c --- /dev/null +++ b/chapter30/src/test/java/com/seaofnodes/simple/RuntimeArgsTest.java @@ -0,0 +1,29 @@ +package com.seaofnodes.simple; + +import java.io.IOException; +import org.junit.Test; +import static org.junit.Assert.*; + +public class RuntimeArgsTest extends TestC { + @Test public void testNativeArguments() throws IOException { + runArgs(""" + val main={ u8[~][] args -> + if(args#!=4 || args[0]#==0) return 1; + if(args[1]#!=0) return 2; + val words=args[2]; + if(words#!=9 || words[3]!=' ' || words[8]!='s') return 3; + val longArg=args[3]; + if(longArg#!=4096) return 4; + for(int i=0; i<longArg#; i++) if(longArg[i]!='x') return 5; + return 0; + }; + ""","runtimeArgs",null,CALL_CONVENTION,"",-1,"","two words","x".repeat(4096)); + } + + @Test public void testArgumentCopiesAndEmptyVector() throws IOException { + String exe="build/objs/runtimeArgsCopy"+(OS.startsWith("Windows") ? ".exe" : ""); + linkExe(runtimeObject("simple_args"),OS.startsWith("Windows") ? "ms_abi" : "sysv_abi", + C_DRIVERS_DIR+"runtime_args.c",null,exe); + assertEquals("ok\n",exec(TEST_TIMEOUT_SECONDS,exe)); + } +} |
