diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-27 17:58:48 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-27 17:58:48 -0500 |
| commit | cc021efe10380039a13da5300990639203450634 (patch) | |
| tree | 02977d571ee6b42e7d5429ff8e922f183422eeb5 /tests | |
| parent | b58698b257fb6552e053cd245d63a140d3f7a478 (diff) | |
| download | mal-cc021efe10380039a13da5300990639203450634.tar.gz mal-cc021efe10380039a13da5300990639203450634.zip | |
Add step5/9 tests for impls that support it.
- Also remove broken make/tests/*.mk tests. Not used any more.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/step5_tco.mal | 27 |
1 files changed, 27 insertions, 0 deletions
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 + |
