From 0031180eef48c18ca0ab6968bea916cdb7fae73a Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 28 Apr 2024 09:48:41 -0400 Subject: [PATCH] Add a test of `setv` --- tests/native_tests/setv.hy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/native_tests/setv.hy b/tests/native_tests/setv.hy index 467868ab1..997ea5c64 100644 --- a/tests/native_tests/setv.hy +++ b/tests/native_tests/setv.hy @@ -1,4 +1,5 @@ (import + unittest.mock [Mock] pytest) @@ -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]