syndicate-rkt/OLD-syndicate/test/core/death-during-turn.rkt

24 lines
913 B
Racket

;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2010-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
#lang syndicate/test-implementation
;; An error signalled mid-turn must cause previous actions to be
;; discarded; discarded actions must not be observed by peers.
(test-case
[(message-struct set-box (new-value))
(assertion-struct box-state (value))
(spawn (field [current-value 0])
(assert (box-state (current-value)))
(on (message (set-box $new-value)) (current-value new-value))
(begin/dataflow (when (= (current-value) 3)
(error 'box "aiee"))))
(spawn (on (asserted (box-state $v)) ;; must not see 3 here.
(printf "~v\n" v)
(send! (set-box (+ v 1)))))]
(expected-output (list "0"
"1"
"2")))