1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-17 16:47:22 +03:00
mal/tests/step5_tco.mal
Joel Martin cc021efe10 Add step5/9 tests for impls that support it.
- Also remove broken make/tests/*.mk tests. Not used any more.
2014-04-27 17:58:48 -05:00

28 lines
437 B
Plaintext

;; Test recursive non-tail call function
(def! sum-to (fn* (n) (if (= n 0) 0 (+ n (sum-to (- n 1))))))
(sum-to 10)
;=>55
;;; no try* yet, so test completion of side-effects
(def! res1 nil)
;=>nil
(def! res1 (sum-to 10000)))
res1
;=>nil
;; Testing recursive tail-call function
(def! sum2 (fn* (n acc) (if (= n 0) acc (sum2 (- n 1) (+ n acc)))))
(sum2 10 0)
;=>55
(def! res2 nil)
;=>nil
(def! res2 (sum2 10000 0))
res2
;=>50005000