X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tests%2Ftest-agenda.scm;h=d96b601c4d359dfe40746c221df3132c8ce2d979;hb=HEAD;hp=013bce7c2d2bb45c85b74a9fc146d7a228076ba3;hpb=b387687cfe0aea2f5461bb211b627ce072364ad4;p=8sync.git diff --git a/tests/test-agenda.scm b/tests/test-agenda.scm index 013bce7..d96b601 100644 --- a/tests/test-agenda.scm +++ b/tests/test-agenda.scm @@ -1,5 +1,6 @@ ;;; 8sync --- Asynchronous programming for Guile ;;; Copyright (C) 2015 Christopher Allan Webber +;;; Copyright (C) 2021 Jan (janneke) Nieuwenhuizen ;;; ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public @@ -30,17 +31,6 @@ (define var (@@ (8sync agenda) var))) - - -;;; Helpers -;;; ======= - -(define (speak-it) - (let ((messages '())) - (lambda* (#:optional message) - (if message (set! messages (append messages (list message)))) - messages))) - ;;; queue helpers ;;; ============= @@ -270,36 +260,30 @@ ;; the dummy test -(define speaker (speak-it)) - (define (dummy-func) - (speaker "I'm a dummy\n")) + (speak "I'm a dummy\n")) (define (run-dummy) - (speaker "I bet I can make you say you're a dummy!\n") + (speak "I bet I can make you say you're a dummy!\n") (run-it dummy-func)) -(begin - (set! speaker (speak-it)) ; reset the speaker - (start-agenda (make-agenda #:queue (make-q* run-dummy)) - #:stop-condition (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"))) +(with-fresh-speaker + (run-agenda (make-agenda #:queue (make-q* run-dummy)) + #:stop-condition (true-after-n-times 2)) + (test-equal (get-spoken) + '("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 -(begin - (set! speaker (speak-it)) ; reset the speaker - (start-agenda (make-agenda #:queue (make-q* run-dummy)) - #:stop-condition (true-after-n-times 1)) - (test-equal (speaker) - '("I bet I can make you say you're a dummy!\n"))) +(with-fresh-speaker + (run-agenda (make-agenda #:queue (make-q* run-dummy)) + #:stop-condition (true-after-n-times 1)) + (test-equal (get-spoken) + '("I bet I can make you say you're a dummy!\n"))) ;; End tests -(test-end "test-agenda") - ;; @@: A better way to handle this at the repl? (test-exit) - +(test-end "test-agenda")