From cc021efe10380039a13da5300990639203450634 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sun, 27 Apr 2014 17:58:48 -0500 Subject: Add step5/9 tests for impls that support it. - Also remove broken make/tests/*.mk tests. Not used any more. --- tests/step5_tco.mal | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/step5_tco.mal (limited to 'tests') diff --git a/tests/step5_tco.mal b/tests/step5_tco.mal new file mode 100644 index 0000000..9054c74 --- /dev/null +++ b/tests/step5_tco.mal @@ -0,0 +1,27 @@ +;; 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 + -- cgit v1.2.3