diff --git a/tests/test_loop.hy b/tests/test_loop.hy index 43ce3cf3..363eacdd 100644 --- a/tests/test_loop.hy +++ b/tests/test_loop.hy @@ -1,11 +1,21 @@ (require hyrule [loop]) (import + math sys - hyrule [inc dec] + hyrule [inc dec recur] pytest) +(defn test-factorial [] + (assert (= + (loop [[i 5] [acc 1]] + (if (= i 0) + acc + (recur (dec i) (* acc i)))) + (math.factorial 5)))) + + (defn test-tco-sum [] ; This plain old tail-recursive function should exceed Python's