factor/extra/lisp/lisp-tests.factor

45 lines
883 B
Factor
Raw Normal View History

2008-04-27 23:12:52 -04:00
! Copyright (C) 2008 James Cash
! See http://factorcode.org/license.txt for BSD license.
2008-05-15 02:38:14 -04:00
USING: lisp lisp.parser tools.test sequences math kernel parser ;
2008-04-27 23:12:52 -04:00
2008-04-29 23:10:47 -04:00
IN: lisp.test
2008-05-05 12:48:58 -04:00
init-env
2008-05-18 11:59:11 -04:00
"#f" [ f ] lisp-define
"#t" [ t ] lisp-define
2008-05-15 22:14:53 -04:00
"+" "math" "+" define-primitve
2008-05-18 11:59:11 -04:00
"-" "math" "-" define-primitve
2008-05-05 12:48:58 -04:00
2008-05-15 22:14:53 -04:00
{ 5 } [
[ 2 3 ] "+" <lisp-symbol> funcall
2008-05-05 12:48:58 -04:00
] unit-test
2008-05-18 11:59:11 -04:00
{ 8.3 } [
[ 10.4 2.1 ] "-" <lisp-symbol> funcall
] unit-test
2008-05-05 12:48:58 -04:00
{ 3 } [
2008-05-15 22:14:53 -04:00
"((lambda (x y) (+ x y)) 1 2)" lisp-string>factor call
2008-05-15 22:58:32 -04:00
] unit-test
2008-05-18 11:59:11 -04:00
{ 42 } [
"((lambda (x y z) (+ x (- y z))) 40 3 1)" lisp-string>factor call
] unit-test
2008-05-15 22:58:32 -04:00
2008-05-18 11:59:11 -04:00
{ 1 } [
"(if #t 1 2)" lisp-string>factor call
2008-05-15 22:58:32 -04:00
] unit-test
2008-05-18 11:59:11 -04:00
{ "b" } [
"(cond (#f \"a\") (#t \"b\"))" lisp-string>factor call
2008-05-19 17:09:30 -04:00
] unit-test
{ 5 } [
"(begin (+ 1 4))" lisp-string>factor call
] unit-test
{ 3 } [
"((lambda (x) (if x (begin (+ 1 2)) (- 3 5))) #t)" lisp-string>factor call
2008-04-29 23:10:47 -04:00
] unit-test