factor/library/test/continuations.factor

31 lines
598 B
Factor
Raw Normal View History

2004-07-16 02:26:21 -04:00
IN: scratchpad
USE: arithmetic
USE: combinators
USE: continuations
USE: kernel
USE: lists
USE: namespaces
USE: stack
USE: stdio
USE: test
: callcc1-test ( x -- list )
[
"test-cc" set [ ] [
swap pred tuck swons
over 0 = [ "test-cc" get call ] when
] forever
] callcc1 nip ;
: callcc-namespace-test ( -- ? )
[
"test-cc" set
5 "x" set
<namespace> [
6 "x" set "test-cc" get call
] bind
] 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