#lang imperative-syndicate/test-implementation

(test-case
    [(assertion-struct greeting (text))

     (spawn #:name "A" (assert (greeting "Hi from outer space!")))
     (spawn #:name "B" (on (asserted (greeting $t))
                           (printf "Outer dataspace: ~a\n" t)))

     (dataspace #:name "C"
                (spawn #:name "D" (assert (outbound (greeting "Hi from inner!"))))
                (spawn #:name "E" (on (asserted (inbound (greeting $t)))
                                      (printf "Inner dataspace: ~a\n" t))))]
  no-crashes
  ;; There are constraints not expressed here; to properly test this,
  ;; we need something closer to real
  ;; regular-expressions-with-interleave over output lines.
  (expected-output (set "Outer dataspace: Hi from outer space!"
                        "Inner dataspace: Hi from outer space!"
                        "Outer dataspace: Hi from inner!"
                        "Inner dataspace: Hi from inner!")))
