[uim-commit] r1707 - branches/r5rs/sigscheme/test
yamaken at freedesktop.org
yamaken at freedesktop.org
Fri Sep 30 15:22:28 PDT 2005
Author: yamaken
Date: 2005-09-30 15:22:25 -0700 (Fri, 30 Sep 2005)
New Revision: 1707
Modified:
branches/r5rs/sigscheme/test/test-continuation.scm
branches/r5rs/sigscheme/test/test-tail-rec.scm
Log:
* sigscheme/test/test-tail-rec.scm
* sigscheme/test/test-continuation.scm
- Add some tests for call/cc
Modified: branches/r5rs/sigscheme/test/test-continuation.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-continuation.scm 2005-09-30 18:39:38 UTC (rev 1706)
+++ branches/r5rs/sigscheme/test/test-continuation.scm 2005-09-30 22:22:25 UTC (rev 1707)
@@ -1,5 +1,7 @@
(load "test/unittest.scm")
+(define call/cc call-with-current-continuation)
+
(assert-equal? "call/cc test1" -3 (call-with-current-continuation
(lambda (exit)
(for-each (lambda (x)
@@ -24,4 +26,13 @@
(assert-equal? "call/cc test2" 4 (list-length '(1 2 3 4)))
(assert-equal? "call/cc test3" #f (list-length '(a b . c)))
+;; function written in C as proc
+(assert-true "call/cc #4" (call/cc procedure?))
+
+;; another continuation as proc
+(assert-true "call/cc #5" (procedure? (call/cc (lambda (c) (call/cc c)))))
+(call/cc (lambda (c) (call/cc c)))
+(call/cc (lambda (c) c))
+(call/cc (lambda (c) (c 1)))
+
(total-report)
Modified: branches/r5rs/sigscheme/test/test-tail-rec.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-tail-rec.scm 2005-09-30 18:39:38 UTC (rev 1706)
+++ branches/r5rs/sigscheme/test/test-tail-rec.scm 2005-09-30 22:22:25 UTC (rev 1707)
@@ -663,6 +663,14 @@
(dummy2 (lambda () dummy)))
(rec-even-with-letrec? (- n 1))))))
+(define rec-continuation
+ (lambda (n)
+ (if (zero? n)
+ 'succeeded
+ (call-with-current-continuation
+ (lambda (cont)
+ (rec-continuation (- n 1)))))))
+
(define rec-proper-infinite
(lambda (cnt)
(rec-proper-infinite (+ cnt 1))))
@@ -942,7 +950,15 @@
(dummy2 (+ 3 4)))
(loop (- cnt 1))))))
+;; call/cc
+;; SigScheme cannot run this test as proper tail recursion. The stack will
+;; grown.
+;;(assert-equal? "proper tail recursion by call/cc"
+;; 'succeeded
+;; (rec-continuation explosive-count))
+
+
;; This test is succeeded if [OK]-exploded message sequence has been
;; printed as follows.
;;
More information about the uim-commit
mailing list