Questions tagged [test.check]

test.check is a Clojure property-based testing tool inspired by QuickCheck. The core idea of test.check is that instead of enumerating expected input and output for unit tests, developers write properties about their function that should hold true for all inputs. This lets them write concise, powerful tests.

test.check is a Clojure property-based testing tool inspired by QuickCheck. The core idea of test.check is that instead of enumerating expected input and output for unit tests, developers write properties about their function that should hold true for all inputs. This lets them write concise, powerful tests.

26 questions
1
vote
0 answers

Is the clojure.test.check.random namespace meant to be used externally?

The Clojure test.check library includes an immutable version of the functionality provided by the Java SplittableRandom class, as described by Gary Fredericks in his "Purely Random" talk. However, the API docs for test.check exclude the…
Sam Estep
  • 12,974
  • 2
  • 37
  • 75
1
vote
2 answers

test.check: let-style behaviour in 'properties/for-all'

Following on this question, and the blog post referenced there, is there a reason why prop/for-all does not just roll in this sort of capability directly? E.g. something like: (require '[clojure.test.check.generators :as gen]) (require…
leeor
  • 17,041
  • 6
  • 34
  • 60
1
vote
0 answers

How do you generate collections with a specific property (like stddev) using test.check

I want to use clojure's test.check library to generate collections that I can do some simple stats on, things like computing mean, stddev, confidence intervals and that sort of thing. How can I generate the collections so that they have…
Pieter Breed
  • 5,579
  • 5
  • 44
  • 60
1
vote
2 answers

How to generate UUIDs that can work with test.check in Clojure

Generative testing seems interesting, but I needed to generate random UUIDs as part of the testing. java.util.UUID/newRandom doesn't play nice with test.check shrinking. The java code looks like: public static UUID randomUUID() { long lsb =…
jwhitlark
  • 505
  • 3
  • 16
1
vote
2 answers

How do I create a test.check generator for a sequence of actions in a constrained order?

(require '[clojure.test.check.generators :as gen]) (def ACTIONS {:create-new-user #{} :edit-user #{:create-new-user} :create-new-board #{:create-new-user} :edit-board #{:create-new-board} :create-new-anonymous-comment…
Stephen Cagle
  • 14,124
  • 16
  • 55
  • 86
0
votes
0 answers

Why is my test.check test using inputs smaller than the generator?

I've implemented my own version of index-of. It takes two strings and returns the index where the second string is found in the first. In use, it seems to work fine, but it's failing the test.check property test. The weird thing is test.check says…
triplej
  • 269
  • 4
  • 9
0
votes
2 answers

How do I generate random keys for test.check?

I'm using test.check to generate a hashmap. I want one key to be a random numeric keywords This is what I tried (gen/hash-map :16 gen/nat :1041 gen/string (keyword (str gen/nat)) gen/string) This works fine for the first two keys, but…
triplej
  • 269
  • 4
  • 9
0
votes
2 answers

How do I write a generator to make an alpha string using test.check?

test.check has a built in generator gen/string-alphanumeric but it does not have a gen/string-alpha. How do I make a generator that will make strings only composed of letters and no numbers?
triplej
  • 269
  • 4
  • 9
0
votes
1 answer

Is clojure.spec check generating bad input?

Using clojure.spec (org.clojure/clojurescript {:mvn/version "1.10.520"}), I have a function spec that specifies a map for its input. gen/generate and gen/sample work fine. But calling cljs.spec.test.alpha/check errors with input that should be a…
Nutritioustim
  • 2,686
  • 4
  • 32
  • 57
0
votes
2 answers

Function generator in test.check

I want to make a generators for functions. I've noticed that there are indeed generators for IFn values, but when the function domain is infinite (and since the values are strict), it's not generally practical for them to be used as generators for…
MasterMastic
  • 20,711
  • 12
  • 68
  • 90
0
votes
1 answer

test.check generate tree with different node types

I want to generate a tree with different node types. For each node type there are different possible combinations of node types that can become children of that node. Any node type may have no children. recursive-gen essentially forces me to build…
Leon Grapenthin
  • 9,246
  • 24
  • 37
1
2