diff --git a/tests/tyield.nim b/tests/tyield.nim new file mode 100644 index 00000000..e75e3662 --- /dev/null +++ b/tests/tyield.nim @@ -0,0 +1,31 @@ +import std/os + +import cps +import cps/eventqueue + +const + start = 2 + tiny = 0 + big = start * 2 +var count = start + +proc higher(ms: int): Cont {.cps.} = + while count < big and count > tiny: + inc count + cps_sleep ms + cps_yield() + cps_yield() + cps_yield() + +proc lower(ms: int): Cont {.cps.} = + while count < big and count > tiny: + dec count + cps_sleep ms + cps_yield() + +trampoline higher(1) +trampoline lower(1) + +run() + +assert count == tiny diff --git a/tests/tyield.nim.cfg b/tests/tyield.nim.cfg new file mode 100644 index 00000000..f9f78b32 --- /dev/null +++ b/tests/tyield.nim.cfg @@ -0,0 +1,5 @@ +--path="$config/.." +--threads:on +--define:threadsafe +--gc:arc +--define:cpsDebug