1 USING: namespaces io tools.test threads kernel
2 concurrency.combinators concurrency.promises locals math
7 [ 2 "x" set ] "Test" spawn drop
8 [ 2 ] [ yield "x" get ] unit-test
9 [ ] [ [ flush ] "flush test" spawn drop flush ] unit-test
10 [ ] [ [ "Errors, errors" throw ] "error test" spawn drop ] unit-test
13 [ ] [ 0.3 sleep ] unit-test
14 [ "hey" sleep ] must-fail
17 [ 3 swap resume-with ] "Test suspend" suspend
20 [ f ] [ f get-global ] unit-test
22 { { 0 3 6 9 12 15 18 21 24 27 } } [
26 "i" [ yield 3 + ] tchange
32 [ [ 3 throw ] "A" suspend ] [ 3 = ] must-fail-with
34 :: spawn-namespace-test ( -- )
35 [let | p [ <promise> ] g [ gensym ] |
38 [ "x" get p fulfill ] "B" spawn drop
43 [ t ] [ spawn-namespace-test ] unit-test
45 [ "a" [ 1 1 + ] spawn 100 sleep ] must-fail