diff options
| author | Mistivia <i@mistivia.com> | 2025-06-23 00:04:01 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-23 00:04:01 +0800 |
| commit | 89f144d3ab27e54f7ad8cbf393418a3baa169f0f (patch) | |
| tree | 45ec23a86cdc86300f4f83321c79eb38b80bdffc /tests | |
| parent | 7563e4e5c3c346b8b11f7e66cdb11c81bcf58fa9 (diff) | |
add test case
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/error.lisp | 1 | ||||
| -rw-r--r-- | tests/let-binding.lisp | 25 |
2 files changed, 22 insertions, 4 deletions
diff --git a/tests/error.lisp b/tests/error.lisp index e0e0c4a..c774622 100644 --- a/tests/error.lisp +++ b/tests/error.lisp @@ -1,4 +1,5 @@ (assert-error (error "")) +(assert-error (let ((x (error ""))) #t)) (assert-error (let () (error "") #t)) (assert-error (if (error "") #t #t)) (assert-error (and (error ""))) diff --git a/tests/let-binding.lisp b/tests/let-binding.lisp index 33d021e..eead06a 100644 --- a/tests/let-binding.lisp +++ b/tests/let-binding.lisp @@ -1,7 +1,24 @@ -(assert-error (let ((i 0)) (i > 4))) - -(assert (= 3 (let ((a 1) (b 2)) - (+ a b)))) + (assert (= 3 (+ a b)))) + +;; let is letrec by default +(let ((a 1) + (b (+ a 1))) + (assert (= 2 b))) + +(let ((my-evenp + (lambda (x) + (if (= x 0) + #t + (funcall my-oddp (- x 1))))) + (my-oddp + (lambda (x) + (if (= x 0) + #f + (funcall my-evenp (- x 1)))))) + (assert (funcall my-evenp 10)) + (assert (funcall my-oddp 9)) + (assert (not (funcall my-evenp 9))) + (assert (not (funcall my-oddp 10)))) |
