Extend subtask stdlib for file, function, and foreign concurrency.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-07 09:41:22 +08:00
1 parent 63e5be80ab
commit 3da7b276d3
11 files changed
+574 -78

No files matched your search

+14
View File
@@ -652,6 +652,20 @@ fn lib_subtask_spawn() {
assert_out("tests/lib/subtask-spawn.mq.md", "done");
}
#[test]
fn lib_subtask_fn() {
assert_out("tests/lib/subtask-fn.mq.md", "42");
}
#[test]
fn lib_subtask_foreign() {
if !python_available() {
eprintln!("skip lib_subtask_foreign: no python on PATH");
return;
}
assert_out("tests/lib/subtask-foreign.mq.md", "15");
}
#[test]
fn lib_json_quote() {
assert_out("tests/lib/json-quote.mq.md", "\"hi\"");
+22
View File
@@ -0,0 +1,22 @@
---
title: subtask spawn fn
> lib/subtask.mq.md
> lib/json.mq.md
---
# main
*`args` = > parse text={"n":21} *
*`id` = > spawn fn=worker args=`args` *
*`v` = > wait id=`id` *
> print text=`v`
---
## worker
+ `n`
**`n` * 2**
+17
View File
@@ -0,0 +1,17 @@
---
title: subtask foreign spawn
> lib/subtask.mq.md
---
# main
`py` =
```python
print(7 + 8)
```
*`id` = > spawn code=`py` *
*`out` = > wait id=`id` *
> print text=`out`