tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit efa7c5a04f3b75c32d0d9c34764891b8088d44fe
parent dc9e1488c27c81efcdc9f36cc182e6c0cb21ae9f
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Thu, 28 Mar 2019 16:44:53 -0700

Add primitve and math tests

Diffstat:
test.c | 35+++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+), 0 deletions(-)

diff --git a/test.c b/test.c @@ -102,6 +102,22 @@ char *tests[][2] = { { "(cdr (cons 1 (cons 2 3)))", "(2 . 3)" }, { "(cdr (cdr (cons 1 (cons 2 3))))", "3" }, + { "void", NULL }, + { "(void)", "" }, + + { "do", NULL }, + { "(do (+ 1 2) (+ 2 2))", "4" }, + { "(do (+ -4 8) (- 1 2) (* 80 0) (+ 39 -3))", "36" }, + { "(do (mod 80 2) (/ 4 2) (void))", "" }, + + { "eval", NULL }, + { "(eval ''hey)", "hey" }, + { "(eval \"sup\")", "\"sup\"" }, + { "(eval (+ 1 2))", "3" }, + { "(eval '(- 4 3))", "1" }, + { "(eval ''(mod 9 3))", "(mod 9 3)" }, + { "(do (define bar '(/ 25 5)) (eval bar))", "5" }, + { "cond", NULL }, { "(cond)", "()" }, { "(cond (t 1))", "1" }, @@ -167,6 +183,25 @@ char *tests[][2] = { { "((lambda (a b) (+ a b)) 2 2)", "4" }, { "((lambda () 5))", "5" }, + { "numerator", NULL }, + { "(numerator 3/2)", "3" }, + { "(numerator 1/2)", "1" }, + { "(numerator -4/2)", "-2" }, + { "(numerator 24)", "24" }, + + { "denominator", NULL }, + { "(denominator 1/4)", "4" }, + { "(denominator 4/3)", "3" }, + { "(denominator 4/2)", "1" }, + { "(denominator 14/8)", "4" }, + { "(denominator -4)", "1" }, + + { "dec", NULL }, + { "(dec 1/2)", "0.5" }, + { "(dec 3/-2)", "-1.5" }, + { "(dec 1)", "1.0" }, + { "(dec 3.14)", "3.14" }, + { "add", NULL }, { "(+ 1 1)", "2" }, { "(+ 1 (+ 1 2))", "4" },