X-Git-Url: https://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=tests.scm;h=f327231339d86e9b0c602f188605b072d57c0cfa;hp=49fc2c4bc861b13de41f454a7aa2b6e6b103d8d9;hb=54729d061d7cbf50de62d767327fcfc3bea1952f;hpb=2d4831a551afbeec0680fa65c6d301853c8a975b diff --git a/tests.scm b/tests.scm index 49fc2c4..f327231 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 @@ -282,8 +295,21 @@ (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) + +(test-prog '((data Foo [foo Int]) + (data Bar [bar Foo]) + (case (bar (foo 42)) + [(bar (foo x)) x])) + 42) +