From: Christopher Allan Webber Date: Thu, 19 Nov 2015 19:29:55 +0000 (-0600) Subject: agenda tests X-Git-Tag: v0.1.0~155 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=c46a7611c4db5d4c8413b859ba6f790945f581de;p=8sync.git agenda tests --- diff --git a/tests.scm b/tests.scm index b865ca8..f0edcfb 100644 --- a/tests.scm +++ b/tests.scm @@ -184,10 +184,45 @@ (test-equal (run-request-when run-two-squared) '(88 . 0))) -;; Agenda tests -;; ------------ +;;; Agenda tests +;;; ------------ +;; helpers +(define (speak-it) + (let ((messages '())) + (lambda* (#:optional message) + (if message (set! messages (append messages (list message)))) + messages))) + +;; the dummy test + +(define speaker (speak-it)) + +(define (dummy-func) + (speaker "I'm a dummy\n")) + +(define (run-dummy) + (speaker "I bet I can make you say you're a dummy!\n") + (run dummy-func)) + +(let ((q (make-q))) + (set! speaker (speak-it)) ; reset the speaker + (enq! q run-dummy) + (start-agenda (make-agenda #:queue q) + (true-after-n-times 2)) + (test-equal (speaker) + '("I bet I can make you say you're a dummy!\n" + "I'm a dummy\n"))) + +;; should only do the first one after one round though +(let ((q (make-q))) + (set! speaker (speak-it)) ; reset the speaker + (enq! q run-dummy) + (start-agenda (make-agenda #:queue q) + (true-after-n-times 1)) + (test-equal (speaker) + '("I bet I can make you say you're a dummy!\n"))) ;; End tests