aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/args.zc
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/programs/args.zc
a
Diffstat (limited to 'tests/programs/args.zc')
-rw-r--r--tests/programs/args.zc16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/programs/args.zc b/tests/programs/args.zc
new file mode 100644
index 0000000..aac72ec
--- /dev/null
+++ b/tests/programs/args.zc
@@ -0,0 +1,16 @@
+// the command line and the environment, as the host hands them over. argv[0]
+// is the program path, and <eval> when the source came from stdin, so argc is
+// 1 even with nothing on the command line. run through a shell with no extra
+// arguments, which is how test.sh calls it, so the line is fixed.
+include "src/lib/std.zc";
+
+fn main() {
+ put_n(argc); put_c(32); put_s(argv[0]);
+ put_c(32); put_c(32); put_s(argv[argc - 1]);
+ // envc counts every entry, envp holds NAME=value strings
+ put_c(32); put_n(envc > 0);
+ let hit = 0;
+ for (int i = 0; i < envc; i++) if (eq_w(envp[i], "ZC_ARG_TEST=ok")) hit = 1;
+ put_c(32); put_n(hit);
+ return 0;
+} \ No newline at end of file