aboutsummaryrefslogtreecommitdiff
path: root/tests/threads/accept
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 08:29:46 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 08:29:46 +0330
commit1c53304d03414890af0da7432d1aea87e754a14a (patch)
tree97190d86cf548c9bc63f68c86a4d2a4f09809713 /tests/threads/accept
parenta (diff)
feat: grow memory limits, add icon/actor libraries, overhaul LSP diagnostics
Compiler and VM - make every memory map limit dynamic and adjustable at both build time and runtime, including compiler tables, stacks, and every execution region - reserve and grow tables, operand and return stacks, frame segments, and image-building output without relocating live code or globals - rename i/o and string helpers consistently (puts -> put_s, putn -> put_n, scat -> cat_s) across compiler, runtime, examples, tests, and docs - recast and consume values assigned to globals from inside functions - allow fixed and const together, add typed closure returns (fn:t(...)), multi-include syntax (include rt, run, core;), and recurse type inference - never infer string literals as word, anywhere, as argument, variable, or return type - draft docs/BORROW.md: a borrow checker less intrusive than Rust's but more intelligent LSP and editor integration - require explicit includes and give every toolchain area its own namespace (rt, lsp, run, core) - hover for built-in types, inferred types, values known at hover time, array and pointer lifetime/size, library names in include statements, and inferred lifetimes with explanations - honor /* */ comments as documentation for variables and arguments, and stop misattributing section headers or trailing comments as variable hints - stream diagnostics and cancel stale requests on change - jump to definition and references, including cross-file - quick fixes with automatic library import, and namespace completion Hints and diagnostics - render hints as blue squigglies by default, with hints on/small/off per file - suppress magic-number hints via a preceding /* */ comment, and say so - warn on unused arguments; allow multiple _ discards in parameters, pattern matching, and tagged enums, warning if a _ is actually used - rewrite hint and comment prose in professional compiler-doc register Libraries - add icon.zc: run-time self-modification, find/replace syntax, type and block edits, and step-through inspection of locals and globals - add actor.zc: async actors with Actor<I,O>, implicit this, spawn/recv/send, injected into the compiler machinery at include time rather than built in Tooling and docs - reorganize sources, tests, and designs into subdirectories - unify windows entry points in tinyvm.bat and add a matching tinyvm.sh - add --help across the toolchain - polish the learning guide, stdlib docs, and design notes Tests - add accept, reject, and regression coverage across the compiler, LSP, - runtime, icon, actors, threads, formatting, and the toolchain contracts, plus fuzzers and property tests
Diffstat (limited to 'tests/threads/accept')
-rw-r--r--tests/threads/accept/actor_identity.zc10
-rw-r--r--tests/threads/accept/cancel.zc8
-rw-r--r--tests/threads/accept/cancel_o3.zc9
-rw-r--r--tests/threads/accept/channels.zc9
-rw-r--r--tests/threads/accept/close_order.zc10
-rw-r--r--tests/threads/accept/failed_worker.zc9
-rw-r--r--tests/threads/accept/isolation.zc17
-rw-r--r--tests/threads/accept/nested.zc15
-rw-r--r--tests/threads/accept/parallel.zc11
9 files changed, 98 insertions, 0 deletions
diff --git a/tests/threads/accept/actor_identity.zc b/tests/threads/accept/actor_identity.zc
new file mode 100644
index 0000000..cf2d4bf
--- /dev/null
+++ b/tests/threads/accept/actor_identity.zc
@@ -0,0 +1,10 @@
+namespace;
+include rt, actor;
+typecheck on;
+fn main() {
+ let process = rt.syscall(53, 0, 0, 0), thread = rt.syscall(54, 0, 0, 0), result = 0;
+ actor.Actor<int,int>* a = rt.new(actor.Actor<int,int>);
+ a.spawn(fn(int n) { return rt.syscall(53, 0, 0, 0) == process && rt.syscall(54, 0, 0, 0) != thread; });
+ a.recv(fn(int n) { result = n; return 0; }); a.send(1); a.await();
+ rt.put_n(result); rt.put_c(10); a.close(); return 0;
+}
diff --git a/tests/threads/accept/cancel.zc b/tests/threads/accept/cancel.zc
new file mode 100644
index 0000000..db4f7c7
--- /dev/null
+++ b/tests/threads/accept/cancel.zc
@@ -0,0 +1,8 @@
+namespace;
+include rt;
+unchecked fn main() {
+ int fd = 0;
+ let context = rt.syscall(51, fn() { while (1) {} return 0; } as word, &fd, 0);
+ rt.syscall(48, 20, 0, 0); let started = rt.syscall(50, 0, 0, 0);
+ rt.put_n(rt.syscall(52, context, 1, 0)); rt.put_c(10); rt.put_n(rt.syscall(50, 0, 0, 0) - started); rt.put_c(10); return 0;
+}
diff --git a/tests/threads/accept/cancel_o3.zc b/tests/threads/accept/cancel_o3.zc
new file mode 100644
index 0000000..e196a13
--- /dev/null
+++ b/tests/threads/accept/cancel_o3.zc
@@ -0,0 +1,9 @@
+namespace;
+include rt;
+o3 int spin() { int n = 0; while (1) n++; return n; }
+unchecked fn main() {
+ int fd = 0;
+ let context = rt.syscall(51, fn() { return spin(); } as word, &fd, 0);
+ rt.syscall(48, 20, 0, 0); let started = rt.syscall(50, 0, 0, 0);
+ rt.put_n(rt.syscall(52, context, 1, 0)); rt.put_c(10); rt.put_n(rt.syscall(50, 0, 0, 0) - started); rt.put_c(10); return 0;
+}
diff --git a/tests/threads/accept/channels.zc b/tests/threads/accept/channels.zc
new file mode 100644
index 0000000..e1e966f
--- /dev/null
+++ b/tests/threads/accept/channels.zc
@@ -0,0 +1,9 @@
+namespace;
+include rt;
+unchecked fn main() {
+ int first_fd = 0, second_fd = 0;
+ let first = rt.syscall(51, fn() { int value; rt.syscall(45, first_fd, &value, 1); return 0; } as word, &first_fd, 0);
+ let second = rt.syscall(51, fn() { int value = 9; int result = rt.syscall(44, first_fd, &value, 1); rt.syscall(44, second_fd, &result, 1); return 0; } as word, &second_fd, 0);
+ int result; rt.syscall(45, second_fd, &result, 1); rt.syscall(52, second, 0, 0);
+ rt.put_n(result); rt.put_c(' '); rt.put_n(rt.syscall(52, first, 1, 0)); rt.put_c(10); return 0;
+}
diff --git a/tests/threads/accept/close_order.zc b/tests/threads/accept/close_order.zc
new file mode 100644
index 0000000..5c0949f
--- /dev/null
+++ b/tests/threads/accept/close_order.zc
@@ -0,0 +1,10 @@
+namespace;
+include rt;
+unchecked fn main() {
+ int fd = 0;
+ let first = rt.syscall(51, fn() { rt.syscall(2, fd, 0, 0); return 0; } as word, &fd, 0);
+ rt.put_n(rt.syscall(52, first, 0, 0)); rt.put_c(' ');
+ let second = rt.syscall(51, fn() { int value; rt.syscall(45, fd, &value, 1); return 0; } as word, &fd, 0);
+ rt.syscall(2, fd, 0, 0); rt.put_n(rt.syscall(52, second, 1, 0)); rt.put_c(' ');
+ rt.put_n(rt.syscall(52, second, 1, 0)); rt.put_c(10); return 0;
+}
diff --git a/tests/threads/accept/failed_worker.zc b/tests/threads/accept/failed_worker.zc
new file mode 100644
index 0000000..b214cac
--- /dev/null
+++ b/tests/threads/accept/failed_worker.zc
@@ -0,0 +1,9 @@
+namespace;
+include rt;
+unchecked fn main() {
+ int fd = 0;
+ let first = rt.syscall(51, fn() { rt.syscall(7, 5, 0, 0); return 0; } as word, &fd, 0);
+ rt.put_n(rt.syscall(52, first, 0, 0)); rt.put_c(' ');
+ let second = rt.syscall(51, fn() { int value = 7; rt.syscall(44, fd, &value, 1); return 0; } as word, &fd, 0);
+ int result; rt.syscall(45, fd, &result, 1); rt.syscall(52, second, 0, 0); rt.put_n(result); rt.put_c(10); return 0;
+}
diff --git a/tests/threads/accept/isolation.zc b/tests/threads/accept/isolation.zc
new file mode 100644
index 0000000..cb1a5e7
--- /dev/null
+++ b/tests/threads/accept/isolation.zc
@@ -0,0 +1,17 @@
+namespace;
+include rt;
+int global_state = 16;
+unchecked fn main() {
+ int fd = 0, state = 7; word heap = rt.new(1); heap[0] = 4;
+ let parent_process = rt.syscall(53, 0, 0, 0), parent_thread = rt.syscall(54, 0, 0, 0);
+ let callback = fn() {
+ global_state += 5; state += 9; heap[0] += 3;
+ int reply[5]; reply[0] = global_state; reply[1] = state; reply[2] = heap[0]; reply[3] = rt.syscall(53, 0, 0, 0); reply[4] = rt.syscall(54, 0, 0, 0);
+ rt.syscall(44, fd, reply, 5); return 0;
+ };
+ let context = rt.syscall(51, callback as word, &fd, 0);
+ int result[5]; rt.syscall(45, fd, result, 5); rt.syscall(52, context, 0, 0);
+ rt.put_n(result[0]); rt.put_c(' '); rt.put_n(result[1]); rt.put_c(' '); rt.put_n(result[2]); rt.put_c(' ');
+ rt.put_n(global_state); rt.put_c(' '); rt.put_n(state); rt.put_c(' '); rt.put_n(heap[0]); rt.put_c(' ');
+ rt.put_n(result[3] == parent_process); rt.put_c(' '); rt.put_n(result[4] != parent_thread); rt.put_c(10); return 0;
+}
diff --git a/tests/threads/accept/nested.zc b/tests/threads/accept/nested.zc
new file mode 100644
index 0000000..e231aad
--- /dev/null
+++ b/tests/threads/accept/nested.zc
@@ -0,0 +1,15 @@
+namespace;
+include rt;
+unchecked fn main() {
+ int fd = 0;
+ let worker = rt.syscall(51, fn() {
+ int child_fd = 0;
+ let run_child = fn() { while (1) {} return 0; };
+ let child = rt.syscall(51, run_child as word, &child_fd, 0);
+ int reply = child > 0; rt.syscall(44, fd, &reply, 1);
+ while (1) {} return 0;
+ } as word, &fd, 0);
+ int result; rt.syscall(45, fd, &result, 1); rt.syscall(52, worker, 1, 0);
+ rt.put_n(result); rt.put_c(' '); rt.put_n(rt.syscall(55, 0, 0, 0)); rt.put_c(' ');
+ rt.put_n(rt.syscall(55, 1, 0, 0)); rt.put_c(' '); rt.put_n(rt.syscall(55, 2, 0, 0)); rt.put_c(10); return 0;
+}
diff --git a/tests/threads/accept/parallel.zc b/tests/threads/accept/parallel.zc
new file mode 100644
index 0000000..567f829
--- /dev/null
+++ b/tests/threads/accept/parallel.zc
@@ -0,0 +1,11 @@
+namespace;
+include rt;
+unchecked fn main() {
+ int left_fd = 0, right_fd = 0;
+ let started = rt.syscall(50, 0, 0, 0);
+ let left = rt.syscall(51, fn() { int value = 11; rt.syscall(48, 300, 0, 0); rt.syscall(44, left_fd, &value, 1); return 0; } as word, &left_fd, 0);
+ let right = rt.syscall(51, fn() { int value = 21; rt.syscall(48, 300, 0, 0); rt.syscall(44, right_fd, &value, 1); return 0; } as word, &right_fd, 0);
+ int a, b; rt.syscall(45, left_fd, &a, 1); rt.syscall(45, right_fd, &b, 1);
+ rt.put_n(a); rt.put_c(' '); rt.put_n(b); rt.put_c(10); rt.put_n(rt.syscall(50, 0, 0, 0) - started); rt.put_c(10);
+ rt.syscall(52, left, 0, 0); rt.syscall(52, right, 0, 0); return 0;
+}