HS pick tests: assert eval-hs result directly, drop dangling 'it' refs

The pick tests were referencing an unbound 'it' in the outer test scope
(the upstream JS variant set window.$test then read it from the browser;
the SX variant has no equivalent). Switch each test to assert against the
return value of eval-hs, which already yields the picked value.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-22 11:55:26 +00:00
parent 5b0c8569a8
commit 41cfa5621b

View File

@@ -8082,29 +8082,43 @@
)
;; ── pick (7 tests) ──
(defsuite "hs-upstream-pick"
(deftest "does not hang on zero-length regex matches"
(let ((haystack "a1b")) (eval-hs "pick matches of \"d*\" from haystack set window.test to it") (assert (not (nil? it))))
)
(deftest "can pick first n items"
(let ((arr (list 10 20 30 40 50))) (eval-hs "pick first 3 of arr set $test to it") (assert= it (list 10 20 30)))
)
(deftest "can pick last n items"
(let ((arr (list 10 20 30 40 50))) (eval-hs "pick last 2 of arr set $test to it") (assert= it (list 40 50)))
)
(deftest "can pick random item"
(let ((arr (list 10 20 30))) (eval-hs "pick random of arr set $test to it") (assert (not (nil? it))))
)
(deftest "can pick random n items"
(let ((arr (list 10 20 30 40 50))) (eval-hs "pick random 2 of arr set $test to it") (assert= (len it) 2))
)
(deftest "can pick items using 'of' syntax"
(let ((arr (list 10 11 12 13 14 15 16))) (eval-hs "pick items 1 to 3 of arr set $test to it") (assert= it (list 11 12)))
)
(deftest "can pick match using 'of' syntax"
(assert= (eval-hs "pick match of \"d+\" of haystack set window.test to it") (list "32"))
)
)
(defsuite
"hs-upstream-pick"
(deftest
"does not hang on zero-length regex matches"
(let
((haystack "a1b"))
(assert (not (nil? (eval-hs "pick matches of \"d*\" from haystack"))))))
(deftest
"can pick first n items"
(let
((arr (list 10 20 30 40 50)))
(assert= (eval-hs "pick first 3 of arr") (list 10 20 30))))
(deftest
"can pick last n items"
(let
((arr (list 10 20 30 40 50)))
(assert= (eval-hs "pick last 2 of arr") (list 40 50))))
(deftest
"can pick random item"
(let
((arr (list 10 20 30)))
(assert (not (nil? (eval-hs "pick random of arr"))))))
(deftest
"can pick random n items"
(let
((arr (list 10 20 30 40 50)))
(assert= (len (eval-hs "pick random 2 of arr")) 2)))
(deftest
"can pick items using 'of' syntax"
(let
((arr (list 10 11 12 13 14 15 16)))
(assert= (eval-hs "pick items 1 to 3 of arr") (list 11 12))))
(deftest
"can pick match using 'of' syntax"
(let
((haystack "The 32 quick brown foxes"))
(assert= (eval-hs "pick match of \"\\d+\" of haystack") (list "32")))))
;; ── settle (1 tests) ──
(defsuite "hs-upstream-settle"