tisp

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

commit 8a9b658cc665222ad72546e5bbbc721a88171951
parent e4b259efae04c47b72de3e39e1e1045f83eab9a6
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Sat,  1 Jan 2022 21:14:05 -0500

Add tests for new list functions

Diffstat:
Mtest.c | 81+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
1 file changed, 50 insertions(+), 31 deletions(-)

diff --git a/test.c b/test.c @@ -297,26 +297,39 @@ char *tests[][2] = { { "(count 3.2 Nil)", "0" }, { "(count \"Bobandy\" '(1/2 1/4 \"Jim\"))", "0" }, - { "list proc", NULL }, - { "(apply list '(1 2 3))", "(1 2 3)" }, - { "(apply + '(2 90))", "92" }, - { "(apply list '(a b c d e))", "(a b c d e)" }, - { "(map car '((1 a) (2 b) (3 c)))", "(1 2 3)" }, - { "(map cdr '((1 a) (2 b) (3 c)))", "((a) (b) (c))" }, - { "(map (Func (x) (car (cdr x))) '((1 a) (2 b) (3 c)))", "(a b c)" }, - { "(map cadr '((1/2 .5) (\"conky\" .25) ('bubbles .125)))", "(0.5 0.25 0.125)" }, - { "(map inc (list 2 4 8 (^ 2 4)))", "(3 5 9 17)" }, - { "(filter positive? '(1 2 -4 5 -9 10))", "(1 2 5 10)" }, - { "(filter odd? '(8 6 17 9 82 34 27))", "(17 9 27)" }, - { "(filter integer? '(1/2 3.e-2 9/3 3.2 0.0 8 17))", "(3 8 17)" }, - { "((compose - sqrt) 9)", "-3" }, - { "((compose / sqrt sqr) 18)", "1/18" }, - { "((compose - sqrt cube) 4)", "-8" }, - { "((compose -) 5/3)", "-5/3" }, - { "((compose - +) 5 6)", "-11" }, - { "((compose sqrt Int *) 4.5 2)", "3" }, - /* { "(foldr + 0 '(1 2 4 5))", "12" }, */ - /* { "(foldr list 0 '(1 2 3 4))", "((((0 1) 2) 3) 4)" }, */ + { "list proc", NULL }, + { "(apply list '(1 2 3))", "(1 2 3)" }, + { "(apply + '(2 90))", "92" }, + { "(apply list '(a b c d e))", "(a b c d e)" }, + { "(map car '((1 a) (2 b) (3 c)))", "(1 2 3)" }, + { "(map cdr '((1 a) (2 b) (3 c)))", "((a) (b) (c))" }, + { "(map (Func (x) (car (cdr x))) '((1 a) (2 b) (3 c)))", "(a b c)" }, + { "(map cadr '((1/2 .5) (\"conky\" .25) ('bubbles .125)))", "(0.5 0.25 0.125)" }, + { "(map inc (list 2 4 8 (^ 2 4)))", "(3 5 9 17)" }, + { "(convert 1 2 '(1 2 3 1 1 4 5 6 7 1))", "(2 2 3 2 2 4 5 6 7 2)" }, + { "(convert 'hey 'hello '(hi sup hey hey hello hola))", + "(hi sup hello hello hello hola)" }, + { "((compose - sqrt) 9)", "-3" }, + { "((compose / sqrt sqr) 18)", "1/18" }, + { "((compose - sqrt cube) 4)", "-8" }, + { "((compose -) 5/3)", "-5/3" }, + { "((compose - +) 5 6)", "-11" }, + { "((compose sqrt Int *) 4.5 2)", "3" }, + /* { "(foldr + 0 '(1 2 4 5))", "12" }, */ + /* { "(foldr list 0 '(1 2 3 4))", "((((0 1) 2) 3) 4)" }, */ + + { "list filter", NULL }, + { "(filter positive? '(1 2 -4 5 -9 10))", "(1 2 5 10)" }, + { "(filter odd? '(8 6 17 9 82 34 27))", "(17 9 27)" }, + { "(filter integer? (list 1/2 3.e-2 9/3 3.2 0.0 8 17))", "(3 8 17)" }, + { "(keep '+ '(+ * - - + + - / sqrt))", "(+ + +)" }, + { "(keep 5 (list (+ 1 2) (- 10 5) 3/2 5 (/ 15 5))))", "(5 5)" }, + { "(keep 3.2 '(3. 3 3.02 3.12 3.20 3.7))", "(3.2)" }, + { "(keep 'a '('a b c d e))", "Nil" }, + { "(remove 1/2 (list 3/4 4/8 6/7 19/17 6/8 1/2))", "(3/4 6/7 19/17 3/4)" }, + { "(remove 2 '(1 3 4 5))", "(1 3 4 5)" }, + { "(remove \"greg\" '(greg 'greg \"wirt\" beatrice))", + "(greg (quote greg) wirt beatrice)" }, { "list mod", NULL }, { "(reverse '(1 2 3 4 5))", "(5 4 3 2 1)" }, @@ -338,18 +351,24 @@ char *tests[][2] = { { "(assoc 3 '((1 b)))", "Nil" }, { "(assoc 4/3 (list (list 1 pi) (list 4/3 1/2 3) (list 2 3)))", "(4/3 1/2 3)" }, - { "member", NULL }, - { "(memp even? (list 1 3 19 4 7 8 2))", "(4 7 8 2)" }, - { "(memp negative? (list 1/3 pi 3.2e-9 0 4 -7 2))", "(-7 2)" }, - { "(memp (Func (x) (> x 8)) '(1/3 1/2 5/3 8 9))", "(9)" }, + { "list member", NULL }, + { "(memp even? (list 1 3 19 4 7 8 2))", "(4 7 8 2)" }, + { "(memp negative? (list 1/3 pi 3.2e-9 0 4 -7 2))", "(-7 2)" }, + { "(memp (Func (x) (> x 8)) '(1/3 1/2 5/3 8 9))", "(9)" }, { "(memp (Func (x) (= x \"fry\")) " - "'(\"fry\" \"nibbler\" \"prof\"))", "(fry nibbler prof)" }, - { "(member 'foo '(foo bar baz))", "(foo bar baz)" }, - { "(member 'bar '(foo bar baz))", "(bar baz)" }, - { "(member 4 '(12 38 4 8))", "(4 8)" }, - { "(member 3.2 '(4/3 2 8 2 3.14 3.2))", "(3.2)" }, - { "(member \"quux\" (list 4.2 3 'quux))", "Nil" }, - { "(member 'qux '(foo bar baz))", "Nil" }, + "'(\"fry\" \"nibbler\" \"prof\"))", "(fry nibbler prof)" }, + { "(member 'foo '(foo bar baz))", "(foo bar baz)" }, + { "(member 'bar '(foo bar baz))", "(bar baz)" }, + { "(member 4 '(12 38 4 8))", "(4 8)" }, + { "(member 3.2 '(4/3 2 8 2 3.14 3.2))", "(3.2)" }, + { "(member \"quux\" (list 4.2 3 'quux))", "Nil" }, + { "(member 'qux '(foo bar baz))", "Nil" }, + { "(everyp? even? '(2 4 10 18))", "True" }, + { "(everyp? odd? '(1 2 3 9 10))", "Nil" }, + { "(everyp? integer? '(1. 2/3 3.14 4/5))", "Nil" }, + { "(every? 'foo '(foo bar baz))", "Nil" }, + { "(every? \"a\" '(a 'a \"a\"))", "Nil" }, + { "(every? 3 (list 3 (+ 1 2) (- 5 2)))", "True" }, { "quasiquote", NULL }, { "`7.2", "7.2" },