Generator Transformation

🚧

Advanced tutorial

The contents of this document should be considered advanced and is provided mostly for interest. You do not need to understand this document in order to use quick_check.js to its full potential.

qc.map ⸬ (a → b) → Gen a → Gen b

This allows you to define a generator in terms of another generator. This function is curried.

qc.of ⸬ a → Gen a

Creates a generator based on a constant value. This generator returns the constant value passed into it. In effect, it works like Lodash's _.constant function.

expect(function(a) {
  return a === 5;
}).forAll(qc.of(3));
expect (a) ->
  a == 5
.forAll qc.of 3
expect(a => a === 5).forAll(qc.of(3));

qc.join ⸬ Gen (Gen a) → Gen a

Takes a generator generator and returns a generator. This way you can unwrap unnecessarily complex values.