aboutsummaryrefslogtreecommitdiff
path: root/tests/tailcall-big.lisp
diff options
context:
space:
mode:
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))))
+
+