X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=tests.scm;h=bcda209fe2b069bc3778b5f80665877203d067cb;hb=8c2beb7c6589872bd9134e1c825c8a50adb11cc0;hp=a198dd4ac5a00e4cd71e9a88f8ae32eefbca994c;hpb=2fb532c612fb077a99938b54d59a9520b71772b0;p=scheme.git diff --git a/tests.scm b/tests.scm index a198dd4..bcda209 100644 --- a/tests.scm +++ b/tests.scm @@ -50,7 +50,26 @@ bar)) '(abs a a)) +(test-types (typecheck '(let ([foo 3] + [bar (+ foo baz)] + [baz (- bar 1)]) + bar)) + 'int) + +(test-types (typecheck '(let ([foo 3] + [bar (baz foo)] + [baz (lambda (x) x)]) + baz)) + '(abs a a)) + +(test-types (typecheck '(let ([foo 3] + [bar (baz foo)] + [baz (lambda (x) x)]) + bar)) + 'int) + (test-prog '(+ 1 2) 3) +(test-prog '(bool->int (= 2 0)) 0) (test-prog '((lambda (x) ((lambda (y) (+ x y)) 42)) 100) 142) (test-prog '(* 10 5) 50) @@ -84,3 +103,12 @@ (f f (- n 1) (+ x 1)))))] (inc inc 3 2)) 5) + +(test-prog '(let ([go (lambda (n m x) + (if (= n 0) + x + (go (- n 1) m (* x m))))] + [pow (lambda (p y) (go p y 1))]) + + (pow 3 2)) + 8)