File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ (ns clojure.core-test.dissoc-bang
2+ (:require [clojure.test :refer [deftest testing are]]
3+ [clojure.core-test.portability #?(:cljs :refer-macros :default :refer ) [when-var-exists ]]))
4+
5+ (when-var-exists dissoc!
6+
7+ (deftest test-dissoc!
8+
9+ (testing " non-nil"
10+ (are [expected m keys] (= expected (persistent! (apply dissoc! (transient m) keys)))
11+ {} {} [:a ]
12+ {} {:a 1 } [:a ]
13+ {} {:a 1 } [:a :a ]
14+ {} {:a 1 :b 2 } [:a :b ]
15+ {:b 2 } {:a 1 :b 2 } [:a ]
16+ {:b 2 } {:a 1 :b 2 } [:a :c ]))
17+
18+ (testing " nil"
19+ (are [expected m keys] (= expected (persistent! (apply dissoc! (transient m) keys)))
20+ {} {} [nil ]
21+ {} {nil nil } [nil ]
22+ {} {nil nil } [nil nil ]))
23+
24+ (testing " bad shape"
25+ (are [m keys] (thrown? #?(:cljs js/Error :default Exception) (apply dissoc! m keys))
26+ {:a 1 } [:a ]
27+ [0 ] [0 ]
28+ (transient [0 ]) [0 ]
29+ '(0 ) [0 ]
30+ #{:a :b } [:a ]
31+ (transient #{:a :b }) [:a ]
32+ 42 [4 ]
33+ :k [:k ]
34+ " string" [\s \t]))))
You can’t perform that action at this time.
0 commit comments