aboutsummaryrefslogtreecommitdiff
path: root/tests/let-binding.lisp
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-06-23 00:04:01 +0800
committerMistivia <i@mistivia.com>2025-06-23 00:04:01 +0800
commit89f144d3ab27e54f7ad8cbf393418a3baa169f0f (patch)
tree45ec23a86cdc86300f4f83321c79eb38b80bdffc /tests/let-binding.lisp
parent7563e4e5c3c346b8b11f7e66cdb11c81bcf58fa9 (diff)
add test case
Diffstat (limited to 'tests/let-binding.lisp')
-rw-r--r--tests/let-binding.lisp25
1 files changed, 21 insertions, 4 deletions
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))))