Skip to content

Commit

Permalink
Add a factorial test for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Nov 22, 2024
1 parent 7ef8e0a commit 0b4dbe7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_loop.hy
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0b4dbe7

Please sign in to comment.