Commit b3ee2975 authored by Andy Li's avatar Andy Li

New upstream version 0.9

parent 4eb389a5
......@@ -6,7 +6,7 @@ _build
TAGS
*.docdir
man
qcheck.install
*.install
*.tar.gz
*.byte
.merlin
#directory "_build/src";;
#use "topfind";;
#require "oUnit";;
#require "unix";;
#require "bytes";;
#load "qcheck.cma";;
open QCheck;;
(* vim: syntax=ocaml:
*)
module Q = QCheck;;
language: c
install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-docker.sh
script: bash -ex .travis-docker.sh
services:
- docker
env:
global:
- PINS="qcheck:. qcheck-core:. qcheck-ounit:. qcheck-alcotest:."
- DISTRO="ubuntu-16.04"
matrix:
- PACKAGE="qcheck" OCAML_VERSION="4.03.0" DEPOPTS="ounit alcotest"
- PACKAGE="qcheck" OCAML_VERSION="4.04.2" DEPOPTS="ounit alcotest"
- PACKAGE="qcheck" OCAML_VERSION="4.05.0" DEPOPTS="ounit alcotest"
- PACKAGE="qcheck" OCAML_VERSION="4.06.0" DEPOPTS="ounit alcotest"
- PACKAGE="qcheck" OCAML_VERSION="4.07.0" DEPOPTS="ounit alcotest"
# Changes
## 0.9
- add `qcheck-ounit` sublibrary
- use environment variables to configure `qcheck-alcotest` tests
- alcotest backend for qcheck
- make `qcheck.ounit` tests verbose by default
- make `qcheck` is a compatibility library, depends on `qcheck-core`
- split lib into `qcheck` and `qcheck.ounit`
- add `TestResult.is_success` helper
- give access to list of instances in test results
- allow setting `time_between_msg` in runner
- chore: remove submodule
- chore: add travis support
- doc: explanations about qcheck.ounit runners
- doc: update readme
## 0.8
- migrate to jbuilder
- fix warnings
- add some useful functions
- update oasis files (close #48)
- update copyright header (closes #47)
## 0.7
- switch to BSD license, make it more explicit (close #43)
......
......@@ -2,28 +2,35 @@
all: build test
build:
jbuilder build @install
@dune build @install
test:
jbuilder runtest --no-buffer
@dune runtest --no-buffer
clean:
jbuilder clean
@dune clean
doc:
jbuilder build @doc
@dune build @doc
EXAMPLES=$(addprefix example/, QCheck_test.exe QCheck_ounit_test.exe QCheck_runner_test.exe)
example-test:
@dune exec example/ounit/QCheck_test.exe
examples:
jbuilder build $(EXAMPLES)
example-ounit-test:
@dune exec example/ounit/QCheck_ounit_test.exe
example-runner:
@dune exec example/QCheck_runner_test.exe
example-alcotest:
@dune exec example/alcotest/QCheck_alcotest_test.exe
VERSION=$(shell awk '/^version:/ {print $$2}' qcheck.opam)
update_next_tag:
@echo "update version to $(VERSION)..."
sed -i "s/NEXT_VERSION/$(VERSION)/g" src/*.ml src/*.mli
sed -i "s/NEXT_RELEASE/$(VERSION)/g" src/*.ml src/*.mli
sed -i "s/NEXT_VERSION/$(VERSION)/g" `find src -name '*.ml' -or -name '*.mli'`
sed -i "s/NEXT_RELEASE/$(VERSION)/g" `find src -name '*.ml' -or -name '*.mli'`
release: update_next_tag
@echo "release version $(VERSION)..."
......
......@@ -17,6 +17,8 @@ can be useful too, for generating random values.
toc::[]
image::https://travis-ci.org/c-cube/qcheck.svg?branch=master[alt="Build Status", link="https://travis-ci.org/c-cube/qcheck"]
== Use
See the documentation. I also wrote
......@@ -49,6 +51,9 @@ and type the following to load QCheck:
#require "qcheck";;
----
NOTE: alternatively, it is now possible to locally do: `dune utop src`
to load `qcheck`.
=== List Reverse is Involutive
We write a random test for checking that `List.rev (List.rev l) = l` for
......@@ -290,8 +295,9 @@ or an error number otherwise.
http://ounit.forge.ocamlcore.org/[OUnit] is a popular unit-testing framework
for OCaml.
QCheck provides some helpers, in `QCheck_runner`, to convert its random tests
into OUnit tests that can be part of a wider test-suite.
QCheck provides a sub-library `qcheck-ounit` with some helpers, in `QCheck_ounit`,
to convert its random tests into OUnit tests that can be part of a wider
test-suite.
[source,OCaml]
----
......@@ -311,6 +317,58 @@ let _ =
let open OUnit in
run_test_tt_main
("tests" >:::
List.map QCheck_runner.to_ounit_test [passing; failing])
List.map QCheck_ounit.to_ounit_test [passing; failing])
----
NOTE: the package `qcheck` contains the module `QCheck_runner`
which contains both custom runners and OUnit-based runners.
=== Integration within alcotest
https://github.com/mirage/alcotest/[Alcotest] is a simple and colorful test framework for
OCaml. QCheck now provides a sub-library `qcheck-alcotest` to
easily integrate into an alcotest test suite:
[source,OCaml]
----
let passing =
QCheck.Test.make ~count:1000
~name:"list_rev_is_involutive"
QCheck.(list small_int)
(fun l -> List.rev (List.rev l) = l);;
let failing =
QCheck.Test.make ~count:10
~name:"fail_sort_id"
QCheck.(list small_int)
(fun l -> l = List.sort compare l);;
let () =
let suite =
List.map QCheck_alcotest.to_alcotest
[ passing; failing]
in
Alcotest.run "my test" [
"suite", suite
]
----
=== Compatibility notes
Starting with 0.9, the library is split into several components:
- `qcheck-core` depends only on unix and bytes. It contains the module
`QCheck` and a `QCheck_base_runner` module with our custom runners.
- `qcheck-ounit` provides an integration layer for `OUnit`
- `qcheck` provides a compatibility API with older versions of qcheck,
using both `qcheck-core` and `qcheck-ounit`.
It provides `QCheck_runner` which is similar to older versions and contains
both custom and Ounit-based runners.
- `qcheck-alcotest` provides an integration layer with `alcotest`
Normally, for contributors,
`opam pin https://github.com/c-cube/qcheck` will pin all these packages.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="next" href="QCheck.Print.html">
<link rel="Up" href="QCheck.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="QCheck" rel="Chapter" href="QCheck.html">
<link title="QCheck_runner" rel="Chapter" href="QCheck_runner.html"><title>QCheck.Gen</title>
</head>
<body>
<div class="navbar">&nbsp;<a class="up" href="QCheck.html" title="QCheck">Up</a>
&nbsp;<a class="post" href="QCheck.Print.html" title="QCheck.Print">Next</a>
</div>
<h1>Module <a href="type_QCheck.Gen.html">QCheck.Gen</a></h1>
<pre><span class="keyword">module</span> Gen: <code class="code">sig</code> <a href="QCheck.Gen.html">..</a> <code class="code">end</code></pre><div class="info module top">
<h2 id="2_GenerateRandomValues">Generate Random Values</h2><br>
</div>
<hr width="100%">
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> = <code class="type">Random.State.t -> 'a</code> </pre>
<div class="info ">
A random generator for values of type 'a<br>
</div>
<pre><span id="TYPEsized"><span class="keyword">type</span> <code class="type">'a</code> sized</span> = <code class="type">int -> Random.State.t -> 'a</code> </pre>
<div class="info ">
Random generator with a size bound<br>
</div>
<pre><span id="VALreturn"><span class="keyword">val</span> return</span> : <code class="type">'a -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Create a constant generator<br>
</div>
<pre><span id="VAL(>>=)"><span class="keyword">val</span> (&gt;&gt;=)</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -> ('a -> 'b <a href="QCheck.Gen.html#TYPEt">t</a>) -> 'b <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Monadic bind for writing dependent generators. First generates an <code class="code">'a</code> and then
passes it to the given function, to generate a <code class="code">'b</code>.<br>
</div>
<pre><span id="VAL(<*>)"><span class="keyword">val</span> (&lt;*&gt;)</span> : <code class="type">('a -> 'b) <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'b <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Infix operator for composing a function generator and an argument generator
into a result generator<br>
</div>
<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">('a -> 'b) -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'b <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">map f g</code> transforms a generator <code class="code">g</code> by applying <code class="code">f</code> to each generated element<br>
</div>
<pre><span id="VALmap2"><span class="keyword">val</span> map2</span> : <code class="type">('a -> 'b -> 'c) -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'b <a href="QCheck.Gen.html#TYPEt">t</a> -> 'c <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">map f g1 g2</code> transforms two generators <code class="code">g1</code> and <code class="code">g2</code> by applying <code class="code">f</code> to each
pair of generated elements<br>
</div>
<pre><span id="VALmap3"><span class="keyword">val</span> map3</span> : <code class="type">('a -> 'b -> 'c -> 'd) -><br> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'b <a href="QCheck.Gen.html#TYPEt">t</a> -> 'c <a href="QCheck.Gen.html#TYPEt">t</a> -> 'd <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">map f g1 g2 g3</code> transforms two generators <code class="code">g1</code>, <code class="code">g2</code>, and <code class="code">g3</code> by applying <code class="code">f</code>
to each triple of generated elements<br>
</div>
<pre><span id="VALmap_keep_input"><span class="keyword">val</span> map_keep_input</span> : <code class="type">('a -> 'b) -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> ('a * 'b) <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">map f g</code> transforms a generator <code class="code">g</code> by applying <code class="code">f</code> to each generated element.
Returns both the generated elememt from <code class="code">g</code> and the output from <code class="code">f</code>.<br>
</div>
<pre><span id="VAL(>|=)"><span class="keyword">val</span> (&gt;|=)</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -> ('a -> 'b) -> 'b <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
An infix synonym for <a href="QCheck.Gen.html#VALmap"><code class="code">QCheck.Gen.map</code></a><br>
</div>
<pre><span id="VALoneof"><span class="keyword">val</span> oneof</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> list -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Constructs a generator that selects among a given list of generators<br>
</div>
<pre><span id="VALoneofl"><span class="keyword">val</span> oneofl</span> : <code class="type">'a list -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Constructs a generator that selects among a given list of values<br>
</div>
<pre><span id="VALoneofa"><span class="keyword">val</span> oneofa</span> : <code class="type">'a array -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Constructs a generator that selects among a given array of values<br>
</div>
<pre><span id="VALfrequency"><span class="keyword">val</span> frequency</span> : <code class="type">(int * 'a <a href="QCheck.Gen.html#TYPEt">t</a>) list -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Constructs a generator that selects among a given list of generators.
Each of the given generators are chosen based on a positive integer weight.<br>
</div>
<pre><span id="VALfrequencyl"><span class="keyword">val</span> frequencyl</span> : <code class="type">(int * 'a) list -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Constructs a generator that selects among a given list of values.
Each of the given values are chosen based on a positive integer weight.<br>
</div>
<pre><span id="VALfrequencya"><span class="keyword">val</span> frequencya</span> : <code class="type">(int * 'a) array -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Constructs a generator that selects among a given array of values.
Each of the array entries are chosen based on a positive integer weight.<br>
</div>
<pre><span id="VALshuffle_a"><span class="keyword">val</span> shuffle_a</span> : <code class="type">'a array -> unit <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Shuffle the array in place<br>
</div>
<pre><span id="VALshuffle_l"><span class="keyword">val</span> shuffle_l</span> : <code class="type">'a list -> 'a list <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Creates a generator of shuffled lists<br>
</div>
<pre><span id="VALunit"><span class="keyword">val</span> unit</span> : <code class="type">unit <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
The unit generator<br>
</div>
<pre><span id="VALbool"><span class="keyword">val</span> bool</span> : <code class="type">bool <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
The Boolean generator<br>
</div>
<pre><span id="VALfloat"><span class="keyword">val</span> float</span> : <code class="type">float <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates floating point numbers<br>
</div>
<pre><span id="VALpfloat"><span class="keyword">val</span> pfloat</span> : <code class="type">float <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates positive floating point numbers<br>
</div>
<pre><span id="VALnfloat"><span class="keyword">val</span> nfloat</span> : <code class="type">float <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates negative floating point numbers<br>
</div>
<pre><span id="VALnat"><span class="keyword">val</span> nat</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates small natural numbers<br>
</div>
<pre><span id="VALneg_int"><span class="keyword">val</span> neg_int</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates negative integers<br>
</div>
<pre><span id="VALpint"><span class="keyword">val</span> pint</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates positive integers uniformly<br>
</div>
<pre><span id="VALint"><span class="keyword">val</span> int</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates integers uniformly<br>
</div>
<pre><span id="VALsmall_nat"><span class="keyword">val</span> small_nat</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Synonym to <a href="QCheck.Gen.html#VALnat"><code class="code">QCheck.Gen.nat</code></a><br>
<b>Since</b> 0.5.1<br>
</div>
<pre><span id="VALsmall_int"><span class="keyword">val</span> small_int</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Small signed integers (not just <a href="QCheck.Gen.html#VALnat"><code class="code">QCheck.Gen.nat</code></a>)<br>
</div>
<pre><span id="VALint_bound"><span class="keyword">val</span> int_bound</span> : <code class="type">int -> int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Uniform integer generator producing integers within <code class="code">0... bound</code>.<br>
<b>Raises</b> <code>Invalid_argument</code> if the bound is too high (typically 2^30)<br>
</div>
<pre><span id="VALint_range"><span class="keyword">val</span> int_range</span> : <code class="type">int -> int -> int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Uniform integer generator producing integers within <code class="code">low,high</code><br>
<b>Raises</b> <code>Invalid_argument</code> if the range is too large (typically 2^30)<br>
</div>
<pre><span id="VAL(--)"><span class="keyword">val</span> (--)</span> : <code class="type">int -> int -> int <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Synonym to <a href="QCheck.Gen.html#VALint_range"><code class="code">QCheck.Gen.int_range</code></a><br>
</div>
<pre><span id="VALui32"><span class="keyword">val</span> ui32</span> : <code class="type">int32 <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates (unsigned) <code class="code">int32</code> values<br>
</div>
<pre><span id="VALui64"><span class="keyword">val</span> ui64</span> : <code class="type">int64 <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates (unsigned) <code class="code">int64</code> values<br>
</div>
<pre><span id="VALlist"><span class="keyword">val</span> list</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a list <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Builds a list generator from an element generator. List size is generated by <a href="QCheck.Gen.html#VALnat"><code class="code">QCheck.Gen.nat</code></a><br>
</div>
<pre><span id="VALlist_size"><span class="keyword">val</span> list_size</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a list <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Builds a list generator from a (non-negative) size generator and an element generator<br>
</div>
<pre><span id="VALlist_repeat"><span class="keyword">val</span> list_repeat</span> : <code class="type">int -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a list <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">list_repeat i g</code> builds a list generator from exactly <code class="code">i</code> elements generated by <code class="code">g</code><br>
</div>
<pre><span id="VALarray"><span class="keyword">val</span> array</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a array <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Builds an array generator from an element generator. Array size is generated by <a href="QCheck.Gen.html#VALnat"><code class="code">QCheck.Gen.nat</code></a><br>
</div>
<pre><span id="VALarray_size"><span class="keyword">val</span> array_size</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a array <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Builds an array generator from a (non-negative) size generator and an element generator<br>
</div>
<pre><span id="VALarray_repeat"><span class="keyword">val</span> array_repeat</span> : <code class="type">int -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a array <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">array_repeat i g</code> builds an array generator from exactly <code class="code">i</code> elements generated by <code class="code">g</code><br>
</div>
<pre><span id="VALopt"><span class="keyword">val</span> opt</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a option <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
An option generator<br>
</div>
<pre><span id="VALpair"><span class="keyword">val</span> pair</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'b <a href="QCheck.Gen.html#TYPEt">t</a> -> ('a * 'b) <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates pairs<br>
</div>
<pre><span id="VALtriple"><span class="keyword">val</span> triple</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Gen.html#TYPEt">t</a> -> 'c <a href="QCheck.Gen.html#TYPEt">t</a> -> ('a * 'b * 'c) <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates triples<br>
</div>
<pre><span id="VALquad"><span class="keyword">val</span> quad</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Gen.html#TYPEt">t</a> -><br> 'c <a href="QCheck.Gen.html#TYPEt">t</a> -> 'd <a href="QCheck.Gen.html#TYPEt">t</a> -> ('a * 'b * 'c * 'd) <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates quadruples<br>
<b>Since</b> 0.5.1<br>
</div>
<pre><span id="VALchar"><span class="keyword">val</span> char</span> : <code class="type">char <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates characters upto character code 255<br>
</div>
<pre><span id="VALprintable"><span class="keyword">val</span> printable</span> : <code class="type">char <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates printable characters<br>
</div>
<pre><span id="VALnumeral"><span class="keyword">val</span> numeral</span> : <code class="type">char <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Generates numeral characters<br>
</div>
<pre><span id="VALstring_size"><span class="keyword">val</span> string_size</span> : <code class="type">?gen:char <a href="QCheck.Gen.html#TYPEt">t</a> -> int <a href="QCheck.Gen.html#TYPEt">t</a> -> string <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Builds a string generator from a (non-negative) size generator.
Accepts an optional character generator (the default is <a href="QCheck.Gen.html#VALchar"><code class="code">QCheck.Gen.char</code></a>)<br>
</div>
<pre><span id="VALstring"><span class="keyword">val</span> string</span> : <code class="type">?gen:char <a href="QCheck.Gen.html#TYPEt">t</a> -> string <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Builds a string generator. String size is generated by <a href="QCheck.Gen.html#VALnat"><code class="code">QCheck.Gen.nat</code></a>.
Accepts an optional character generator (the default is <a href="QCheck.Gen.html#VALchar"><code class="code">QCheck.Gen.char</code></a>)<br>
</div>
<pre><span id="VALsmall_string"><span class="keyword">val</span> small_string</span> : <code class="type">?gen:char <a href="QCheck.Gen.html#TYPEt">t</a> -> string <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Builds a string generator. String size is in the range <code class="code">0-10</code>.
Accepts an optional character generator (the default is <a href="QCheck.Gen.html#VALchar"><code class="code">QCheck.Gen.char</code></a>)<br>
</div>
<pre><span id="VALjoin"><span class="keyword">val</span> join</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEt">t</a> <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Collapses a generator of generators to simply a generator.<br>
<b>Since</b> 0.5<br>
</div>
<pre><span id="VALsized"><span class="keyword">val</span> sized</span> : <code class="type">'a <a href="QCheck.Gen.html#TYPEsized">sized</a> -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Create a generator from a size-bounded generator by first
generating a size using <a href="QCheck.Gen.html#VALnat"><code class="code">QCheck.Gen.nat</code></a> and passing the result to the size-bounded generator<br>
</div>
<pre><span id="VALsized_size"><span class="keyword">val</span> sized_size</span> : <code class="type">int <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a <a href="QCheck.Gen.html#TYPEsized">sized</a> -> 'a <a href="QCheck.Gen.html#TYPEt">t</a></code></pre><div class="info ">
Create a generator from a size-bounded generator by first
generating a size using the integer generator and passing the result
to the size-bounded generator<br>
<b>Since</b> 0.5<br>
</div>
<pre><span id="VALfix"><span class="keyword">val</span> fix</span> : <code class="type">('a <a href="QCheck.Gen.html#TYPEsized">sized</a> -> 'a <a href="QCheck.Gen.html#TYPEsized">sized</a>) -> 'a <a href="QCheck.Gen.html#TYPEsized">sized</a></code></pre><div class="info ">
Fixpoint combinator for generating recursive, size-bounded data types.
The passed size-parameter should decrease to ensure termination.<br>
</div>
<br>
Example:
<pre class="codepre"><code class="code"> type tree = Leaf of int | Node of tree * tree
let leaf x = Leaf x
let node x y = Node (x,y)
let g = QCheck.Gen.(sized @@ fix
(fun self n -&gt; match n with
| 0 -&gt; map leaf nat
| n -&gt;
frequency
[1, map leaf nat;
2, map2 node (self (n/2)) (self (n/2))]
))
</code></pre><br>
<pre><span id="VALgenerate"><span class="keyword">val</span> generate</span> : <code class="type">?rand:Random.State.t -> n:int -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a list</code></pre><div class="info ">
<code class="code">generate ~n g</code> generates <code class="code">n</code> instances of <code class="code">g</code><br>
</div>
<pre><span id="VALgenerate1"><span class="keyword">val</span> generate1</span> : <code class="type">?rand:Random.State.t -> 'a <a href="QCheck.Gen.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
<code class="code">generate1 g</code> generates one instance of <code class="code">g</code><br>
</div>
</body></html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="QCheck.Print.html">
<link rel="next" href="QCheck.Shrink.html">
<link rel="Up" href="QCheck.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="QCheck" rel="Chapter" href="QCheck.html">
<link title="QCheck_runner" rel="Chapter" href="QCheck_runner.html"><title>QCheck.Iter</title>
</head>
<body>
<div class="navbar"><a class="pre" href="QCheck.Print.html" title="QCheck.Print">Previous</a>
&nbsp;<a class="up" href="QCheck.html" title="QCheck">Up</a>
&nbsp;<a class="post" href="QCheck.Shrink.html" title="QCheck.Shrink">Next</a>
</div>
<h1>Module <a href="type_QCheck.Iter.html">QCheck.Iter</a></h1>
<pre><span class="keyword">module</span> Iter: <code class="code">sig</code> <a href="QCheck.Iter.html">..</a> <code class="code">end</code></pre><div class="info module top">
<h2 id="2_Iterators">Iterators</h2>
<p>
Compatible with the library "sequence". An iterator <code class="code">i</code> is simply
a function that accepts another function <code class="code">f</code> (of type <code class="code">'a -&gt; unit</code>)
and calls <code class="code">f</code> on a sequence of elements <code class="code">f x1; f x2; ...; f xn</code>.<br>
</div>
<hr width="100%">
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> = <code class="type">('a -> unit) -> unit</code> </pre>
<pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALreturn"><span class="keyword">val</span> return</span> : <code class="type">'a -> 'a <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VAL(<*>)"><span class="keyword">val</span> (&lt;*&gt;)</span> : <code class="type">('a -> 'b) <a href="QCheck.Iter.html#TYPEt">t</a> -> 'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'b <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VAL(>>=)"><span class="keyword">val</span> (&gt;&gt;=)</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a> -> ('a -> 'b <a href="QCheck.Iter.html#TYPEt">t</a>) -> 'b <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">('a -> 'b) -> 'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'b <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALmap2"><span class="keyword">val</span> map2</span> : <code class="type">('a -> 'b -> 'c) -> 'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'b <a href="QCheck.Iter.html#TYPEt">t</a> -> 'c <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VAL(>|=)"><span class="keyword">val</span> (&gt;|=)</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a> -> ('a -> 'b) -> 'b <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALappend"><span class="keyword">val</span> append</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'a <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VAL(<+>)"><span class="keyword">val</span> (&lt;+&gt;)</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'a <a href="QCheck.Iter.html#TYPEt">t</a></code></pre><div class="info ">
Synonym to <a href="QCheck.Iter.html#VALappend"><code class="code">QCheck.Iter.append</code></a><br>
</div>
<pre><span id="VALof_list"><span class="keyword">val</span> of_list</span> : <code class="type">'a list -> 'a <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALof_array"><span class="keyword">val</span> of_array</span> : <code class="type">'a array -> 'a <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALpair"><span class="keyword">val</span> pair</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'b <a href="QCheck.Iter.html#TYPEt">t</a> -> ('a * 'b) <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALtriple"><span class="keyword">val</span> triple</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Iter.html#TYPEt">t</a> -> 'c <a href="QCheck.Iter.html#TYPEt">t</a> -> ('a * 'b * 'c) <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALquad"><span class="keyword">val</span> quad</span> : <code class="type">'a <a href="QCheck.Iter.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Iter.html#TYPEt">t</a> -><br> 'c <a href="QCheck.Iter.html#TYPEt">t</a> -> 'd <a href="QCheck.Iter.html#TYPEt">t</a> -> ('a * 'b * 'c * 'd) <a href="QCheck.Iter.html#TYPEt">t</a></code></pre>
<pre><span id="VALfind"><span class="keyword">val</span> find</span> : <code class="type">('a -> bool) -> 'a <a href="QCheck.Iter.html#TYPEt">t</a> -> 'a option</code></pre></body></html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="QCheck.Gen.html">
<link rel="next" href="QCheck.Iter.html">
<link rel="Up" href="QCheck.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="QCheck" rel="Chapter" href="QCheck.html">
<link title="QCheck_runner" rel="Chapter" href="QCheck_runner.html"><title>QCheck.Print</title>
</head>
<body>
<div class="navbar"><a class="pre" href="QCheck.Gen.html" title="QCheck.Gen">Previous</a>
&nbsp;<a class="up" href="QCheck.html" title="QCheck">Up</a>
&nbsp;<a class="post" href="QCheck.Iter.html" title="QCheck.Iter">Next</a>
</div>
<h1>Module <a href="type_QCheck.Print.html">QCheck.Print</a></h1>
<pre><span class="keyword">module</span> Print: <code class="code">sig</code> <a href="QCheck.Print.html">..</a> <code class="code">end</code></pre><div class="info module top">
<h2 id="2_ShowValues">Show Values</h2><br>
</div>
<hr width="100%">
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> = <code class="type">'a -> string</code> </pre>
<pre><span id="VALint"><span class="keyword">val</span> int</span> : <code class="type">int <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALbool"><span class="keyword">val</span> bool</span> : <code class="type">bool <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALfloat"><span class="keyword">val</span> float</span> : <code class="type">float <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALchar"><span class="keyword">val</span> char</span> : <code class="type">char <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALstring"><span class="keyword">val</span> string</span> : <code class="type">string <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALoption"><span class="keyword">val</span> option</span> : <code class="type">'a <a href="QCheck.Print.html#TYPEt">t</a> -> 'a option <a href="QCheck.Print.html#TYPEt">t</a></code></pre>