X-Git-Url: https://git.lukelau.me/?a=blobdiff_plain;f=tests.scm;h=bcd878a11dfccb8368d930931d5ad00721d8c626;hb=c4a5f8ab1efce20f0e1181ffe34639facb19594a;hp=648ce073fbb97526b1a70e8327842a905dae35fa;hpb=190fc656a7b4e12e6fcf640c56e6ff71b5a39e40;p=scheme.git diff --git a/tests.scm b/tests.scm index 648ce07..bcd878a 100644 --- a/tests.scm +++ b/tests.scm @@ -45,15 +45,14 @@ (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 + '((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))) @@ -62,6 +61,12 @@ (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)) @@ -138,14 +143,6 @@ '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 @@ -227,7 +224,7 @@ ; adts and pattern matching -(test-prog '((data A [foo Int]) - (let ([(foo x) (foo 42)]) - x)) +(test-prog '((data A [foo Bool Int]) + (let ([(foo x y) (foo (= 3 3) 42)]) + y)) 42)