Skip to content

Commit

Permalink
build based on c00aa87
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Mar 13, 2024
1 parent 601d5d5 commit 5cb0c93
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 86 deletions.
2 changes: 1 addition & 1 deletion dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-08T09:55:30","documenter_version":"1.3.0"}}
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-13T08:56:03","documenter_version":"1.3.0"}}
2 changes: 1 addition & 1 deletion dev/Examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
@test check(splat(successor), itype(Tuple{UInt, UInt}))
@test check(splat(associative), itype(Tuple{UInt, UInt, UInt}))
end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Test Summary: | Pass Total Time
Addition | 4 4 0.8s</code></pre><p>Be aware that while all checks pass, we <em>do not have a guarantee that our code is correct for all cases</em>. Sampling elements to test is a statistical process and as such we can only gain <em>confidence</em> that our code is correct. You may view this in the light of Bayesian statistics, where we update our prior that the code is correct as we run our testsuite more often. This is also true were we not using property based testing or PropCheck at all - with traditional testing approaches, only the values we&#39;ve actually run the code with can be said to be tested.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../intro.html">« Introduction to PBT</a><a class="docs-footer-nextpage" href="structs.html">Generating Structs »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.3.0 on <span class="colophon-date" title="Friday 8 March 2024 09:55">Friday 8 March 2024</span>. Using Julia version 1.10.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Addition | 4 4 0.8s</code></pre><p>Be aware that while all checks pass, we <em>do not have a guarantee that our code is correct for all cases</em>. Sampling elements to test is a statistical process and as such we can only gain <em>confidence</em> that our code is correct. You may view this in the light of Bayesian statistics, where we update our prior that the code is correct as we run our testsuite more often. This is also true were we not using property based testing or PropCheck at all - with traditional testing approaches, only the values we&#39;ve actually run the code with can be said to be tested.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../intro.html">« Introduction to PBT</a><a class="docs-footer-nextpage" href="structs.html">Generating Structs »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.3.0 on <span class="colophon-date" title="Wednesday 13 March 2024 08:56">Wednesday 13 March 2024</span>. Using Julia version 1.10.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
36 changes: 18 additions & 18 deletions dev/Examples/chaining.html

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions dev/Examples/containers.html

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions dev/Examples/properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
gradegen = map(Base.splat(Dict{String,Int}), PropCheck.tuple(isample(1:10), grade))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Integrated{PropCheck.Tree{Dict{String, Int64}}}(genF)</code></pre><div class="admonition is-info"><header class="admonition-header">Different ranges</header><div class="admonition-body"><p><code>isample(2:10, PropCheck.shrinkTowards(2))</code> gives us an integrated shrinker producing elements in the range <code>2:10</code>. They&#39;ll shrink towards <code>2</code>.</p></div></div><p>Now to our student:</p><pre><code class="language-julia hljs">students = map(Base.splat(Student), PropCheck.interleave(itype(String), itype(Int), gradegen))
check(passes, students)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Main.Student(&quot;&quot;, 0, Dict(&quot;\0&quot; =&gt; 0, &quot;&quot; =&gt; 0))</code></pre><p>And we can see that just generic shrinking produced the minimal student that doesn&#39;t pass. A nameless, ageless student who received no points on two subjects. Note that due to us using a dictionary (which forces unique keys), the two subjects have different names!</p><p>PropCheck tries to be fast when it can, so this reduction barely took any time:</p><pre><code class="language-julia hljs">pairs(@timed @time check(passes, students))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">pairs(::NamedTuple) with 5 entries:
:value =&gt; Student(&quot;&quot;, 0, Dict(&quot;\0&quot;=&gt;0, &quot;&quot;=&gt;0))
:time =&gt; 4.65202
:bytes =&gt; 218556512
:gctime =&gt; 0.206392
:gcstats =&gt; GC_Diff(218556512, 0, 0, 2284188, 3128, 4, 206391527, 5, 2)</code></pre><p>Let&#39;s say now that we expect our students to be between <code>10-18</code> years old, have a name consisting of <code>5-20</code> lowercase ASCII letters and having between 5 and 10 subjects of <code>5-15</code> lowercase ASCII letters. We could build them like this:</p><pre><code class="language-julia hljs">subj_name = PropCheck.str(isample(5:15), isample(&#39;a&#39;:&#39;z&#39;))
:time =&gt; 2.7658
:bytes =&gt; 151738848
:gctime =&gt; 0.0163801
:gcstats =&gt; GC_Diff(151738848, 0, 0, 1609645, 2053, 0, 16380098, 3, 0)</code></pre><p>Let&#39;s say now that we expect our students to be between <code>10-18</code> years old, have a name consisting of <code>5-20</code> lowercase ASCII letters and having between 5 and 10 subjects of <code>5-15</code> lowercase ASCII letters. We could build them like this:</p><pre><code class="language-julia hljs">subj_name = PropCheck.str(isample(5:15), isample(&#39;a&#39;:&#39;z&#39;))
grade = map(Base.splat(Pair), PropCheck.interleave(subj_name, isample(0:100))) # random subject, with points in 0:100
gradegen = map(Base.splat(Dict{String,Int}), PropCheck.vector(isample(5:10), grade))
stud_name = PropCheck.str(isample(5:20), isample(&#39;a&#39;:&#39;z&#39;)) # we don&#39;t want names shorter than 5 characters
stud_age = isample(10:18) # our youngest student can only be 10 years old
students = map(Base.splat(Student), PropCheck.interleave(stud_name, stud_age, gradegen))
collect(Iterators.take(students, 5))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">5-element Vector{PropCheck.Tree{Main.Student}}:
Tree(Main.Student(&quot;ggmtxofjxmwdiklmng&quot;, 17, Dict(&quot;pytlcxmvdawwkdu&quot; =&gt; 46, &quot;bzfhszbc&quot; =&gt; 46, &quot;fjcfhgscf&quot; =&gt; 47, &quot;yvotf&quot; =&gt; 52, &quot;joabfdifayupk&quot; =&gt; 21)))
Tree(Main.Student(&quot;iaqlujx&quot;, 10, Dict(&quot;cewdzqn&quot; =&gt; 42, &quot;txfvmdarj&quot; =&gt; 54, &quot;uzhpvgyarrkxhqw&quot; =&gt; 62, &quot;gqnoiaqawe&quot; =&gt; 34, &quot;cuvpldlvhxtmu&quot; =&gt; 33)))
Tree(Main.Student(&quot;wxjpbklyegwgh&quot;, 10, Dict(&quot;xsjvhnudjoh&quot; =&gt; 54, &quot;sxlmzhktj&quot; =&gt; 4, &quot;brgequglymxsian&quot; =&gt; 97, &quot;epayousizofvaql&quot; =&gt; 93, &quot;bhvasmpgfx&quot; =&gt; 73, &quot;qewkkzlixav&quot; =&gt; 44, &quot;gerhwjmo&quot; =&gt; 83)))
Tree(Main.Student(&quot;ldunnjryebqpp&quot;, 16, Dict(&quot;kqhaqqscwtwotjz&quot; =&gt; 97, &quot;cgwhl&quot; =&gt; 100, &quot;sugaxief&quot; =&gt; 40, &quot;imqbyijnzi&quot; =&gt; 45, &quot;vazaeqrjky&quot; =&gt; 94, &quot;kgojtg&quot; =&gt; 22, &quot;ycesdrvbvpezk&quot; =&gt; 40)))
Tree(Main.Student(&quot;rmhyezynaagma&quot;, 18, Dict(&quot;wmqshhu&quot; =&gt; 33, &quot;ktpoujygxde&quot; =&gt; 71, &quot;hadyrxnfly&quot; =&gt; 90, &quot;hmohfpehjjuwagt&quot; =&gt; 81, &quot;hzvdghqzqvqctrd&quot; =&gt; 97, &quot;roncnkfqajhnc&quot; =&gt; 39, &quot;tuneuskllympcb&quot; =&gt; 78, &quot;hrpddqhi&quot; =&gt; 67)))</code></pre><p>which will preserve the invariants described during generation when shrinking:</p><pre><code class="language-julia hljs">check(passes, students)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Main.Student(&quot;aaaaa&quot;, 10, Dict(&quot;aaaaa&quot; =&gt; 0, &quot;aaaab&quot; =&gt; 0))</code></pre><p>The student returned has a name with 5 characters, is 10 years old, has taken two distinct subjects and received 0 points in both of them. We can do much better if we modify our generators a bit, at the cost of having a smaller pool of possible tests:</p><pre><code class="language-julia hljs"># sample their classes
Tree(Main.Student(&quot;ldohxlnvhzf&quot;, 11, Dict(&quot;njlhlk&quot; =&gt; 10, &quot;jyazudgfwjm&quot; =&gt; 34, &quot;kldjdofbqm&quot; =&gt; 61, &quot;mklwz&quot; =&gt; 1, &quot;hwhcsjlysw&quot; =&gt; 51, &quot;oivbnjlwjzfhkz&quot; =&gt; 53, &quot;znhznqya&quot; =&gt; 18)))
Tree(Main.Student(&quot;rdgbruemsbyve&quot;, 11, Dict(&quot;szmppfsaaol&quot; =&gt; 11, &quot;wkvhycvxif&quot; =&gt; 29, &quot;gpufc&quot; =&gt; 74, &quot;ddstcehimm&quot; =&gt; 79, &quot;qauybcrjscb&quot; =&gt; 0, &quot;cxghfryoaeipmam&quot; =&gt; 95, &quot;awkdrsxooqevoa&quot; =&gt; 2)))
Tree(Main.Student(&quot;oyhvaundfeife&quot;, 17, Dict(&quot;celzedkj&quot; =&gt; 69, &quot;vgtwxvxqrrzfu&quot; =&gt; 35, &quot;sbcgmqxqfw&quot; =&gt; 5, &quot;vnsoctu&quot; =&gt; 44, &quot;kumdfizlgqpzhgx&quot; =&gt; 38, &quot;efjykojruz&quot; =&gt; 42, &quot;mpqgovf&quot; =&gt; 81, &quot;snzmowngejfeb&quot; =&gt; 46, &quot;eczlxa&quot; =&gt; 20)))
Tree(Main.Student(&quot;zlvxhnmlrqxywaijbmv&quot;, 16, Dict(&quot;vekpgowbt&quot; =&gt; 57, &quot;vganhsxshlu&quot; =&gt; 37, &quot;vdzzgr&quot; =&gt; 43, &quot;aieblg&quot; =&gt; 5, &quot;lsjbdpyg&quot; =&gt; 31, &quot;pxpbk&quot; =&gt; 71, &quot;ituuj&quot; =&gt; 76, &quot;zlhymore&quot; =&gt; 72, &quot;gnmbxjpkty&quot; =&gt; 31)))
Tree(Main.Student(&quot;napyagmehawc&quot;, 13, Dict(&quot;qamhqzjpadhtrq&quot; =&gt; 36, &quot;zpgjyc&quot; =&gt; 0, &quot;ltjeqw&quot; =&gt; 27, &quot;zumtwuxawiy&quot; =&gt; 67, &quot;psqwx&quot; =&gt; 90, &quot;oqorpocqxaxsb&quot; =&gt; 58, &quot;ksvvafhzxjkvzuv&quot; =&gt; 80, &quot;bkvyaldoedppuj&quot; =&gt; 36, &quot;fwusstukwrqpm&quot; =&gt; 93, &quot;yvylpxxyy&quot; =&gt; 68…)))</code></pre><p>which will preserve the invariants described during generation when shrinking:</p><pre><code class="language-julia hljs">check(passes, students)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Main.Student(&quot;aaaaa&quot;, 10, Dict(&quot;aaaaa&quot; =&gt; 0, &quot;aaaab&quot; =&gt; 0))</code></pre><p>The student returned has a name with 5 characters, is 10 years old, has taken two distinct subjects and received 0 points in both of them. We can do much better if we modify our generators a bit, at the cost of having a smaller pool of possible tests:</p><pre><code class="language-julia hljs"># sample their classes
subj_name = isample([&quot;Geography&quot;, &quot;Mathematics&quot;, &quot;English&quot;, &quot;Arts &amp; Crafts&quot;, &quot;Music&quot;, &quot;Science&quot;], PropCheck.noshrink)

# random subject, with points in 0:100
Expand All @@ -53,11 +53,11 @@
@testset &quot;All students pass&quot; begin
@test check(passes, students)
end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">┌ Info: Found counterexample for &#39;passes&#39;, beginning shrinking...
└ Counterexample = Main.Student(&quot;Bob&quot;, 13, Dict(&quot;Mathematics&quot; =&gt; 34, &quot;English&quot; =&gt; 91, &quot;Geography&quot; =&gt; 21, &quot;Arts &amp; Crafts&quot; =&gt; 76))
[ Info: 26 counterexamples found for passes
└ Counterexample = Main.Student(&quot;Bob&quot;, 18, Dict(&quot;English&quot; =&gt; 14, &quot;Mathematics&quot; =&gt; 91, &quot;Science&quot; =&gt; 14, &quot;Geography&quot; =&gt; 61, &quot;Music&quot; =&gt; 65, &quot;Arts &amp; Crafts&quot; =&gt; 27))
[ Info: 46 counterexamples found for passes
All students pass: Error During Test at properties.md:99
Expression evaluated to non-Boolean
Expression: check(passes, students)
Value: Main.Student(&quot;Bob&quot;, 10, Dict(&quot;Mathematics&quot; =&gt; 0, &quot;English&quot; =&gt; 0, &quot;Geography&quot; =&gt; 0, &quot;Arts &amp; Crafts&quot; =&gt; 0))
Value: Main.Student(&quot;Bob&quot;, 10, Dict(&quot;English&quot; =&gt; 0, &quot;Mathematics&quot; =&gt; 0, &quot;Science&quot; =&gt; 0, &quot;Geography&quot; =&gt; 0, &quot;Music&quot; =&gt; 0))
Test Summary: | Error Total Time
All students pass | 1 1 0.3s</code></pre><div class="admonition is-info"><header class="admonition-header">Dictionaries</header><div class="admonition-body"><p>While this example directly splats a vector into the <code>Dict{String,Int}</code> constructor, this is in general not optimal. <code>Dict</code> will delete previously set values if a key is duplicated, so it&#39;s usually better to generate a list of unique keys first, which is then combined with a seperately generated list of values. In order to generate that list of unique keys, you can use <a href="../api.html#PropCheck.iunique-Union{Tuple{Vector{T}}, Tuple{T}, Tuple{Vector{T}, Any}} where T"><code>iunique</code></a>.</p></div></div><div class="admonition is-info"><header class="admonition-header">Test stdlib and `@test`</header><div class="admonition-body"><p>Currently, <code>check</code> returns the minimized failing testcase, so that <code>@test</code> displays that the test has evaluated to a non-Boolean. This is suboptimal and misuses the <code>@test</code> macro. In the future, this may be replaced by a <code>@check</code> macro, which creates a custom <code>TestSet</code> for recording what kind of failure was experienced.</p></div></div></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="containers.html">« Generating Containers</a><a class="docs-footer-nextpage" href="chaining.html">Generator Chaining »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.3.0 on <span class="colophon-date" title="Friday 8 March 2024 09:55">Friday 8 March 2024</span>. Using Julia version 1.10.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
All students pass | 1 1 0.4s</code></pre><div class="admonition is-info"><header class="admonition-header">Dictionaries</header><div class="admonition-body"><p>While this example directly splats a vector into the <code>Dict{String,Int}</code> constructor, this is in general not optimal. <code>Dict</code> will delete previously set values if a key is duplicated, so it&#39;s usually better to generate a list of unique keys first, which is then combined with a seperately generated list of values. In order to generate that list of unique keys, you can use <a href="../api.html#PropCheck.iunique-Union{Tuple{Vector{T}}, Tuple{T}, Tuple{Vector{T}, Any}} where T"><code>iunique</code></a>.</p></div></div><div class="admonition is-info"><header class="admonition-header">Test stdlib and `@test`</header><div class="admonition-body"><p>Currently, <code>check</code> returns the minimized failing testcase, so that <code>@test</code> displays that the test has evaluated to a non-Boolean. This is suboptimal and misuses the <code>@test</code> macro. In the future, this may be replaced by a <code>@check</code> macro, which creates a custom <code>TestSet</code> for recording what kind of failure was experienced.</p></div></div></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="containers.html">« Generating Containers</a><a class="docs-footer-nextpage" href="chaining.html">Generator Chaining »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.3.0 on <span class="colophon-date" title="Wednesday 13 March 2024 08:56">Wednesday 13 March 2024</span>. Using Julia version 1.10.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 5cb0c93

Please sign in to comment.