testing

Nim Sadeh 2024-01-23T19:42:24.556419Z

Is there a library somewhere for generating data for property-based testing with conditions? It's useful in a ton of scenarios, but to illustrate here's a concrete example: My function takes a histogram and needs to return the item responsible for 80% of the value counted in the histogram or :NONE if such a value does not exist. So {:A 9 :B 1} should return :A, {:A 5 :B 5} should return :NONE. I want to be able to write a test that looks something like (every #(= :A (gen-80-percent :A))) if that makes any sense

lassemaatta 2024-01-24T08:55:03.985669Z

clojure.test.check.generators + create a custom generator?