tisp

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

commit 596d3d79e67c9cbdcbb28204e62bdce5395f99b2
parent 3bee7f468475b890395720d0d6b1946b1d71be10
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Wed, 22 Jan 2020 14:36:57 -0800

Add switch, head, and tail tests

Diffstat:
test.c | 75+++++++++++++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 43 insertions(+), 32 deletions(-)

diff --git a/test.c b/test.c @@ -196,18 +196,22 @@ char *tests[][2] = { { "((lambda (a b) (+ a b)) 2 2)", "4" }, { "((lambda () 5))", "5" }, - { "control", NULL }, - { "(if t 1 2)", "1" }, - { "(if () 1 2)", "2" }, - { "(if (integer? 3) t ())", "t" }, - { "(if (ratio? car) (cons 1 2) (car '(1 2)))", "1" }, - { "(when t 'foo)", "foo" }, - { "(when () 'b ar)", "" }, - { "(when (= 1 1) 4)", "4" }, - { "(unless t 'foo)", "" }, - { "(unless () 'bar)", "bar" }, - { "(unless 3 4)", "" }, - { "(unless (< 5 4) 7)", "7" }, + { "control", NULL }, + { "(if t 1 2)", "1" }, + { "(if () 1 2)", "2" }, + { "(if (integer? 3) t ())", "t" }, + { "(if (ratio? car) (cons 1 2) (car '(1 2)))", "1" }, + { "(when t 'foo)", "foo" }, + { "(when () 'b ar)", "" }, + { "(when (= 1 1) 4)", "4" }, + { "(unless t 'foo)", "" }, + { "(unless () 'bar)", "bar" }, + { "(unless 3 4)", "" }, + { "(unless (< 5 4) 7)", "7" }, + { "(switch 5 (3 'yes) (5 'no))", "no" }, + { "(switch (+ 1 2) ((mod 8 5) 'yes) (err 'no))", "yes" }, + { "(switch 2 (3 'yes) (5 'no))", "" }, + { "(switch \"foo\" (e \"bar\") (\"foo\" 'zar) ('baz 3))", "zar" }, { "logic", NULL }, { "(not ())", "t" }, @@ -241,26 +245,33 @@ char *tests[][2] = { { "(list* (sqr 3) (cube 4))", "(9 . 64)" }, { "(list* 5/4)", "5/4" }, - { "list get", NULL }, - { "(last '(1 2 3))", "3" }, - { "(last (list 4 5))", "5" }, - { "(last '(a b c d e f))", "f" }, - { "(last (cons 1 (cons 2 ())))", "2" }, - { "(length '(1 2 3))", "3" }, - { "(length (list .3 -3/2 12 5))", "4" }, - { "(length '(a b))", "2" }, - { "(length (list list))", "1" }, - { "(length ())", "0" }, - { "(length nil)", "0" }, - { "(nth '(1 2 3) 1)", "2" }, - { "(nth (list 3 5/2 .332 -2) 2)", "0.332" }, - { "(nth '(a b c) 0)", "a" }, - { "(nth (list 'foo 'bar 'zar 'baz) 3)", "baz" }, - { "(count 3 '(1 2 3 4))", "1" }, - { "(count 1/2 (list 1/2 1/3 2/4 8 9.0))", "2" }, - { "(count 'a '(b c a a f h a b c a))", "4" }, - { "(count 3.2 nil)", "0" }, - { "(count \"Bobandy\" '(1/2 1/4 \"Jim\"))", "0" }, + { "list get", NULL }, + { "(last '(1 2 3))", "3" }, + { "(last (list 4 5))", "5" }, + { "(last '(a b c d e f))", "f" }, + { "(last (cons 1 (cons 2 ())))", "2" }, + { "(length '(1 2 3))", "3" }, + { "(length (list .3 -3/2 12 5))", "4" }, + { "(length '(a b))", "2" }, + { "(length (list list))", "1" }, + { "(length ())", "0" }, + { "(length nil)", "0" }, + { "(nth '(1 2 3) 1)", "2" }, + { "(nth (list 3 5/2 .332 -2) 2)", "0.332" }, + { "(nth '(a b c) 0)", "a" }, + { "(nth (list 'foo 'bar 'zar 'baz) 3)", "baz" }, + { "(head '(1.2 1.3 1.4 1.5) 2)", "(1.2 1.3)" }, + { "(head '(1 1e1 1e2 1e3) 3)", "(1 10 100)" }, + { "(head '(1 2 3) 1)", "(1)" }, + { "(head '(1 2) 0)", "()" }, + { "(tail '(randy bobandy lahey bubs) 3)", "(bubs)" }, + { "(tail (list 1/2 1/3 1/4) 0)", "(1/2 1/3 1/4)" }, + { "(tail '(2 4 9 16 25 36) 2)", "(9 16 25 36)" }, + { "(count 3 '(1 2 3 4))", "1" }, + { "(count 1/2 (list 1/2 1/3 2/4 8 9.0))", "2" }, + { "(count 'a '(b c a a f h a b c a))", "4" }, + { "(count 3.2 nil)", "0" }, + { "(count \"Bobandy\" '(1/2 1/4 \"Jim\"))", "0" }, { "list proc", NULL }, { "(apply list '(1 2 3))", "(1 2 3)" },