Update testing code

This commit is contained in:
Tony Garnock-Jones 2012-02-08 16:27:05 -05:00
parent 3b98769e8d
commit fe88c1cbb6
1 changed files with 6 additions and 1 deletions

View File

@ -6,11 +6,16 @@
(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? v (transition final-w expected-actions)
(check-equal? (flatten-transition v) (transition final-w expected-actions)
"Produced world-and-actions did not match expected world-and-actions"))