(let ((str (read-file "/tmp/test-output.txt")))
(test str output)))
-(test (data-tors (data-layout '(data A
- (foo Int Bool)
+(test (data-tors '(A . ((foo Int Bool)
(bar Bool))))
- '((foo . (constructor . (abs Int (abs Bool A))))
- (foo~0 . (0 . (abs A Int)))
- (foo~1 . (1 . (abs A Bool)))
- (bar . (constructor . (abs Bool A)))
- (bar~0 . (0 . (abs A Bool)))))
-
-(test (data-tors-env
- (data-layout '(data A
- (foo Int Bool)
+ '((foo (A foo constructor)
+ abs Int (abs Bool A))
+ (foo~0 (A foo 0) abs A Int)
+ (foo~1 (A foo 1) abs A Bool)
+ (bar (A bar constructor) abs Bool A)
+ (bar~0 (A bar 0) 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))
(bar . (abs Bool A))
(bar~0 . (abs A Bool))))
+(test (expand-pattern-matches '(let ([(foo x y) (foo 123 234)] [z (f 123)]) x))
+ '(let ([x (foo~0 (foo 123 234))]
+ [y (foo~1 (foo 123 234))]
+ [z (f 123)])
+ x))
+
(test-types (typecheck '((lambda (x) (+ ((lambda (y) (x y 3)) 5) 2))))
'(abs (abs Int (abs Int Int)) Int))
'Int)
- ; pattern matching
-(test (let-bindings '(let ([(foo x) a]) x))
- '((x (foo~0 a))))
-
-(test (let-bindings '(let ([x (foo 42)] [(foo y) x]) x))
- '((x (foo 42))
- (y (foo~0 x))))
-
; type annotations
(test (annotate-types
(- y x))))
'((let ()
- ((let ((x 42 : Int)
- (y ((((+ : (abs Int (abs Int Int))) (1 : Int)) : (abs Int Int)) (x : Int)) : Int))
- (((((- : (abs Int (abs Int Int))) (y : Int)) : (abs Int Int)) (x : Int)) : Int))))))
+ ((let ((x (42 : Int))
+ (y (((+ : (abs Int (abs Int Int))) (1 : Int) (x : Int)) : Int)))
+ (((- : (abs Int (abs Int Int))) (y : Int) (x : Int)) : Int)) : Int)) : Int))
(test-expr '(+ 1 2) 3)
(test-expr '(bool->int (= 2 0)) 0)
;; (print "b")
;; (f (- m 1))))])
;; (f 10))) "ababababab")
+
+ ; adts and pattern matching
+
+(test-prog '((data A [foo Bool Int])
+ (let ([(foo x y) (foo (= 3 3) 42)])
+ y))
+ 42)