Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (38 sloc) 1.339 kB
; Copyright (c) Rich Hickey, Stuart Halloway, and contributors.
; All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns clojure.test.hash-test
(:use clojure.test.generative)
(:require [clojure.test.generative.generators :as gen]))
(defn hash-obj
(reify Object (hashCode [_] h)))
(defn poorly-keyed-map
[vals distinct]
(map #(hash-obj (mod (hash %) distinct)) vals)
(defn verify-key-removal
[m kset]
(loop [c (count kset)
[k & more] (seq kset)
tmap (transient m)]
(if k
(assert (= (count tmap) c))
(recur (dec c)
(dissoc! tmap k)))
(assert (zero? (count tmap)))
(assert (zero? (count (persistent! tmap))))))))
(defspec transient-maps-with-key-collision
[^{:tag (vec long (uniform 0 1000))} vals
^{:tag (uniform 1 100)} distinct]
(verify-key-removal % (into #{} (keys %))))
Jump to Line
Something went wrong with that request. Please try again.