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:
@@ -8082,29 +8082,43 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
;; ── pick (7 tests) ──
|
;; ── pick (7 tests) ──
|
||||||
(defsuite "hs-upstream-pick"
|
(defsuite
|
||||||
(deftest "does not hang on zero-length regex matches"
|
"hs-upstream-pick"
|
||||||
(let ((haystack "a1b")) (eval-hs "pick matches of \"d*\" from haystack set window.test to it") (assert (not (nil? it))))
|
(deftest
|
||||||
)
|
"does not hang on zero-length regex matches"
|
||||||
(deftest "can pick first n items"
|
(let
|
||||||
(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)))
|
((haystack "a1b"))
|
||||||
)
|
(assert (not (nil? (eval-hs "pick matches of \"d*\" from haystack"))))))
|
||||||
(deftest "can pick last n items"
|
(deftest
|
||||||
(let ((arr (list 10 20 30 40 50))) (eval-hs "pick last 2 of arr set $test to it") (assert= it (list 40 50)))
|
"can pick first n items"
|
||||||
)
|
(let
|
||||||
(deftest "can pick random item"
|
((arr (list 10 20 30 40 50)))
|
||||||
(let ((arr (list 10 20 30))) (eval-hs "pick random of arr set $test to it") (assert (not (nil? it))))
|
(assert= (eval-hs "pick first 3 of arr") (list 10 20 30))))
|
||||||
)
|
(deftest
|
||||||
(deftest "can pick random n items"
|
"can pick last 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))
|
(let
|
||||||
)
|
((arr (list 10 20 30 40 50)))
|
||||||
(deftest "can pick items using 'of' syntax"
|
(assert= (eval-hs "pick last 2 of arr") (list 40 50))))
|
||||||
(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 random item"
|
||||||
(deftest "can pick match using 'of' syntax"
|
(let
|
||||||
(assert= (eval-hs "pick match of \"d+\" of haystack set window.test to it") (list "32"))
|
((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) ──
|
;; ── settle (1 tests) ──
|
||||||
(defsuite "hs-upstream-settle"
|
(defsuite "hs-upstream-settle"
|
||||||
|
|||||||
Reference in New Issue
Block a user