6a9b0a7d669e1e0a970f356a7d3cb90fd30fb8a1
[8sync.git] / tests / test-actors.scm
1 (define-module (tests test-actors)
2   #:use-module (srfi srfi-64)
3   #:use-module (8sync systems actors)
4   #:use-module (tests utils))
5
6 (test-begin "test-actors")
7
8
9 ;;; Actor utilities
10 ;;; ===============
11
12 ;;; Message tests
13 ;;; =============
14
15 (let ((monkey-message
16        (make-message 'id 'to 'from 'action
17                      '((monkey . banana)))))
18   ;; A key we have
19   (test-equal (message-ref monkey-message 'monkey)
20     'banana)
21
22   ;; A key we don't have
23   (let ((caught-error #f))
24     (catch 'message-missing-key
25       (lambda ()
26         (message-ref monkey-message 'coo-coo))
27       (lambda (. args)
28         (set! caught-error #t)))
29     (test-assert caught-error))
30
31   ;; A key we don't have, with a default set
32   (test-equal (message-ref monkey-message 'coo-coo 'danger-danger)
33     'danger-danger))
34
35
36 (test-end "test-agenda")
37 (test-exit)