test-check

2020-07-05T09:25:12.064400Z

(I was unable to post on Jira, so I report here) in the docstring of tuple:

(def t (tuple gen/small-integer gen/boolean))
should be
(def t (gen/tuple gen/small-integer gen/boolean))

2020-07-05T16:37:54.064600Z

let's see if I still have commit rights

2020-07-05T16:39:23.064800Z

I do! it's fixed, thanks

1👍
2020-07-05T16:46:46.066100Z

Yesterday I struggled with test.check’s API, I had to use a lot of internal functions and did not see a way to do otherwise. Here is my function:

(defn- decreasing-sizes-gen
  "Returns a generator of lazy sequence of decreasing sizes."
  [max-size]
  (#'gen/make-gen
    (fn [rng _]
      (let [f (fn f [rng max-size]
                (when-not (neg? max-size)
                  (lazy-seq
                    (let [[r1 r2] (random/split rng)
                          size (#'gen/rand-range r1 0 max-size)]
                      (cons size (f r2 (dec size)))))))]
        (rose/pure (f rng max-size))))))

#_(gen/sample (decreasing-sizes-gen 100) 1)

2020-07-05T16:49:52.068400Z

• I had to make my own #'gen/make-gen because gen/randomized is not public, • gen/lazy-random-states is not public either, • I did not find an easy way to recursively iterate between using a generated value and using it to feed a new generator.

2020-07-05T16:58:07.069900Z

I am under the impression that, since the public API cannot be complete for sure, make-gen and rng should be exposed to the users.

2020-07-05T16:59:10.070900Z

If one day I am writing a successor to test.check, I would build it based on that.

2020-07-05T17:01:41.071400Z

You can't do this with the sizing combinators?

2020-07-05T17:02:17.071600Z

which ones?

2020-07-05T17:02:34.072Z

sized and with-size, I think

2020-07-05T17:02:57.072400Z

One to get the size, the other to set them

2020-07-05T17:04:29.073Z

then I would still need a way to build my lazy sequence

2020-07-05T17:05:36.073400Z

map with range

2020-07-05T17:05:41.073600Z

And tuple

2020-07-05T17:06:36.074Z

It won't be lazy; is that important?

2020-07-05T17:07:37.075Z

in my case, I could live without, but in the general case, lazy sequence is something with zero support in test.check

2020-07-05T17:08:19.075800Z

I will keep my function as is, but I wanted to report the limitations I found.

2020-07-05T17:10:35.077300Z

Yes. Should be easier to add laziness now that the rng is immutable