2008-04-27 23:12:52 -04:00
|
|
|
! Copyright (C) 2008 James Cash
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-05-26 15:48:22 -04:00
|
|
|
USING: lisp lisp.parser tools.test sequences math kernel parser arrays ;
|
2008-04-27 23:12:52 -04:00
|
|
|
|
2008-04-29 23:10:47 -04:00
|
|
|
IN: lisp.test
|
|
|
|
|
2008-05-22 18:38:51 -04:00
|
|
|
[
|
|
|
|
init-env
|
|
|
|
|
2008-05-26 04:35:18 -04:00
|
|
|
"#f" [ f ] lisp-define
|
2008-05-22 18:38:51 -04:00
|
|
|
"#t" [ t ] lisp-define
|
|
|
|
|
2008-05-26 15:48:22 -04:00
|
|
|
"+" "math" "+" define-primitive
|
|
|
|
"-" "math" "-" define-primitive
|
|
|
|
|
2008-06-03 23:40:30 -04:00
|
|
|
! "list" [ >array ] lisp-define
|
2008-05-22 18:38:51 -04:00
|
|
|
|
|
|
|
{ 5 } [
|
|
|
|
[ 2 3 ] "+" <lisp-symbol> funcall
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 8.3 } [
|
|
|
|
[ 10.4 2.1 ] "-" <lisp-symbol> funcall
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 3 } [
|
2008-05-26 15:48:22 -04:00
|
|
|
"((lambda (x y) (+ x y)) 1 2)" lisp-eval
|
2008-05-22 18:38:51 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 42 } [
|
2008-05-26 15:48:22 -04:00
|
|
|
"((lambda (x y z) (+ x (- y z))) 40 3 1)" lisp-eval
|
2008-05-22 18:38:51 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 1 } [
|
2008-05-26 15:48:22 -04:00
|
|
|
"(if #t 1 2)" lisp-eval
|
2008-05-22 18:38:51 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ "b" } [
|
2008-05-26 15:48:22 -04:00
|
|
|
"(cond (#f \"a\") (#t \"b\"))" lisp-eval
|
2008-05-22 18:38:51 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 5 } [
|
2008-05-26 15:48:22 -04:00
|
|
|
"(begin (+ 1 4))" lisp-eval
|
2008-05-22 18:38:51 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ 3 } [
|
2008-05-26 15:48:22 -04:00
|
|
|
"((lambda (x) (if x (begin (+ 1 2)) (- 3 5))) #t)" lisp-eval
|
|
|
|
] unit-test
|
|
|
|
|
2008-06-03 23:40:30 -04:00
|
|
|
! { { 1 2 3 4 5 } } [
|
|
|
|
! "(list 1 2 3 4 5)" lisp-eval
|
|
|
|
! ] unit-test
|
2008-05-26 17:02:23 -04:00
|
|
|
|
|
|
|
] with-interactive-vocabs
|