aboutsummaryrefslogtreecommitdiff
path: root/tests/tailcall-big.lisp
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-06-23 00:09:54 +0800
committerMistivia <i@mistivia.com>2025-06-23 00:12:58 +0800
commit957175b7f1bff57477ccd000c956bcbe06d159cf (patch)
tree73d5a368eda556dd56af0d89a40c97befd8084ff /tests/tailcall-big.lisp
parent89f144d3ab27e54f7ad8cbf393418a3baa169f0f (diff)
test with intensive gc
Diffstat (limited to 'tests/tailcall-big.lisp')
-rw-r--r--tests/tailcall-big.lisp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/tailcall-big.lisp b/tests/tailcall-big.lisp
new file mode 100644
index 0000000..ebf64c6
--- /dev/null
+++ b/tests/tailcall-big.lisp
@@ -0,0 +1,24 @@
+(assert (is-even 10000))
+(assert (cnt-down 10000))
+
+;; can pass without stack overflow,
+;; but comment out for too time-consuming
+;; (assert (is-even 1000000))
+;; (assert (cnt-down 1000000))
+
+(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 10000))
+ (assert (funcall my-oddp 10009))
+ (assert (not (funcall my-evenp 10009)))
+ (assert (not (funcall my-oddp 10000))))
+
+