-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathclojure.test.check.html
76 lines (74 loc) · 6.9 KB
/
clojure.test.check.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>clojure.test.check documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><link rel="stylesheet" type="text/css" href="https://storage.googleapis.com/app.klipse.tech/css/codemirror.css" /><div style="visibility: hidden;"><div class="klipse" data-external-libs="https://raw.githubusercontent.com/clojure/test.check/master/src/main/clojure">(ns my.test
(:require [clojure.test.check :as tc :refer [quick-check]]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop :include-macros true]))</div></div><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Test.check</span> <span class="project-version">0.9.1-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="cheatsheet.html"><div class="inner"><span>test.check cheatsheet</span></div></a></li><li class="depth-1 "><a href="generator-examples.html"><div class="inner"><span>Generator Examples</span></div></a></li><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to test.check</span></div></a></li><li class="depth-1 "><a href="migrating-from-simple-check.html"><div class="inner"><span>Migrating from simple-check</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>clojure</span></div></div></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>test</span></div></div></li><li class="depth-3 current"><a href="clojure.test.check.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>check</span></div></a></li><li class="depth-4 branch"><a href="clojure.test.check.clojure-test.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>clojure-test</span></div></a></li><li class="depth-4 branch"><a href="clojure.test.check.generators.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>generators</span></div></a></li><li class="depth-4"><a href="clojure.test.check.properties.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>properties</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="clojure.test.check.html#var-quick-check"><div class="inner"><span>quick-check</span></div></a></li></ul></div><div class="namespace-docs" id="content"><p id="klipse-loader-wrapper">Click <a id="klipse-loader" href="javascript:void(0)">here</a> to make these examples interactive with ClojureScript.</p><h1 class="anchor" id="top">clojure.test.check</h1><div class="doc"><div class="markdown"></div></div><div class="public anchor" id="var-quick-check"><h3>quick-check</h3><div class="usage"><code>(quick-check num-tests property & {:keys [seed max-size reporter-fn], :or {max-size 200, reporter-fn (constantly nil)}})</code></div><div class="doc"><div class="markdown"><p>Tests <code>property</code> <code>num-tests</code> times.</p>
<p>Takes several optional keys:</p>
<p><code>:seed</code> Can be used to re-run previous tests, as the seed used is returned after a test is run.</p>
<p><code>:max-size</code>. can be used to control the ‘size’ of generated values. The size will start at 0, and grow up to max-size, as the number of tests increases. Generators will use the size parameter to bound their growth. This prevents, for example, generating a five-thousand element vector on the very first test.</p>
<p><code>:reporter-fn</code> A callback function that will be called at various points in the test run, with a map like:</p>
<pre><code> ;; called after a passing trial
{:type :trial
:property #<...>
:so-far <number of tests run so far>
:num-tests <total number of tests>}
;; called after each failing trial
{:type :failure
:property #<...>
:result ...
:trial-number <tests ran before failure found>
:failing-args [...]}
It will also be called on :complete, :shrink-step and :shrunk.
</code></pre>
<p>Examples:</p>
<p>Check that the square of a positive number is always greater than itself:</p>
<pre><code>(def p (prop/for-all [a gen/pos-int] (> (* a a) a)))
(quick-check 100 p)
</code></pre>
<p>Another example using <code>reporter-fn</code>:</p>
<pre><code>(quick-check 200 p
:seed 42
:max-size 50
:reporter-fn (fn [m]
(when (= :failure (:type m))
(println "Uh oh..."))))
</code></pre></div></div></div></div><script>window.klipse_settings = {
selector: '.klipse,.clojure',
codemirror_options_in: {
lineWrapping: true,
autoCloseBrackets: true
},
codemirror_options_out: {
lineWrapping: true
}
};</script><script>
function klipseLocalStorageEnabled() {
var mod = 'modernizr';
try {
localStorage.setItem(mod, mod);
localStorage.removeItem(mod);
return true;
} catch (e) {
return false;
}
}
function klipseLoad() {
if (klipseLocalStorageEnabled()) { sessionStorage.setItem('klipse', true);}
$('#klipse-loader-wrapper').remove();
var s = document.createElement('script');
s.setAttribute('src','https://storage.googleapis.com/app.klipse.tech/plugin/js/klipse_plugin.js');
document.head.appendChild(s);
}
if(!true) {
klipseLoad();
} else {
if((klipseLocalStorageEnabled() && sessionStorage.getItem('klipse')) || window.location.search.match(/klipse=1/)) {
klipseLoad();
} else {
$('#klipse-loader').click(function(){
klipseLoad();
});
}
}
</script></body></html>