first delimited continuation test
[8sync.git] / tests.scm
index e438fc70836997b44457f8f72637d3478418b987..d56b4f2af73dbaddbf33584e75f3f09e043b0db2 100644 (file)
--- a/tests.scm
+++ b/tests.scm
   (test-equal (speaker)
     '("I bet I can make you say you're a dummy!\n")))
 
+;; delimited continuation tests
+
+(define (return-monkey)
+  (speaker "(Hint, it's a monkey...)\n")
+  'monkey)
+
+(define (talk-about-the-zoo)
+  (speaker "Today I went to the zoo and I saw...\n")
+  (speaker
+   (string-concatenate
+    `("A " ,(symbol->string (%sync (%run (return-monkey)))) "!\n"))))
+
+(let ((q (make-q)))
+  (set! speaker (speak-it))
+  (enq! q talk-about-the-zoo)
+  ;; (enq! q talk-about-the-zoo-but-wait)
+  (start-agenda (make-agenda #:queue q)
+                #:stop-condition (true-after-n-times 10))
+  (test-equal (speaker)
+              '("Today I went to the zoo and I saw...\n"
+                "(Hint, it's a monkey...)\n"
+                "A monkey!\n")))
+
 ;; End tests
 
 (test-end "tests")