mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 Fix safe-subvec 2-arity rejecting start=0
The guard used (> start 0) instead of (>= start 0), so (safe-subvec v 0) returned nil instead of the full vector.
This commit is contained in:
parent
176edadb6f
commit
2e97f01838
@ -1146,7 +1146,7 @@
|
||||
"Wrapper around subvec so it doesn't throw an exception but returns nil instead"
|
||||
([v start]
|
||||
(when (and (some? v)
|
||||
(> start 0) (< start (count v)))
|
||||
(>= start 0) (< start (count v)))
|
||||
(subvec v start)))
|
||||
([v start end]
|
||||
(when (some? v)
|
||||
|
||||
@ -325,6 +325,8 @@
|
||||
(t/is (= [2 3] (d/safe-subvec [1 2 3 4] 1 3)))
|
||||
;; single arg — from index to end
|
||||
(t/is (= [2 3 4] (d/safe-subvec [1 2 3 4] 1)))
|
||||
;; start=0 returns the full vector
|
||||
(t/is (= [1 2 3 4] (d/safe-subvec [1 2 3 4] 0)))
|
||||
;; out-of-range returns nil
|
||||
(t/is (nil? (d/safe-subvec [1 2 3] 5)))
|
||||
(t/is (nil? (d/safe-subvec [1 2 3] 0 5)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user