File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -2360,8 +2360,14 @@ reduces them without incurring seq initialization"
23602360 range of indexes. 'contains?' operates constant or logarithmic time;
23612361 it will not perform a linear search for a value. See also 'some'."
23622362 [coll v]
2363- (if (identical? (get coll v lookup-sentinel) lookup-sentinel)
2363+ (cond
2364+ (implements? IAssociative coll)
2365+ (-contains-key? coll v)
2366+
2367+ (identical? (get coll v lookup-sentinel) lookup-sentinel)
23642368 false
2369+
2370+ :else
23652371 true ))
23662372
23672373(defn find
Original file line number Diff line number Diff line change 8484 (is (not (contains? (to-array [5 6 7 ]) 3 )))
8585 (is (not (contains? nil 42 )))
8686 (is (contains? " f" 0 ))
87- (is (not (contains? " f" 55 )))))
87+ (is (not (contains? " f" 55 ))))
88+
89+ (testing " Testing contains? with IAssociative protocol"
90+ (let [ds (reify
91+ IAssociative
92+ (-contains-key? [_ k] (= k :valid )))]
93+ (is (contains? ds :valid ))
94+ (is (not (contains? ds :invalid ))))))
8895
8996(deftest test-run!
9097 (testing " Testing run!"
You can’t perform that action at this time.
0 commit comments