slovo/docs/language/examples/formatter/host-io.slo
2026-05-22 08:38:43 +02:00

35 lines
792 B
Plaintext

(module main)
(fn fixture_path () -> string
"slovo-exp3-host-io.txt")
(fn write_fixture () -> i32
(std.fs.write_text (fixture_path) "host io"))
(fn read_fixture () -> string
(std.fs.read_text (fixture_path)))
(fn missing_env () -> string
(std.env.get "SLOVO_EXP3_MISSING"))
(fn arg_count_plus_one () -> i32
(+ (std.process.argc) 1))
(test "missing env returns empty string"
(= (missing_env) ""))
(test "argc is not negative"
(< 0 (arg_count_plus_one)))
(test "write text returns success"
(= (write_fixture) 0))
(test "read text returns written text"
(= (read_fixture) "host io"))
(fn main () -> i32
(std.io.eprint "exp-3 host io")
(std.io.print_string (std.process.arg 0))
(std.io.print_string (read_fixture))
(std.fs.write_text (fixture_path) "host io"))