Skip to content

Commit

Permalink
build based on ef65810
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Mar 8, 2024
1 parent d26a15c commit e373f5b
Show file tree
Hide file tree
Showing 22 changed files with 1,008 additions and 536 deletions.
1 change: 1 addition & 0 deletions dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-08T08:59:47","documenter_version":"1.3.0"}}
6 changes: 3 additions & 3 deletions dev/Examples/basic.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Basic Usage · PropCheck.jl Documentation</title><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href="../index.html">PropCheck.jl Documentation</a></span></div><form class="docs-search" action="../search.html"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../index.html">Main Page</a></li><li><a class="tocitem" href="../intro.html">Introduction to PBT</a></li><li><span class="tocitem">Examples</span><ul><li class="is-active"><a class="tocitem" href="basic.html">Basic Usage</a></li><li><a class="tocitem" href="structs.html">Generating Structs</a></li><li><a class="tocitem" href="containers.html">Generating Containers</a></li><li><a class="tocitem" href="properties.html">Composing Generators</a></li><li><a class="tocitem" href="chaining.html">Generator Chaining</a></li></ul></li><li><a class="tocitem" href="../shrinktrees.html">Shrinking with <code>Tree</code>s</a></li><li><a class="tocitem" href="../faq.html">FAQ</a></li><li><a class="tocitem" href="../interfaces.html">Interfaces</a></li><li><a class="tocitem" href="../api.html">API Reference</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Examples</a></li><li class="is-active"><a href="basic.html">Basic Usage</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="basic.html">Basic Usage</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/Seelengrab/PropCheck.jl/blob/main/docs/src/Examples/basic.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Basic-Usage"><a class="docs-heading-anchor" href="#Basic-Usage">Basic Usage</a><a id="Basic-Usage-1"></a><a class="docs-heading-anchor-permalink" href="#Basic-Usage" title="Permalink"></a></h1><p>Property based testing is all about having a <em>function</em> to test and a set of <em>properties</em> that should hold on the outputs of that function, given its inputs. It is, in part, a philosophy of test driven design.</p><p>Consider this <code>add</code> function:</p><pre><code class="language-julia hljs">function add(a,b)
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Basic Usage · PropCheck.jl Documentation</title><meta name="title" content="Basic Usage · PropCheck.jl Documentation"/><meta property="og:title" content="Basic Usage · PropCheck.jl Documentation"/><meta property="twitter:title" content="Basic Usage · PropCheck.jl Documentation"/><meta name="description" content="Documentation for PropCheck.jl Documentation."/><meta property="og:description" content="Documentation for PropCheck.jl Documentation."/><meta property="twitter:description" content="Documentation for PropCheck.jl Documentation."/><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../search_index.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href="../index.html">PropCheck.jl Documentation</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../index.html">Main Page</a></li><li><a class="tocitem" href="../intro.html">Introduction to PBT</a></li><li><span class="tocitem">Examples</span><ul><li class="is-active"><a class="tocitem" href="basic.html">Basic Usage</a></li><li><a class="tocitem" href="structs.html">Generating Structs</a></li><li><a class="tocitem" href="containers.html">Generating Containers</a></li><li><a class="tocitem" href="properties.html">Composing Generators</a></li><li><a class="tocitem" href="chaining.html">Generator Chaining</a></li></ul></li><li><a class="tocitem" href="../shrinktrees.html">Shrinking with <code>Tree</code>s</a></li><li><a class="tocitem" href="../faq.html">FAQ</a></li><li><a class="tocitem" href="../interfaces.html">Interfaces</a></li><li><a class="tocitem" href="../api.html">API Reference</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Examples</a></li><li class="is-active"><a href="basic.html">Basic Usage</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="basic.html">Basic Usage</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/Seelengrab/PropCheck.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/Seelengrab/PropCheck.jl/blob/main/docs/src/Examples/basic.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="Basic-Usage"><a class="docs-heading-anchor" href="#Basic-Usage">Basic Usage</a><a id="Basic-Usage-1"></a><a class="docs-heading-anchor-permalink" href="#Basic-Usage" title="Permalink"></a></h1><p>Property based testing is all about having a <em>function</em> to test and a set of <em>properties</em> that should hold on the outputs of that function, given its inputs. It is, in part, a philosophy of test driven design.</p><p>Consider this <code>add</code> function:</p><pre><code class="language-julia hljs">function add(a,b)
a + b
end</code></pre><p>How would we test this? First we have to define the properties we expect to hold. In this case, it&#39;s just the laws of addition:</p><pre><code class="language-julia hljs">commutative(a,b) = add(a,b) == add(b,a)
associative(a,b,c) = add(add(a,b), c) == add(a, add(b,c))
Expand All @@ -12,7 +12,7 @@
end

sumres == add(a,b)
end</code></pre><p>To check that the properties hold, we first need to define a generator for our input. In this case, we are interested in integers, so let&#39;s define a simple generator that just draws some random numbers. The most basic generator PropCheck provides is <a href="../interfaces.html#PropCheck.itype"><code>itype</code></a>, which generates values of a given type:</p><pre><code class="language-julia hljs">using PropCheck
end</code></pre><p>To check that the properties hold, we first need to define a generator for our input. In this case, we are interested in integers, so let&#39;s define a simple generator that just draws some random numbers. The most basic generator PropCheck provides is <a href="../interfaces.html#itype"><code>itype</code></a>, which generates values of a given type:</p><pre><code class="language-julia hljs">using PropCheck

gen = PropCheck.itype(Int)</code></pre><p>which we can then use to check that our <code>identity_add</code> property holds:</p><pre><code class="language-julia-repl hljs">julia&gt; check(identity_add, gen)
true</code></pre><p>Perhaps unsurprisingly (we&#39;re only forwarding to <code>+</code> after all), the property holds - PropCheck was unable to find a counterexample.</p><p>Here&#39;s an example for a property that doesn&#39;t hold, showing how PropCheck handles generated cases that fail:</p><pre><code class="language-julia-repl hljs">julia&gt; failprop(x) = add(x, one(x)) &lt; x;
Expand All @@ -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 1.1s</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="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 0.27.25 on <span class="colophon-date" title="Monday 11 September 2023 09:41">Monday 11 September 2023</span>. Using Julia version 1.9.3.</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="Friday 8 March 2024 08:59">Friday 8 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 e373f5b

Please sign in to comment.