Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
32 lines
1.1 KiB
Plaintext
32 lines
1.1 KiB
Plaintext
// Real OS-argv accessor from `modules/std/cli.sx` (extern _NSGetArgv).
|
|
//
|
|
// Only DETERMINISTIC structural invariants are asserted — the actual arg
|
|
// contents depend on how the test is invoked (under `sx run` the process
|
|
// argv is the interpreter's: ["sx", "run", "<this file>"]), so we never
|
|
// pin exact strings:
|
|
// - argc >= 1 (every process has argv[0])
|
|
// - argv[0] is non-empty (the executable path)
|
|
// - os_argc() agrees with the filled slice length (no truncation)
|
|
//
|
|
// `buf` is a stack `[64]string`; `os_args` fills it with zero-copy views
|
|
// over the C runtime's argv block — no heap, no per-arg allocation.
|
|
|
|
#import "modules/std.sx";
|
|
#import "modules/std/cli.sx";
|
|
|
|
main :: () {
|
|
buf : [64]string = ---;
|
|
args := os_args(buf[0..64]);
|
|
|
|
if args.len >= 1 { print("argc>=1: ok\n"); }
|
|
else { print("argc>=1: FAIL ({})\n", args.len); }
|
|
|
|
if args.len >= 1 {
|
|
if args[0].len > 0 { print("arg0-nonempty: ok\n"); }
|
|
else { print("arg0-nonempty: FAIL\n"); }
|
|
}
|
|
|
|
if os_argc() == args.len { print("argc-consistent: ok\n"); }
|
|
else { print("argc-consistent: FAIL (os_argc={} len={})\n", os_argc(), args.len); }
|
|
}
|