feat(strictness): transient bang ops require a transient; conj! arities
conj!/assoc!/dissoc!/disj!/pop!/persistent! now throw on a non-transient (or wrong transient kind) instead of falling back to the persistent op, matching Clojure. conj! keeps its special arities: (conj!) -> (transient []), (conj! coll) -> coll. conj! onto a transient map accepts a [k v] pair or a map (merge), and throws on a list/set/seq. pop_bang/dissoc_bang clean; conj_bang 13/1/22->47/3/1; persistent_bang 9/8->16/1. clojure-test-suite pass 3781->3824. spec: transient/strictness (10). jpm test green.
This commit is contained in:
parent
fb36577ee7
commit
a4a48a8520
3 changed files with 43 additions and 14 deletions
|
|
@ -76,3 +76,17 @@
|
|||
["persistent! twice" :throws
|
||||
"(let [t (transient [])] (persistent! t) (persistent! t))"]
|
||||
["pop! empty" :throws "(pop! (transient []))"])
|
||||
|
||||
# The bang ops require an appropriate transient (Clojure throws otherwise);
|
||||
# conj! has the special 0-/1-arg identity arities.
|
||||
(defspec "transient / strictness"
|
||||
["conj! on persistent" :throws "(conj! [1 2] 3)"]
|
||||
["assoc! on persistent" :throws "(assoc! {:a 1} :b 2)"]
|
||||
["persistent! on vector" :throws "(persistent! [1 2])"]
|
||||
["persistent! on nil" :throws "(persistent! nil)"]
|
||||
["pop! on transient map" :throws "(pop! (transient {:a 1}))"]
|
||||
["dissoc! on tset" :throws "(dissoc! (transient #{1}) 1)"]
|
||||
["conj! map bad item" :throws "(conj! (transient {}) (list :a 1))"]
|
||||
["conj! no args" "[]" "(persistent! (conj!))"]
|
||||
["conj! identity" "[1 2]" "(conj! [1 2])"]
|
||||
["conj! map merges map" "{:a 1, :b 2}" "(persistent! (conj! (transient {:a 1}) {:b 2}))"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue