diff options
Diffstat (limited to 'tests/tailcall.lisp')
| -rw-r--r-- | tests/tailcall.lisp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/tailcall.lisp b/tests/tailcall.lisp new file mode 100644 index 0000000..8cea496 --- /dev/null +++ b/tests/tailcall.lisp @@ -0,0 +1,17 @@ +(defun is-even (x) + (if (= x 0) + #t + (is-odd (- x 1)))) + +(defun is-odd (x) + (is-even (- x 1))) + +(assert (is-even 10000)) +(assert (is-even 10)) +(assert (is-even 0)) +(assert (is-odd 1)) +(assert (is-even 2)) + +;; can pass without stack overflow, +;; but comment out for too time-consuming +;; (assert (is-even 1000000)) |
