fix transforms on subvectors to maintain the type as a vector type

This commit is contained in:
nathanmarz 2017-02-17 12:05:12 -05:00
parent d8cfb649ad
commit ef5ad1de6d
3 changed files with 16 additions and 3 deletions

View file

@ -14,6 +14,7 @@
* Dynamic navs automatically compile sequence returns if completely static * Dynamic navs automatically compile sequence returns if completely static
* Eliminate reflection warnings for clj (thanks @mpenet) * Eliminate reflection warnings for clj (thanks @mpenet)
* Bug fix: Collected vals now properly passed to subpaths for `if-path`, `selected?`, and `not-selected?` * Bug fix: Collected vals now properly passed to subpaths for `if-path`, `selected?`, and `not-selected?`
* Bug fix: `LAST`, `FIRST`, `srange`, `BEGINNING`, and `END` properly transform subvector types to a vector type
## 0.13.2 ## 0.13.2

View file

@ -99,7 +99,7 @@
(clojure.lang.MapEntry. newk newv)))) (clojure.lang.MapEntry. newk newv))))
#?(:clj clojure.lang.PersistentVector :cljs cljs.core/PersistentVector) #?(:clj clojure.lang.IPersistentVector :cljs cljs.core/PersistentVector)
(all-transform [structure next-fn] (all-transform [structure next-fn]
(into [] (into []
(comp (map next-fn) (comp (map next-fn)
@ -360,7 +360,7 @@
(prepend-one [_ elem] (prepend-one [_ elem]
(list elem)) (list elem))
#?(:clj clojure.lang.PersistentVector :cljs cljs.core/PersistentVector) #?(:clj clojure.lang.IPersistentVector :cljs cljs.core/PersistentVector)
(append-all [structure elements] (append-all [structure elements]
(reduce conj structure elements)) (reduce conj structure elements))
(prepend-all [structure elements] (prepend-all [structure elements]
@ -436,7 +436,7 @@
(extend-protocol UpdateExtremes (extend-protocol UpdateExtremes
#?(:clj clojure.lang.PersistentVector :cljs cljs.core/PersistentVector) #?(:clj clojure.lang.IPersistentVector :cljs cljs.core/PersistentVector)
(update-first [v afn] (update-first [v afn]
(let [val (nth v 0)] (let [val (nth v 0)]
(assoc v 0 (afn val)))) (assoc v 0 (afn val))))

View file

@ -1442,3 +1442,15 @@
(is (predand= list? '(1) (setval s/BEFORE-ELEM 1 nil))) (is (predand= list? '(1) (setval s/BEFORE-ELEM 1 nil)))
(is (= #{1 2 3} (setval s/NONE-ELEM 3 #{1 2}))) (is (= #{1 2 3} (setval s/NONE-ELEM 3 #{1 2})))
) )
(deftest subvec-test
(let [v (subvec [1] 0)]
(is (predand= vector? [2] (transform s/FIRST inc v)))
(is (predand= vector? [2] (transform s/LAST inc v)))
(is (predand= vector? [2] (transform s/ALL inc v)))
(is (predand= vector? [0 1] (setval s/BEGINNING [0] v)))
(is (predand= vector? [1 0] (setval s/END [0] v)))
(is (predand= vector? [0 1] (setval s/BEFORE-ELEM 0 v)))
(is (predand= vector? [1 0] (setval s/AFTER-ELEM 0 v)))
(is (predand= vector? [1 0] (setval (s/srange 1 1) [0] v)))
))