22 lines
801 B
Racket
22 lines
801 B
Racket
#lang racket/base
|
|
|
|
(require racket/match)
|
|
(require rackunit)
|
|
(require "os-big-bang.rkt")
|
|
|
|
(provide check-message-handler)
|
|
|
|
(define (flatten-transition t)
|
|
(if (transition? t)
|
|
(transition (transition-state t) (transition-actions t)) ;; autoflattens
|
|
(transition t '()))) ;; wrap for convenient comparison
|
|
|
|
(define (check-message-handler mh initial-w message final-w expected-actions)
|
|
(match-define (on-message pattern handler) mh)
|
|
(check-true (pattern message) "Message-handler pattern did not match message provided")
|
|
(define v (match (handler message initial-w)
|
|
[(? transition? t) t]
|
|
[new-w (transition new-w '())]))
|
|
(check-equal? (flatten-transition v) (transition final-w expected-actions)
|
|
"Produced world-and-actions did not match expected world-and-actions"))
|