File tree 4 files changed +21
-2
lines changed
test/clojure/test_clojure
4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1425
1425
1426
1426
; ;map stuff
1427
1427
1428
+ (defn map-entry?
1429
+ " Return true if x is a map entry"
1430
+ {:added " 1.8" }
1431
+ [x]
1432
+ (and (instance? java.util.Map$Entry x)
1433
+ (if (instance? clojure.lang.IPersistentVector x)
1434
+ (= 2 (count x))
1435
+ true )))
1436
+
1428
1437
(defn contains?
1429
1438
" Returns true if key is present in the given collection, otherwise
1430
1439
returns false. Note that for numerically indexed collections like
Original file line number Diff line number Diff line change 132
132
(defn- imap-cons
133
133
[^IPersistentMap this o]
134
134
(cond
135
- (instance? java.util.Map$Entry o)
135
+ (map-entry? o)
136
136
(let [^java.util.Map$Entry pair o]
137
137
(.assoc this (.getKey pair) (.getValue pair)))
138
138
(instance? clojure.lang.IPersistentVector o)
Original file line number Diff line number Diff line change 21
21
22
22
(defn collection-tag [x]
23
23
(cond
24
- (instance? java.util.Map$Entry x) :entry
24
+ (map-entry? x) :entry
25
25
(instance? java.util.Map x) :seqable
26
26
(instance? java.util.Set x) :seqable
27
27
(sequential? x) :seq
Original file line number Diff line number Diff line change 704
704
ai3 ao3
705
705
ai4 ao4)))
706
706
707
+ (deftest test-map-entry?
708
+ (testing " map-entry? = false"
709
+ (are [entry]
710
+ (false ? (map-entry? entry))
711
+ nil 5 #{1 2 } '(1 2 ) {:a 1 } [] [0 ] [1 2 3 ]))
712
+ (testing " map-entry? = true"
713
+ (are [entry]
714
+ (true ? (map-entry? entry))
715
+ [1 2 ] (first (doto (java.util.HashMap. ) (.put " x" 1 ))))))
716
+
707
717
; ; *** Sets ***
708
718
709
719
(deftest test-hash-set
You can’t perform that action at this time.
0 commit comments