+ (test-f equal? str output)))
+
+(define-syntax test-exception
+ (syntax-rules ()
+ ((_ f)
+ (begin
+ (display (quote f))
+ (newline)
+ (call/cc (lambda (k)
+ (with-exception-handler
+ (lambda (x)
+ (when (eqv? 'no-exception x)
+ (error #f "test failed: no exception thrown"))
+ (k))
+ (lambda ()
+ (begin
+ f
+ (raise 'no-exception))))))))))
+
+(test (data-tors '(A . ((foo Int Bool)
+ (bar Bool))))
+ '((foo (A foo constructor)
+ abs Int (abs Bool A))
+ (foo~0 (A foo 0 Int) abs A Int)
+ (foo~1 (A foo 1 Bool) abs A Bool)
+ (bar (A bar constructor) abs Bool A)
+ (bar~0 (A bar 0 Bool) abs A Bool)))
+
+(test (data-tors-type-env
+ '(A . ((foo Int Bool)
+ (bar Bool))))
+ '((foo . (abs Int (abs Bool A)))
+ (foo~0 . (abs A Int))
+ (foo~1 . (abs A Bool))
+ (bar . (abs Bool A))
+ (bar~0 . (abs A Bool))))
+
+(test (expand-pattern-matches
+ '((data A (foo Int Int))
+ (let ([(foo x y) (foo 123 234)] [z (f 123)]) x)))
+ '((data A (foo Int Int))
+ (let ([x (foo~0 (foo 123 234))]
+ [y (foo~1 (foo 123 234))]
+ [z (f 123)])
+ x)))
+
+(test-exception
+ (expand-pattern-matches '((data A (foo Int Int))
+ (let ([(foo x) (foo 123 234)])
+ x))))