projects
/
scheme.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bindings in ADT pattern matching codegen
[scheme.git]
/
tests.scm
diff --git
a/tests.scm
b/tests.scm
index cdd60bd92730df41c4d15077ddee7ffc61bf7f17..a3f4913a75d5e9177843da3d5a71ce2d24b0a8b4 100644
(file)
--- a/
tests.scm
+++ b/
tests.scm
@@
-70,10
+70,10
@@
(bar Bool))))
'((foo (A foo constructor)
abs Int (abs Bool A))
(bar Bool))))
'((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)
+ (foo~0 (A foo 0
Int
) abs A Int)
+ (foo~1 (A foo 1
Bool
) abs A Bool)
(bar (A bar constructor) abs Bool A)
(bar (A bar constructor) abs Bool A)
- (bar~0 (A bar 0) abs A Bool)))
+ (bar~0 (A bar 0
Bool
) abs A Bool)))
(test (data-tors-type-env
'(A . ((foo Int Bool)
(test (data-tors-type-env
'(A . ((foo Int Bool)
@@
-169,6
+169,19
@@
y)))
'Int)
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
; type annotations
@@
-278,3
+291,19
@@
(let ([(bar (foo x)) (bar (foo 42))])
x))
42)
(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)
+