From: Christopher Allan Webber Date: Sun, 22 Nov 2015 03:34:16 +0000 (-0600) Subject: first delimited continuation test X-Git-Tag: v0.1.0~116 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=06111cedb79268f25fefd62e73ddb1651a66f04b;p=8sync.git first delimited continuation test --- diff --git a/tests.scm b/tests.scm index e438fc7..d56b4f2 100644 --- a/tests.scm +++ b/tests.scm @@ -246,6 +246,29 @@ (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")