factor/library/test/continuations.factor

34 lines
696 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
[
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
2004-08-10 00:58:52 -04:00
! This caused the Java Factor to run out of memory
2004-08-10 01:38:49 -04:00
[ ] [ 100000 [ [ call ] callcc0 ] times ] unit-test