1 ! Copyright (C) 2005 Chris Double, 2007 Clemens Hofreither, 2008 James Cash.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: coroutines kernel sequences prettyprint tools.test math ;
7 [ drop 1 coyield* 2 coyield* 3 coterminate ] cocreate ;
10 [ 1+ coyield* ] cocreate ;
12 test1 dup *coresume . dup *coresume . dup *coresume . dup *coresume 2drop
13 [ test2 42 over coresume . dup *coresume . drop ] must-fail
14 { 43 } [ 42 test2 coresume ] unit-test
17 [ [ coyield* ] each ] cocreate ;
19 { "c" "b" "a" } [ test3 { "a" "b" "c" } over coresume [ dup *coresume [ *coresume ] dip ] dip ] unit-test
21 { 4+2/3 } [ [ 1+ coyield 2 * coyield 3 / coreset ] cocreate 1 5 [ over coresume ] times nip ] unit-test