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"
2360
2360
range of indexes. 'contains?' operates constant or logarithmic time;
2361
2361
it will not perform a linear search for a value. See also 'some'."
2362
2362
[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)
2364
2368
false
2369
+
2370
+ :else
2365
2371
true ))
2366
2372
2367
2373
(defn find
Original file line number Diff line number Diff line change 84
84
(is (not (contains? (to-array [5 6 7 ]) 3 )))
85
85
(is (not (contains? nil 42 )))
86
86
(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 ))))))
88
95
89
96
(deftest test-run!
90
97
(testing " Testing run!"
You can’t perform that action at this time.
0 commit comments