Skip to content

Commit

Permalink
Merge pull request #2576 from Kodiologist/setv-test
Browse files Browse the repository at this point in the history
Add a test of `setv`
  • Loading branch information
Kodiologist committed May 2, 2024
2 parents 05bb450 + 0031180 commit b93147c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/native_tests/setv.hy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(import
unittest.mock [Mock]
pytest)


Expand Down Expand Up @@ -42,6 +43,21 @@
(hy.eval '(setv a 1 b))))


(defn test-setv-pairs-eval-order []
"Each assignment pair should fully resolve before anything in the next is
evaluated, even when statements need to be pulled out."

(setv m (Mock))
(setv l (* [None] 5))
(setv
(get l 0) m.call-count
(get l 1) (do (m) m.call-count)
(get l 2) m.call-count
(get l 3) (do (m) m.call-count)
(get l 4) m.call-count)
(assert (= l [0 1 1 2 2])))


(defn test-setv-returns-none []

(defn an [x]
Expand Down

0 comments on commit b93147c

Please sign in to comment.