#lang imperative-syndicate/test-implementation
;; Tests that pending actions are abandoned during a turn in which there is an exception

(test-case
    [(message-struct stage (n))

     (spawn #:name 'actor0
            (on (message (stage 0))
                (send! (stage 1)))

            (on (message (stage 2))
                (send! (stage 3))
                (error 'test-case "Deliberate error")
                (send! (stage 3))))

     (spawn #:name 'main
            (on (message (stage $v))
                (printf "Got message ~v\n" v))
            (on-start
             (until (asserted (observe (stage 0))))
             (send! (stage 0))
             (until (message (stage 1)))
             (send! (stage 2))))]
  (it "should involve one crash" (actor-died? 'actor0 "Deliberate error"))
  (expected-output (list "Got message 0"
                         "Got message 1"
                         "Got message 2")))
