factor/library/test/continuations.factor

30 lines
555 B
Factor
Raw Normal View History

IN: temporary
2004-07-16 02:26:21 -04:00
USE: kernel
USE: lists
2004-08-26 22:21:17 -04:00
USE: math
2004-07-16 02:26:21 -04:00
USE: namespaces
USE: stdio
USE: test
: (callcc1-test)
swap 1 - tuck swons
over 0 = [ "test-cc" get call ] when
(callcc1-test) ;
2004-07-16 02:26:21 -04:00
: callcc1-test ( x -- list )
[
"test-cc" set [ ] (callcc1-test)
2004-07-16 02:26:21 -04:00
] callcc1 nip ;
: callcc-namespace-test ( -- ? )
[
"test-cc" set
5 "x" set
[
2004-07-16 02:26:21 -04:00
6 "x" set "test-cc" get call
] with-scope
2004-07-16 02:26:21 -04:00
] callcc0 "x" get 5 = ;
2004-08-04 03:12:55 -04:00
[ t ] [ 10 callcc1-test 10 count = ] unit-test
[ t ] [ callcc-namespace-test ] unit-test