Skip to content

Commit

Permalink
Clean up flatten tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Dec 17, 2024
1 parent 9e408fd commit cbf1720
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions tests/test_iterables.hy
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,16 @@


(defn test-flatten []
(setv res (flatten [1 2 [3 4] 5]))
(assert (= res [1 2 3 4 5]))
(setv res (flatten ["foo" #(1 2) [1 [2 3] 4] "bar"]))
(assert (= res ["foo" 1 2 1 2 3 4 "bar"]))
(setv res (flatten [1]))
(assert (= res [1]))
(setv res (flatten []))
(assert (= res []))
(setv res (flatten #(1)))
(assert (= res [1]))
;; test with None
(setv res (flatten #(1 #(None 3))))
(assert (= res [1 None 3]))
(assert (=
(flatten [1 2 [3 4] 5])
[1 2 3 4 5]))
(assert (=
(flatten ["foo" #(1 2) [1 [2 3] 4] "bar"])
["foo" 1 2 1 2 3 4 "bar"]))
(assert (= (flatten [1]) [1]))
(assert (= (flatten []) []))
(assert (= (flatten #(1)) [1]))
(assert (= (flatten #(1 #(None 3))) [1 None 3]))
(try (flatten "foo")
(except [e [TypeError]] (assert (in "not a collection" (str e)))))
(try (flatten 12.34)
Expand Down

0 comments on commit cbf1720

Please sign in to comment.