factor/library/test/continuations.factor

31 lines
603 B
Factor
Raw Normal View History

IN: temporary
2004-07-16 02:26:21 -04:00
USE: kernel
2004-08-26 22:21:17 -04:00
USE: math
2004-07-16 02:26:21 -04:00
USE: namespaces
USE: io
2004-07-16 02:26:21 -04:00
USE: test
2006-05-15 01:37:11 -04:00
USE: sequences
USE: vectors
2004-07-16 02:26:21 -04:00
: (callcc1-test)
2006-05-15 01:37:11 -04:00
swap 1- tuck swap ?push
2005-09-14 00:37:50 -04:00
over 0 = [ "test-cc" get continue-with ] when
(callcc1-test) ;
2004-07-16 02:26:21 -04:00
: callcc1-test ( x -- list )
[
2006-05-15 01:37:11 -04:00
"test-cc" set V{ } clone (callcc1-test)
2005-09-18 01:37:28 -04:00
] callcc1 nip ;
2004-07-16 02:26:21 -04:00
: callcc-namespace-test ( -- ? )
[
"test-cc" set
5 "x" set
[
2005-09-14 00:37:50 -04:00
6 "x" set "test-cc" get continue
] with-scope
2005-09-18 01:37:28 -04:00
] callcc0 "x" get 5 = ;
2004-07-16 02:26:21 -04:00
2006-05-15 01:37:11 -04:00
[ t ] [ 10 callcc1-test 10 reverse >vector = ] unit-test
2004-08-04 03:12:55 -04:00
[ t ] [ callcc-namespace-test ] unit-test