From 852eff8d0baefb535c49890a6cf8ee8bd9b2b654 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 2 May 2018 18:23:02 +0100 Subject: [PATCH] New (failing) test case re: the approach to relaying --- syndicate/test/core/nesting-confusion.rkt | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 syndicate/test/core/nesting-confusion.rkt diff --git a/syndicate/test/core/nesting-confusion.rkt b/syndicate/test/core/nesting-confusion.rkt new file mode 100644 index 0000000..18c737d --- /dev/null +++ b/syndicate/test/core/nesting-confusion.rkt @@ -0,0 +1,45 @@ +#lang imperative-syndicate/test-implementation +;; Uhoh! The current (2018-05-02) scheme for relaying between +;; dataspaces instantiates each pattern when a matching assertion +;; appears and then relays the result on via an ordinary assertion. +;; However, this is probably wrong! If one inner observer monitors +;; +;; (inbound (x _ $y)) +;; +;; while another monitors +;; +;; (inbound (x $z _)) +;; +;; then the second one will see a literal `(discard)` for `z`! + +(require racket/string) + +(assertion-struct researcher (name topic)) + +(test-case + [(spawn #:name 'tony + (assert (researcher "Tony" "Computering")) + (assert (researcher "Tony" "Bicycling"))) + (spawn #:name 'alice + (assert (researcher "Alice" "Cryptography")) + (assert (researcher "Alice" "Bicycling"))) + (spawn #:name 'eve + (assert (researcher "Eve" "Cryptography")) + (assert (researcher "Eve" "Computering")) + (assert (researcher "Eve" "Evil"))) + + (dataspace #:name 'inner-dataspace + (spawn #:name 'all-topics + (during (inbound (researcher _ $topic)) + (on-start (printf "Added topic: ~a\n" topic)) + (on-stop (printf "Removed topic: ~a\n" topic)))) + (spawn #:name 'all-researchers + (during (inbound (researcher $name _)) + (on-start (printf "Added researcher: ~a\n" name)) + (on-stop (printf "Removed researcher: ~a\n" name)))))] + no-crashes + (procedure-rename + (lambda () + (not (memf (lambda (line) (string-contains? line "#s(discard)")) + (collected-lines)))) + 'no-mention-of-discard))