Fix bindings in ADT pattern matching codegen
[scheme.git] / tests.scm
index 49fc2c4bc861b13de41f454a7aa2b6e6b103d8d9..a3f4913a75d5e9177843da3d5a71ce2d24b0a8b4 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
 
 (test-prog '((data Foo [a] [b] [c])
             (let ([x b])
               (case x
-                [a 1]
+                [a 3]
                 [b 2]
-                [c 3])))
+                [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)
+