diff options
| author | Mistivia <i@mistivia.com> | 2025-06-22 23:32:56 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-22 23:33:12 +0800 |
| commit | 7563e4e5c3c346b8b11f7e66cdb11c81bcf58fa9 (patch) | |
| tree | 3d3ca32fdab4e1b21dc352d0bc98d3e8bedd452f /tests | |
| parent | daf22cff78522a1b5140fb7b02be3006ea4a2236 (diff) | |
add symbol functions
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lambda.lisp | 7 | ||||
| -rw-r--r-- | tests/symbol.lisp | 4 | ||||
| -rw-r--r-- | tests/test.lisp | 34 |
3 files changed, 29 insertions, 16 deletions
diff --git a/tests/lambda.lisp b/tests/lambda.lisp index 18bbd8b..0a1ad1c 100644 --- a/tests/lambda.lisp +++ b/tests/lambda.lisp @@ -24,3 +24,10 @@ (assert (= 1 (funcall c))) (assert (= 2 (funcall c))) (assert (= 3 (funcall c)))) + +(let ((x 1) + (fn nil)) + (setq fn + (lambda (x) (setq x 2))) + (funcall fn x) + (assert (= x 1))) diff --git a/tests/symbol.lisp b/tests/symbol.lisp new file mode 100644 index 0000000..f771272 --- /dev/null +++ b/tests/symbol.lisp @@ -0,0 +1,4 @@ +(assert (eq 'a (intern "a"))) +(assert (eq (intern "ab") (intern (concat "a" "b")))) +(assert (equal "abc" (symbol->string 'abc))) +(assert (not (eq (gensym) (gensym)))) diff --git a/tests/test.lisp b/tests/test.lisp index 9b0f888..ca8195c 100644 --- a/tests/test.lisp +++ b/tests/test.lisp @@ -1,19 +1,21 @@ -(defmacro test-module (name) - `(progn - (princ (format "[TEST] %s\n" ,name)) - (load (format "%s.lisp" ,name)) - (princ (format "[PASS] %s\n" ,name)))) +(defmacro test-module (module) + (let ((name (symbol->string module))) + `(progn + (princ (format "[TEST] %s\n" ,name)) + (load (format "%s.lisp" ,name)) + (princ (format "[PASS] %s\n" ,name))))) -(test-module "math") -(test-module "eq") -(test-module "arithmetic") -(test-module "error") -(test-module "logic") -(test-module "tailcall") -(test-module "control-flow") -(test-module "lambda") -(test-module "comment") -(test-module "macro") -(test-module "let-binding") +(test-module math) +(test-module symbol) +(test-module eq) +(test-module arithmetic) +(test-module error) +(test-module logic) +(test-module tailcall) +(test-module control-flow) +(test-module lambda) +(test-module comment) +(test-module macro) +(test-module let-binding) (exit) |
