X-Git-Url: https://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=tests.scm;h=87ed2a6461004eaf44ef2fcd3c1e0ea18aa87ef4;hp=4e14fb6ab8ee3634b1fce5be5166d55fe8455d96;hb=7be98b67cbad421a0b041d20e0f4620e70bd4cd6;hpb=89ef32141732e6d0bbfc7484b465844b62d8d139 diff --git a/tests.scm b/tests.scm index 4e14fb6..87ed2a6 100644 --- a/tests.scm +++ b/tests.scm @@ -43,18 +43,18 @@ (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))))) + (bar~0 . (0 . ( + + abs A Bool))))) (test (data-tors-env - (data-layout '(data A - (foo Int Bool) + '(A . ((foo Int Bool) (bar Bool)))) '((foo . (abs Int (abs Bool A))) (foo~0 . (abs A Int)) @@ -154,9 +154,9 @@ (- 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) @@ -224,3 +224,10 @@ ;; (print "b") ;; (f (- m 1))))]) ;; (f 10))) "ababababab") + + ; adts and pattern matching + +(test-prog '((data (A [foo Int])) + (let ([(foo x) (foo 42)]) + x)) + 42)