lean4-htt/tests/lean/run/task_test_io.lean
Sebastian Ullrich 5f7a40ae48
chore: fix test exclusion (#5990)
You cannot pass `-E` to `ctest` multiple times
2024-11-07 10:41:47 +00:00

37 lines
926 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#exit -- TODO
#eval id (α := IO _) do
let t1 ← IO.asTask $ Nat.forM 10 fun _ => IO.println "hi";
let t2 ← IO.asTask $ Nat.forM 10 fun _ => IO.println "ho";
IO.ofExcept t1.get
#eval id (α := IO _) do
let t1 ← IO.mapTask IO.println (Task.spawn fun _ => "ha");
pure ()
#eval id (α := IO _) do
let t1 ← IO.bindTask (Task.spawn fun _ => "hu") fun s =>
IO.asTask (IO.println s);
pure ()
#eval id (α := IO _) do
let t1 ← IO.asTask do {
let c ← IO.checkCanceled;
IO.println (if c then "canceled!" else "done!")
};
pure ()
#eval id (α := IO _) do
let t1 ← IO.asTask do {
let c ← IO.checkCanceled;
IO.println (if c then "canceled! 2" else "done! 2")
};
IO.cancel t1;
discard $ IO.wait t1;
pure ()
#eval IO.waitAny [
Task.spawn fun _ => dbgSleep 2 fun _ => "A",
Task.spawn fun _ => dbgSleep 3 fun _ => "B",
Task.spawn fun _ => dbgSleep 1 fun _ => "C"
]