X-Git-Url: http://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=tests.scm;h=a3f4913a75d5e9177843da3d5a71ce2d24b0a8b4;hp=b3e630bbffefebbe31d959e7fd17ffa22e504976;hb=a457cd3bb5ce9366db3ca0731a07abc50ecbc1f3;hpb=1b7e2b53e68a39265fd7424910998d2607cc3815 diff --git a/tests.scm b/tests.scm index b3e630b..a3f4913 100644 --- a/tests.scm +++ b/tests.scm @@ -169,6 +169,19 @@ y))) 'Int) + ; case statements +(test-types + (typecheck '((data A (foo B)) + (data B (bar Int)) + (case (foo (bar 32)) + [(foo x) x]))) + 'B) + +(test-types + (typecheck '((case 42 + [23 (= 1 2)] + [x (= x 1)]))) + 'Bool) ; type annotations @@ -278,3 +291,19 @@ (let ([(bar (foo x)) (bar (foo 42))]) x)) 42) + +(test-prog '((data Foo [a] [b] [c]) + (let ([x b]) + (case x + [a 3] + [b 2] + [c 1]))) + 2) + +(test-prog '((data Foo [foo Int Int] [bar Bool]) + (case (foo 42 12) + [(foo 20 x) 0] + [(foo 42 x) x] + [(bar x) 0])) + 12) +