Add case statement codegen and singleton ADTs
[scheme.git] / tests.scm
index b3e630bbffefebbe31d959e7fd17ffa22e504976..0c11e89714b89d309cae775cc7f47d3d800e752f 100644 (file)
--- a/tests.scm
+++ b/tests.scm
       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
 
             (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)
+