This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-23
Channels
- # announcements (1)
- # babashka (13)
- # cherry (12)
- # cider (6)
- # clj-kondo (3)
- # cljs-dev (28)
- # clojure (77)
- # clojure-europe (25)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-uk (5)
- # clojurescript (31)
- # conjure (7)
- # cursive (12)
- # data-science (9)
- # datalevin (5)
- # datomic (8)
- # hyperfiddle (21)
- # jobs (7)
- # kaocha (19)
- # malli (26)
- # matrix (3)
- # releases (1)
- # shadow-cljs (42)
- # squint (95)
- # testing (2)
- # vim (14)
- # wasm (1)
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
clojure.test.check.generators
+ create a custom generator?