summaryrefslogtreecommitdiff
path: root/lib/thread/test/do.myr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/thread/test/do.myr')
-rw-r--r--lib/thread/test/do.myr30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/thread/test/do.myr b/lib/thread/test/do.myr
new file mode 100644
index 0000000..e2e64e8
--- /dev/null
+++ b/lib/thread/test/do.myr
@@ -0,0 +1,30 @@
+use std
+use thread
+
+const main = {
+ match std.espork(["echo", "hello"][:])
+ | `std.Err e:
+ std.fatal("could not spork\n")
+ | `std.Ok (pid, in, out, err):
+ std.close(in)
+ var w = thread.do({;-> std.wait(pid)})
+ var o = thread.do({;-> std.fslurp(out)})
+ var e = thread.do({;-> std.fslurp(err)})
+
+ match thread.futget(w)
+ | `std.Wsuccess: /* ok */
+ | bad: std.fatal("bad wait: {}\n", bad)
+ ;;
+
+ match thread.futget(o)
+ | `std.Ok "hello\n": /* ok */
+ | bad: std.fatal("bad out: {}\n", bad)
+ ;;
+
+ match thread.futget(e)
+ | `std.Ok "": /* ok */
+ | bad: std.fatal("bad err: {}\n", bad)
+ ;;
+ ;;
+}
+