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.
This diff is collapsed.
<!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>
<pre><span id="VALpair"><span class="keyword">val</span> pair</span> : <code class="type">'a <a href="QCheck.Print.html#TYPEt">t</a> -> 'b <a href="QCheck.Print.html#TYPEt">t</a> -> ('a * 'b) <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALtriple"><span class="keyword">val</span> triple</span> : <code class="type">'a <a href="QCheck.Print.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Print.html#TYPEt">t</a> -> 'c <a href="QCheck.Print.html#TYPEt">t</a> -> ('a * 'b * 'c) <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALquad"><span class="keyword">val</span> quad</span> : <code class="type">'a <a href="QCheck.Print.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Print.html#TYPEt">t</a> -><br> 'c <a href="QCheck.Print.html#TYPEt">t</a> -> 'd <a href="QCheck.Print.html#TYPEt">t</a> -> ('a * 'b * 'c * 'd) <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALlist"><span class="keyword">val</span> list</span> : <code class="type">'a <a href="QCheck.Print.html#TYPEt">t</a> -> 'a list <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALarray"><span class="keyword">val</span> array</span> : <code class="type">'a <a href="QCheck.Print.html#TYPEt">t</a> -> 'a array <a href="QCheck.Print.html#TYPEt">t</a></code></pre>
<pre><span id="VALcomap"><span class="keyword">val</span> comap</span> : <code class="type">('a -> 'b) -> 'b <a href="QCheck.Print.html#TYPEt">t</a> -> 'a <a href="QCheck.Print.html#TYPEt">t</a></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.Iter.html">
<link rel="next" href="QCheck.TestResult.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.Shrink</title>
</head>
<body>
<div class="navbar"><a class="pre" href="QCheck.Iter.html" title="QCheck.Iter">Previous</a>
&nbsp;<a class="up" href="QCheck.html" title="QCheck">Up</a>
&nbsp;<a class="post" href="QCheck.TestResult.html" title="QCheck.TestResult">Next</a>
</div>
<h1>Module <a href="type_QCheck.Shrink.html">QCheck.Shrink</a></h1>
<pre><span class="keyword">module</span> Shrink: <code class="code">sig</code> <a href="QCheck.Shrink.html">..</a> <code class="code">end</code></pre><div class="info module top">
<h2 id="2_ShrinkValues">Shrink Values</h2>
<p>
Shrinking is used to reduce the size of a counter-example. It tries
to make the counter-example smaller by decreasing it, or removing
elements, until the property to test holds again; then it returns the
smallest value that still made the test fail<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 -> 'a <a href="QCheck.Iter.html#TYPEt">QCheck.Iter.t</a></code> </pre>
<div class="info ">
Given a counter-example, return an iterator on smaller versions
of the counter-example<br>
</div>
<pre><span id="VALnil"><span class="keyword">val</span> nil</span> : <code class="type">'a <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre><div class="info ">
No shrink<br>
</div>
<pre><span id="VALint"><span class="keyword">val</span> int</span> : <code class="type">int <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre>
<pre><span id="VALoption"><span class="keyword">val</span> option</span> : <code class="type">'a <a href="QCheck.Shrink.html#TYPEt">t</a> -> 'a option <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre>
<pre><span id="VALstring"><span class="keyword">val</span> string</span> : <code class="type">string <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre>
<pre><span id="VALlist"><span class="keyword">val</span> list</span> : <code class="type">?shrink:'a <a href="QCheck.Shrink.html#TYPEt">t</a> -> 'a list <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre><div class="info ">
Try to shrink lists by removing elements one by one.<br>
</div>
<div class="param_info"><code class="code">shrink</code> : if provided, will be used to also try to reduce
the elements of the list themselves (e.g. in an <code class="code">int list</code>
one can try to decrease the integers)</div>
<pre><span id="VALarray"><span class="keyword">val</span> array</span> : <code class="type">?shrink:'a <a href="QCheck.Shrink.html#TYPEt">t</a> -> 'a array <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre><div class="info ">
Shrink an array.<br>
</div>
<div class="param_info"><code class="code">shrink</code> : see <a href="QCheck.Shrink.html#VALlist"><code class="code">QCheck.Shrink.list</code></a></div>
<pre><span id="VALpair"><span class="keyword">val</span> pair</span> : <code class="type">'a <a href="QCheck.Shrink.html#TYPEt">t</a> -> 'b <a href="QCheck.Shrink.html#TYPEt">t</a> -> ('a * 'b) <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre>
<pre><span id="VALtriple"><span class="keyword">val</span> triple</span> : <code class="type">'a <a href="QCheck.Shrink.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Shrink.html#TYPEt">t</a> -> 'c <a href="QCheck.Shrink.html#TYPEt">t</a> -> ('a * 'b * 'c) <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre>
<pre><span id="VALquad"><span class="keyword">val</span> quad</span> : <code class="type">'a <a href="QCheck.Shrink.html#TYPEt">t</a> -><br> 'b <a href="QCheck.Shrink.html#TYPEt">t</a> -><br> 'c <a href="QCheck.Shrink.html#TYPEt">t</a> -><br> 'd <a href="QCheck.Shrink.html#TYPEt">t</a> -> ('a * 'b * 'c * 'd) <a href="QCheck.Shrink.html#TYPEt">t</a></code></pre></body></html>
\ No newline at end of file
This diff is collapsed.
<!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.Shrink.html">
<link rel="next" href="QCheck.Test.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.TestResult</title>
</head>
<body>
<div class="navbar"><a class="pre" href="QCheck.Shrink.html" title="QCheck.Shrink">Previous</a>
&nbsp;<a class="up" href="QCheck.html" title="QCheck">Up</a>
&nbsp;<a class="post" href="QCheck.Test.html" title="QCheck.Test">Next</a>
</div>
<h1>Module <a href="type_QCheck.TestResult.html">QCheck.TestResult</a></h1>
<pre><span class="keyword">module</span> TestResult: <code class="code">sig</code> <a href="QCheck.TestResult.html">..</a> <code class="code">end</code></pre><div class="info module top">
Result of running a test<br>
</div>
<hr width="100%">
<pre><code><span id="TYPEcounter_ex"><span class="keyword">type</span> <code class="type">'a</code> counter_ex</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcounter_ex.instance">instance</span>&nbsp;: <code class="type">'a</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
The counter-example(s)<br>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcounter_ex.shrink_steps">shrink_steps</span>&nbsp;: <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
How many shrinking steps for this counterex<br>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
}
<pre><span id="TYPEfailed_state"><span class="keyword">type</span> <code class="type">'a</code> failed_state</span> = <code class="type">'a <a href="QCheck.TestResult.html#TYPEcounter_ex">counter_ex</a> list</code> </pre>
<pre><code><span id="TYPEstate"><span class="keyword">type</span> <code class="type">'a</code> state</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstate.Success"><span class="constructor">Success</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstate.Failed"><span class="constructor">Failed</span></span> <span class="keyword">of</span> <code class="type">'a <a href="QCheck.TestResult.html#TYPEfailed_state">failed_state</a></code></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
Failed instances<br>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstate.Error"><span class="constructor">Error</span></span> <span class="keyword">of</span> <code class="type">'a <a href="QCheck.TestResult.html#TYPEcounter_ex">counter_ex</a> * exn</code></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
Error, and instance that triggered it<br>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<pre><code><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable&nbsp;</span><span id="TYPEELTt.state">state</span>&nbsp;: <code class="type">'a <a href="QCheck.TestResult.html#TYPEstate">state</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable&nbsp;</span><span id="TYPEELTt.count">count</span>&nbsp;: <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable&nbsp;</span><span id="TYPEELTt.count_gen">count_gen</span>&nbsp;: <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTt.collect_tbl">collect_tbl</span>&nbsp;: <code class="type">(string, int) Hashtbl.t lazy_t</code>;</code></td>
</tr></table>
}
</body></html>
\ No newline at end of file
This diff is collapsed.
<!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.html">
<link rel="Up" href="index.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"><link title="State" rel="Section" href="#2_State">
<link title="Conversion of tests to OUnit Tests" rel="Section" href="#2_ConversionofteststoOUnitTests">
<link title="OUnit runners" rel="Section" href="#2_OUnitrunners">
<link title="Run a Suite of Tests and Get Results" rel="Section" href="#2_RunaSuiteofTestsandGetResults">
<title>QCheck_runner</title>
</head>
<body>
<div class="navbar"><a class="pre" href="QCheck.html" title="QCheck">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;</div>
<h1>Module <a href="type_QCheck_runner.html">QCheck_runner</a></h1>
<pre><span class="keyword">module</span> QCheck_runner: <code class="code">sig</code> <a href="QCheck_runner.html">..</a> <code class="code">end</code></pre><div class="info module top">
<h1 id="1_RunnersforTests">Runners for Tests</h1><br>
</div>
<hr width="100%">
<br>
<h2 id="2_State">State</h2><br>
<pre><span id="VALrandom_state"><span class="keyword">val</span> random_state</span> : <code class="type">unit -> Random.State.t</code></pre><div class="info ">
Access the current random state<br>
</div>
<pre><span id="VALverbose"><span class="keyword">val</span> verbose</span> : <code class="type">unit -> bool</code></pre><div class="info ">
Is the default mode verbose or quiet?<br>
</div>
<pre><span id="VALset_seed"><span class="keyword">val</span> set_seed</span> : <code class="type">int -> unit</code></pre><div class="info ">
Change the <a href="QCheck_runner.html#VALrandom_state"><code class="code">QCheck_runner.random_state</code></a> by creating a new one, initialized with
the given seed.<br>
</div>
<pre><span id="VALset_verbose"><span class="keyword">val</span> set_verbose</span> : <code class="type">bool -> unit</code></pre><div class="info ">
Change the value of <code class="code">verbose ()</code><br>
</div>
<br>
<h2 id="2_ConversionofteststoOUnitTests">Conversion of tests to OUnit Tests</h2><br>
<pre><span id="VALto_ounit_test"><span class="keyword">val</span> to_ounit_test</span> : <code class="type">?verbose:bool -> ?rand:Random.State.t -> <a href="QCheck.Test.html#TYPEt">QCheck.Test.t</a> -> OUnit.test</code></pre><div class="info ">
<code class="code">to_ounit_test ~rand t</code> wraps <code class="code">t</code> into a OUnit test<br>
</div>
<div class="param_info"><code class="code">verbose</code> : used to print information on stdout (default: <code class="code">verbose()</code>)</div>
<div class="param_info"><code class="code">rand</code> : the random generator to use (default: <code class="code">random_state ()</code>)</div>
<pre><span id="VALto_ounit_test_cell"><span class="keyword">val</span> to_ounit_test_cell</span> : <code class="type">?verbose:bool -> ?rand:Random.State.t -> 'a <a href="QCheck.Test.html#TYPEcell">QCheck.Test.cell</a> -> OUnit.test</code></pre><div class="info ">
Same as <a href="QCheck_runner.html#VALto_ounit_test"><code class="code">QCheck_runner.to_ounit_test</code></a> but with a polymorphic test cell<br>
</div>
<pre><span id="VAL(>:::)"><span class="keyword">val</span> (&gt;:::)</span> : <code class="type">string -> <a href="QCheck.Test.html#TYPEt">QCheck.Test.t</a> list -> OUnit.test</code></pre><div class="info ">
Same as <code class="code">OUnit.&gt;:::</code> but with a list of QCheck tests<br>
</div>
<pre><span id="VALto_ounit2_test"><span class="keyword">val</span> to_ounit2_test</span> : <code class="type">?rand:Random.State.t -> <a href="QCheck.Test.html#TYPEt">QCheck.Test.t</a> -> OUnit2.test</code></pre><div class="info ">
<code class="code">to_ounit2_test ?rand t</code> wraps <code class="code">t</code> into a OUnit2 test<br>
</div>
<div class="param_info"><code class="code">rand</code> : the random generator to use (default: a static seed for reproducibility),
can be overridden with "-seed" on the command-line</div>
<pre><span id="VALto_ounit2_test_list"><span class="keyword">val</span> to_ounit2_test_list</span> : <code class="type">?rand:Random.State.t -> <a href="QCheck.Test.html#TYPEt">QCheck.Test.t</a> list -> OUnit2.test list</code></pre><div class="info ">
<code class="code">to_ounit2_test_list ?rand t</code> like <code class="code">to_ounit2_test</code> but for a list of tests<br>
</div>
<br>
<h2 id="2_OUnitrunners">OUnit runners</h2><br>
<pre><span id="VALrun"><span class="keyword">val</span> run</span> : <code class="type">?argv:string array -> OUnit.test -> int</code></pre><div class="info ">
<code class="code">run test</code> runs the test, and returns an error code that is <code class="code">0</code>
if all tests passed, <code class="code">1</code> otherwise.
This is the default runner used by the comment-to-test generator.<br>
<b>Raises</b><ul><li><code>Arg.Bad</code> in case <code class="code">argv</code> contains unknown arguments</li>
<li><code>Arg.Help</code> in case <code class="code">argv</code> contains "--help"
<p>
This test runner displays execution in a compact way, making it good
for suites that have lots of tests.</li>
</ul>
</div>
<div class="param_info"><code class="code">argv</code> : the command line arguments to parse parameters from (default <code class="code">Sys.argv</code>)</div>
<pre><span id="VALrun_tap"><span class="keyword">val</span> run_tap</span> : <code class="type">OUnit.test -> OUnit.test_results</code></pre><div class="info ">
TAP-compatible test runner, in case we want to use a test harness.
It prints one line per test.<br>
</div>
<br>
<h2 id="2_RunaSuiteofTestsandGetResults">Run a Suite of Tests and Get Results</h2><br>