Skip to content

Commit

Permalink
Update generated documentation for version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtschelfthout committed Apr 29, 2024
1 parent 446dd63 commit deb27c2
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 86 deletions.
6 changes: 5 additions & 1 deletion LearningResources.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ <h3 class="muted"><a href="https://fscheck.github.io/FsCheck/">FsCheck</a></h3>
<h1><a name="Learning-resources" class="anchor" href="#Learning-resources">Learning resources</a></h1>
<h2><a name="Articles" class="anchor" href="#Articles">Articles</a></h2>
<ul>
<li>A series on understanding property-based testing through implementing a simplified PBT library: <a href="https://getcode.substack.com/p/property-based-testing-1-what-is">Part 1</a>, <a href="https://getcode.substack.com/p/-property-based-testing-2-the-essentials">Part 2</a>, <a href="https://getcode.substack.com/p/property-based-testing-3-shrinking">Part 3</a></li>
<li>A six-part series on understanding property-based testing through implementing a simplified PBT library: <a href="https://getcode.substack.com/p/property-based-testing-1-what-is">1</a>, <a href="https://getcode.substack.com/p/-property-based-testing-2-the-essentials">2</a>, <a href="https://getcode.substack.com/p/property-based-testing-3-shrinking">3</a>, <a href="https://getcode.substack.com/p/property-based-testing-4-unifying">4</a>, <a href="https://getcode.substack.com/p/property-based-testing-5-shrinking">5</a>, <a href="https://getcode.substack.com/p/property-based-testing-6-random-all">6</a>.</li>
<li>"QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs" by Koen Claessen and John Hughes <a href="http://www.eecs.northwestern.edu/~robby/courses/395-495-2009-fall/quick.pdf">pdf</a></li>
<li>"An introduction to property-based testing" by Scott Wlaschin <a href="http://fsharpforfunandprofit.com/posts/property-based-testing/">link</a></li>
<li>"Choosing properties for property-based testing" by Scott Wlaschin <a href="http://fsharpforfunandprofit.com/posts/property-based-testing-2/">link</a></li>
<li>An interesting read about QuickCheck is in <a href="http://book.realworldhaskell.org/read/testing-and-quality-assurance.html">Chapter 11</a> of the excellent <a href="http://book.realworldhaskell.org">Real world Haskell</a> book. The book is freely available online, but do the authors a favor and buy it, it's really worth it also for F# programmers.</li>
<li><a href="http://opcoast.com/demos/fsharp/part3.html">This section</a> of the <a href="http://opcoast.com/demos/fsharp/index.html">Learning F#: Case study with Branch and Bound</a> article demonstrates uses of FsCheck to test functions that arise in development of a branch and bound algorithm.</li>
</ul>
<h2><a name="Books" class="anchor" href="#Books">Books</a></h2>
<ul>
<li>"Property-Based Testing with PropEr, Erlang, and Elixir: Find Bugs Before Your Users Do" by Fred Hebert <a href="https://pragprog.com/titles/fhproper/property-based-testing-with-proper-erlang-and-elixir">link</a>.</li>
</ul>
<h2><a name="Videos" class="anchor" href="#Videos">Videos</a></h2>
<ul>
<li>"The lazy programmer's guide to writing 1000's of tests: An introduction to property based testing" by Scott Wlaschin <a href="https://www.youtube.com/watch?v=IYzDFHx6QPY">video</a></li>
Expand Down
42 changes: 19 additions & 23 deletions Properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h2><a name="Conditional-Properties" class="anchor" href="#Conditional-Propertie
</code></pre>
<table class="pre"><tr><td class="snippet"><pre class="fssnip highlighted"><code lang="csharp">Prop.ForAll&lt;<span class="k">int</span>, <span class="k">int</span>[]<span class="o">&gt;</span>((x, xs) <span class="o">=</span><span class="o">&gt;</span> xs.Insert(x).IsOrdered().When(xs.IsOrdered()))
.QuickCheck();</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 10 tests.</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 20 tests.</code></pre></td></tr></table>
<p>Such a property holds if the property after <code>==&gt;</code> holds whenever the condition does.</p>
<p>Testing discards test cases which do not satisfy the condition. Test case generation
continues until 100 cases which do satisfy the condition have been found, or until
Expand All @@ -129,8 +129,8 @@ <h2><a name="Lazy-Properties" class="anchor" href="#Lazy-Properties">Lazy Proper
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs22', 55)" onmouseover="showTip(event, 'fs22', 55)" class="fn">tooEager</span> <span onmouseout="hideTip(event, 'fs23', 56)" onmouseover="showTip(event, 'fs23', 56)" class="fn">a</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs23', 57)" onmouseover="showTip(event, 'fs23', 57)" class="fn">a</span> <span class="o">&lt;&gt;</span> <span class="n">0</span> <span class="o">==&gt;</span> <span class="pn">(</span><span class="n">1</span><span class="o">/</span><span onmouseout="hideTip(event, 'fs23', 58)" onmouseover="showTip(event, 'fs23', 58)" class="fn">a</span> <span class="o">=</span> <span class="n">1</span><span class="o">/</span><span onmouseout="hideTip(event, 'fs23', 59)" onmouseover="showTip(event, 'fs23', 59)" class="fn">a</span><span class="pn">)</span>
<span onmouseout="hideTip(event, 'fs20', 60)" onmouseover="showTip(event, 'fs20', 60)" class="rt">Check</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs21', 61)" onmouseover="showTip(event, 'fs21', 61)" class="id">Quick</span> <span onmouseout="hideTip(event, 'fs22', 62)" onmouseover="showTip(event, 'fs22', 62)" class="fn">tooEager</span>
</code></pre>
<table class="pre"><tr><td><pre><code>Falsifiable, after 2 tests (0 shrinks) (15593756792864180355,10592848517997997791)
Last step was invoked with size of 3 and seed of (17297163148764663572,3327180118707930563):
<table class="pre"><tr><td><pre><code>Falsifiable, after 10 tests (0 shrinks) (3671468370077160750,12134166166860178027)
Last step was invoked with size of 11 and seed of (1055744825524944911,15849000332784013395):
Original:
0
with exception:
Expand Down Expand Up @@ -202,7 +202,7 @@ <h3><a name="Counting-Trivial-Cases" class="anchor" href="#Counting-Trivial-Case
.QuickCheck();</code></pre></td></tr></table>
<p>Test cases for which the condition is true are classified as trivial, and the proportion of
trivial test cases in the total is reported:</p>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 17 tests (41% trivial).</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 10 tests (50% trivial).</code></pre></td></tr></table>
<h3><a name="Classifying-Test-Cases" class="anchor" href="#Classifying-Test-Cases">Classifying Test Cases</a></h3>
<p>A property may take the form <code>classify &lt;condition&gt; &lt;string&gt; &lt;property&gt;</code></p>
<p>For example,</p>
Expand All @@ -220,10 +220,10 @@ <h3><a name="Classifying-Test-Cases" class="anchor" href="#Classifying-Test-Case
.QuickCheck();</code></pre></td></tr></table>
<p>Test cases satisfying the condition are assigned the classification given, and the distribution of
classifications is reported after testing:</p>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 13 tests.
46% at-tail, at-head.
38% at-head.
15% at-tail.</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 16 tests.
62% at-tail, at-head.
18% at-head.
12% at-tail.</code></pre></td></tr></table>
<p>Note that a test case may fall into more than one classification.</p>
<h3><a name="Collecting-Data-Values" class="anchor" href="#Collecting-Data-Values">Collecting Data Values</a></h3>
<p>A property may take the form <code>collect &lt;expression&gt; &lt;property&gt;</code></p>
Expand All @@ -240,11 +240,10 @@ <h3><a name="Collecting-Data-Values" class="anchor" href="#Collecting-Data-Value
.QuickCheck();</code></pre></td></tr></table>
<p>The argument of collect is evaluated in each test case, and the distribution of
values is reported. The type of this argument is printed using <code>sprintf "%A"</code>:</p>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 15 tests.
46% 0.
33% 2.
13% 1.
6% 3.</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 10 tests.
40% 0.
30% 2.
30% 1.</code></pre></td></tr></table>
<h3><a name="Combining-Observations" class="anchor" href="#Combining-Observations">Combining Observations</a></h3>
<p>The observations described here may be combined in any way. All the observations
of each test case are combined, and the distribution of these combinations is
Expand All @@ -263,14 +262,11 @@ <h3><a name="Combining-Observations" class="anchor" href="#Combining-Observation
.Classify(xs.Concat(<span class="k">new</span> <span class="k">int</span>[] { x }).IsOrdered(), <span class="s">"at-tail"</span>)
.Collect(<span class="s">"length "</span> <span class="o">+</span> xs.Count().ToString()))
.QuickCheck();</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 15 tests.
40% 0, at-tail, at-head.
20% 1, at-tail.
13% 2, at-head.
6% 9, at-head.
6% 3, at-tail.
6% 2, at-tail.
6% 1, at-head.</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Arguments exhausted after 22 tests.
31% 1, at-head.
31% 0, at-tail, at-head.
27% 1, at-tail.
9% 2, at-head.</code></pre></td></tr></table>
<h2><a name="And-Or-and-Labels" class="anchor" href="#And-Or-and-Labels">And, Or and Labels</a></h2>
<p>Properties may take the form</p>
<ul>
Expand All @@ -295,8 +291,8 @@ <h2><a name="And-Or-and-Labels" class="anchor" href="#And-Or-and-Labels">And, Or
.And(result <span class="o">&gt;</span><span class="o">=</span> n).Label(<span class="s">"result &gt; #2"</span>)
.And(result <span class="o">&lt;</span> m <span class="o">+</span> n).Label(<span class="s">"result not sum"</span>);
}).QuickCheck();</code></pre></td></tr></table>
<table class="pre"><tr><td><pre><code>Falsifiable, after 1 test (3 shrinks) (2524805318723404745,16821562061416485393)
Last step was invoked with size of 2 and seed of (8953960450956275541,4621003460662097749):
<table class="pre"><tr><td><pre><code>Falsifiable, after 1 test (3 shrinks) (12860091623354605327,1242882491839509389)
Last step was invoked with size of 2 and seed of (6770465432084718975,11292055197076861381):
Label of failing property: result not sum
Original:
-1
Expand Down
12 changes: 6 additions & 6 deletions QuickStart.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ <h2><a name="A-Simple-Example" class="anchor" href="#A-Simple-Example">A Simple
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs10', 15)" onmouseover="showTip(event, 'fs10', 15)" class="fn">revIsOrig</span> <span class="pn">(</span><span onmouseout="hideTip(event, 'fs3', 16)" onmouseover="showTip(event, 'fs3', 16)" class="fn">xs</span><span class="pn">:</span><span onmouseout="hideTip(event, 'fs4', 17)" onmouseover="showTip(event, 'fs4', 17)" class="rt">list</span><span class="pn">&lt;</span><span onmouseout="hideTip(event, 'fs5', 18)" onmouseover="showTip(event, 'fs5', 18)" class="vt">int</span><span class="pn">&gt;</span><span class="pn">)</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs6', 19)" onmouseover="showTip(event, 'fs6', 19)" class="m">List</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs7', 20)" onmouseover="showTip(event, 'fs7', 20)" class="id">rev</span> <span onmouseout="hideTip(event, 'fs3', 21)" onmouseover="showTip(event, 'fs3', 21)" class="fn">xs</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs3', 22)" onmouseover="showTip(event, 'fs3', 22)" class="fn">xs</span>
<span onmouseout="hideTip(event, 'fs8', 23)" onmouseover="showTip(event, 'fs8', 23)" class="rt">Check</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs9', 24)" onmouseover="showTip(event, 'fs9', 24)" class="id">Quick</span> <span onmouseout="hideTip(event, 'fs10', 25)" onmouseover="showTip(event, 'fs10', 25)" class="fn">revIsOrig</span>
</code></pre>
<table class="pre"><tr><td><pre><code>Falsifiable, after 4 tests (2 shrinks) (13267287472967635298,18211440624688182821)
Last step was invoked with size of 5 and seed of (13322308203434852808,12069236234672464129):
<table class="pre"><tr><td><pre><code>Falsifiable, after 1 test (1 shrink) (1044306273230240130,12856555433618444501)
Last step was invoked with size of 2 and seed of (11529939979664627634,3928163698192096459):
Original:
[-2; -1; 0]
[-1; 0]
Shrunk:
[1; 0]
with exception:
Expand Down Expand Up @@ -144,10 +144,10 @@ <h2><a name="FsCheck-teaches-us-a-lesson" class="anchor" href="#FsCheck-teaches-
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs11', 26)" onmouseover="showTip(event, 'fs11', 26)" class="fn">revRevIsOrigFloat</span> <span class="pn">(</span><span onmouseout="hideTip(event, 'fs12', 27)" onmouseover="showTip(event, 'fs12', 27)" class="fn">xs</span><span class="pn">:</span><span onmouseout="hideTip(event, 'fs4', 28)" onmouseover="showTip(event, 'fs4', 28)" class="rt">list</span><span class="pn">&lt;</span><span onmouseout="hideTip(event, 'fs13', 29)" onmouseover="showTip(event, 'fs13', 29)" class="vt">float</span><span class="pn">&gt;</span><span class="pn">)</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs6', 30)" onmouseover="showTip(event, 'fs6', 30)" class="m">List</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs7', 31)" onmouseover="showTip(event, 'fs7', 31)" class="id">rev</span><span class="pn">(</span><span onmouseout="hideTip(event, 'fs6', 32)" onmouseover="showTip(event, 'fs6', 32)" class="m">List</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs7', 33)" onmouseover="showTip(event, 'fs7', 33)" class="id">rev</span> <span onmouseout="hideTip(event, 'fs12', 34)" onmouseover="showTip(event, 'fs12', 34)" class="fn">xs</span><span class="pn">)</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs12', 35)" onmouseover="showTip(event, 'fs12', 35)" class="fn">xs</span>
<span onmouseout="hideTip(event, 'fs8', 36)" onmouseover="showTip(event, 'fs8', 36)" class="rt">Check</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs9', 37)" onmouseover="showTip(event, 'fs9', 37)" class="id">Quick</span> <span onmouseout="hideTip(event, 'fs11', 38)" onmouseover="showTip(event, 'fs11', 38)" class="fn">revRevIsOrigFloat</span>
</code></pre>
<table class="pre"><tr><td><pre><code>Falsifiable, after 8 tests (6 shrinks) (18014236043352962824,13495439114589001055)
Last step was invoked with size of 9 and seed of (8924499886130544753,6764838283798129305):
<table class="pre"><tr><td><pre><code>Falsifiable, after 17 tests (6 shrinks) (12003914617536896781,4245046932773807927)
Last step was invoked with size of 18 and seed of (801088087772054284,8353231879387336807):
Original:
[nan; -0.6919015549; -0.0; nan; -0.0; 0.0; nan]
[0.0; -0.8516859466; nan; 0.0; -infinity; nan; -0.0]
Shrunk:
[nan]
with exception:
Expand Down
6 changes: 3 additions & 3 deletions RunningTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ <h3><a name="Running-many-properties-at-once-with-Check-All" class="anchor" href
<p>FsCheck now also prints the name of each test:</p>
<table class="pre"><tr><td><pre><code>--- Checking ListProperties ---
ListProperties.reverse of reverse is original-Ok, passed 100 tests.
ListProperties.reverse is original-Falsifiable, after 2 tests (4 shrinks) (12394975693502514121,11048480033499951041)
Last step was invoked with size of 3 and seed of (12427705748592770437,15290041744239143249):
ListProperties.reverse is original-Falsifiable, after 2 tests (2 shrinks) (10232327670056031672,15190129820286491799)
Last step was invoked with size of 3 and seed of (8231381327023492931,13197688870822028301):
Original:
[0; 0; -3]
[0; 0; -1]
Shrunk:
[0; 1]
with exception:
Expand Down
15 changes: 9 additions & 6 deletions StatefulTestingNew.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,22 @@ <h1><a name="Model-based-Testing-Experimental" class="anchor" href="#Model-based
<p>A specification can be checked as follows:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span onmouseout="hideTip(event, 'fs42', 105)" onmouseover="showTip(event, 'fs42', 105)" class="rt">Check</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs43', 106)" onmouseover="showTip(event, 'fs43', 106)" class="id">Quick</span> <span class="pn">(</span><span onmouseout="hideTip(event, 'fs44', 107)" onmouseover="showTip(event, 'fs44', 107)" class="m">StateMachine</span><span class="pn">.</span><span onmouseout="hideTip(event, 'fs45', 108)" onmouseover="showTip(event, 'fs45', 108)" class="id">toProperty</span> <span onmouseout="hideTip(event, 'fs13', 109)" onmouseover="showTip(event, 'fs13', 109)" class="id">spec</span><span class="pn">)</span>
</code></pre>
<table class="pre"><tr><td><pre><code>Falsifiable, after 7 tests (6 shrinks) (8898997135889442479,9692081928994144837)
Last step was invoked with size of 8 and seed of (821688670418066841,589392447838876129):
<table class="pre"><tr><td><pre><code>Falsifiable, after 10 tests (9 shrinks) (14109763696607613050,486088154503131329)
Last step was invoked with size of 11 and seed of (1756509616903215099,12028728125209013407):
Label of failing property: Inc: model = 5, actual = 6
Original:
(3, Setup Counter)
inc -&gt; 4
inc -&gt; 5
dec -&gt; 4
inc -&gt; 5
dec -&gt; 4
dec -&gt; 3
inc -&gt; 4
dec -&gt; 3
inc -&gt; 4
inc -&gt; 5
dec -&gt; 4
dec -&gt; 3
dec -&gt; 2
inc -&gt; 3
dec -&gt; 2

Shrunk:
(3, Setup Counter)
Expand Down
Loading

0 comments on commit deb27c2

Please sign in to comment.