Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-helium-α #1

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
This library contains a set of tools, mainly for testing purposes:

- [`print`](#print) (pretty-print data with label)
- [`to_data`](#to_data) (upcast any serialisable type to `Data`)
- [`collections`](#collections) (contains some `list` and `zip3` functions)
- [`fuzzy`](#fuzzy) (`address`, `assets`, `certificate`, `governance`, and `transaction` fuzzers)
- [`time`](#time) (to `add`/`subtract` intervals and unwrapping finite time, taking its inclusivity into account)
- [`tx`](#tx) (helps mocking and constructing transaction data using the `transaction` builder)

| ℹ️ | Package info | aiken-extra/test_kit | 🧰 |
| --- | --------------- | ---------------------------------------------------------------------------------------- | --- |
| 🔴 | **Version** | **v0.0.1** | 🛠️ |
| 🔴 | **Codename** | **hydrogen** | 💧 |
| 🔴 | **Version** | **v0.0.2** | 🛠️ |
| 🔴 | **Codename** | **helium** | 🔥 |
| 🔴 | **Status** | **alpha** | 🧪 |
| 🟢 | **Depends on** | [**aiken-lang/fuzz v2.1.0**](https://github.com/aiken-lang/fuzz/releases/tag/v2.1.0) | ✅ |
| 🟢 | **Depends on** | [**aiken-lang/stdlib v2.2.0**](https://github.com/aiken-lang/stdlib/releases/tag/v2.2.0) | ✅ |
| 🟢 | **Tested with** | [**aiken v1.1.9**](https://github.com/aiken-lang/aiken/releases/tag/v1.1.9) | ✅ |

<!-- | 🟢 | **Version** | **boron** | ✅ | -->

<!-- | 🔴 | **Codename** | **helium** | 🔥 | -->
<!-- | 🟡 | **Codename** | **lithium** | ☄️ | -->
<!-- | 🟡 | **Codename** | **beryllium** | ☄️ | -->

Expand All @@ -38,6 +38,16 @@ print("Label", data) // fuzz.label(@"Label: cbor.diagnostic(data)")
By calling [`fuzz.label`](https://aiken-lang.github.io/fuzz/aiken/fuzz.html#label) internally,
`print` will also work with property testing.

## `to_data`

Upcast any serialisable type to `Data`:

```gleam
use test_kit.{to_data}

any |> to_data // let data: Data = any
```

## `collections`

Zip3:
Expand All @@ -62,14 +72,18 @@ use test_kit/collections/logic

## `fuzzy`

Tuple fuzzer:
Tuple and unique fuzzers:

```gleam
use test_kit/fuzzy

// A convenient way of generating tuples instead of doing map:
test prop_tuple((a, b) via fuzzy.tuple(fuzzer_a, fuzzer_b)) { .. }

// also available: tuple3 to tuple9

// Generates 3 unique elements from the given fuzzer:
test prop_unique((x1, x2, x3) via fuzzy.unique3(fuzzer_x)) { .. }
// other element counts are also available
```

Transaction data fuzzers:
Expand Down
2 changes: 1 addition & 1 deletion aiken.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "aiken-extra/test_kit"
version = "hydrogen-α"
version = "helium-α"
compiler = "v1.1.9"
plutus = "v3"
license = "Apache-2.0"
Expand Down
28 changes: 19 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@
<h2>
<a href="./">test_kit</a>
<span id="project-version">
<span>hydrogen-α </span>
<span>helium-α </span>
</span>
<script>
"use strict";

if ("undefined" !== typeof versionNodes) {
const currentVersion = "vhydrogen-α";
const currentVersion = "vhelium-α";
if (! versionNodes.find(element => element.version === currentVersion)) {
versionNodes.unshift({ version: currentVersion, url: "#" });
}
Expand Down Expand Up @@ -272,21 +272,21 @@ <h1>test_kit</h1>
<p>This library contains a set of tools, mainly for testing purposes:</p>
<ul>
<li><a href="#print"><code>print</code></a> (pretty-print data with label)</li>
<li><a href="#to_data"><code>to_data</code></a> (upcast any serialisable type to <code>Data</code>)</li>
<li><a href="#collections"><code>collections</code></a> (contains some <code>list</code> and <code>zip3</code> functions)</li>
<li><a href="#fuzzy"><code>fuzzy</code></a> (<code>address</code>, <code>assets</code>, <code>certificate</code>, <code>governance</code>, and <code>transaction</code> fuzzers)</li>
<li><a href="#time"><code>time</code></a> (to <code>add</code>/<code>subtract</code> intervals and unwrapping finite time, taking its inclusivity into account)</li>
<li><a href="#tx"><code>tx</code></a> (helps mocking and constructing transaction data using the <code>transaction</code> builder)</li>
</ul>
<table><thead><tr><th>ℹ️</th><th>Package info</th><th>aiken-extra/test_kit</th><th>🧰</th></tr></thead><tbody>
<tr><td>🔴</td><td><strong>Version</strong></td><td><strong>v0.0.1</strong></td><td>🛠️</td></tr>
<tr><td>🔴</td><td><strong>Codename</strong></td><td><strong>hydrogen</strong></td><td>💧</td></tr>
<tr><td>🔴</td><td><strong>Version</strong></td><td><strong>v0.0.2</strong></td><td>🛠️</td></tr>
<tr><td>🔴</td><td><strong>Codename</strong></td><td><strong>helium</strong></td><td>🔥</td></tr>
<tr><td>🔴</td><td><strong>Status</strong></td><td><strong>alpha</strong></td><td>🧪</td></tr>
<tr><td>🟢</td><td><strong>Depends on</strong></td><td><a href="https://github.com/aiken-lang/fuzz/releases/tag/v2.1.0"><strong>aiken-lang/fuzz v2.1.0</strong></a></td><td>✅</td></tr>
<tr><td>🟢</td><td><strong>Depends on</strong></td><td><a href="https://github.com/aiken-lang/stdlib/releases/tag/v2.2.0"><strong>aiken-lang/stdlib v2.2.0</strong></a></td><td>✅</td></tr>
<tr><td>🟢</td><td><strong>Tested with</strong></td><td><a href="https://github.com/aiken-lang/aiken/releases/tag/v1.1.9"><strong>aiken v1.1.9</strong></a></td><td>✅</td></tr>
</tbody></table>
<!-- | 🟢 | **Version** | **boron** | ✅ | -->
<!-- | 🔴 | **Codename** | **helium** | 🔥 | -->
<!-- | 🟡 | **Codename** | **lithium** | ☄️ | -->
<!-- | 🟡 | **Codename** | **beryllium** | ☄️ | -->
<!-- | 🟡 | **Status** | **beta** | ⚗️ | -->
Expand All @@ -298,6 +298,12 @@ <h2><code>print</code></h2>
</code></pre>
<p>By calling <a href="https://aiken-lang.github.io/fuzz/aiken/fuzz.html#label"><code>fuzz.label</code></a> internally,
<code>print</code> will also work with property testing.</p>
<h2><code>to_data</code></h2>
<p>Upcast any serialisable type to <code>Data</code>:</p>
<pre><code class="language-aiken">use test_kit.{to_data}

any |&gt; to_data // let data: Data = any
</code></pre>
<h2><code>collections</code></h2>
<p>Zip3:</p>
<pre><code class="language-aiken">use test_kit/collections
Expand All @@ -314,12 +320,16 @@ <h2><code>collections</code></h2>
[..bools] |&gt; logic.any_false // -&gt; True | False
</code></pre>
<h2><code>fuzzy</code></h2>
<p>Tuple fuzzer:</p>
<p>Tuple and unique fuzzers:</p>
<pre><code class="language-aiken">use test_kit/fuzzy

// A convenient way of generating tuples instead of doing map:
test prop_tuple((a, b) via fuzzy.tuple(fuzzer_a, fuzzer_b)) { .. }

// also available: tuple3 to tuple9

// Generates 3 unique elements from the given fuzzer:
test prop_unique((x1, x2, x3) via fuzzy.unique3(fuzzer_x)) { .. }
// other element counts are also available
</code></pre>
<p>Transaction data fuzzers:</p>
<pre><code class="language-aiken">use test_kit/fuzzy/fuzzer.{ .. }
Expand Down Expand Up @@ -521,9 +531,9 @@ <h2><code>tx</code></h2>
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script src="./js/lunr.min.js?v=1.1.9"></script>
<script src="./js/index.js?v=1736322070"></script>
<script src="./js/index.js?v=1736788049"></script>
<!-- Load the search index using JSONP to avoid CORS issues -->
<script src="./search-data.js?v=1736322070"></script>
<script src="./search-data.js?v=1736788049"></script>
<script>
void function() {
if (typeof tippy !== "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion docs/search-data.js

Large diffs are not rendered by default.

67 changes: 62 additions & 5 deletions docs/test_kit.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@
<h2>
<a href="./">test_kit</a>
<span id="project-version">
<span>hydrogen-α </span>
<span>helium-α </span>
</span>
<script>
"use strict";

if ("undefined" !== typeof versionNodes) {
const currentVersion = "vhydrogen-α";
const currentVersion = "vhelium-α";
if (! versionNodes.find(element => element.version === currentVersion)) {
versionNodes.unshift({ version: currentVersion, url: "#" });
}
Expand Down Expand Up @@ -188,6 +188,13 @@ <h2>Source code</h2>



<h2>Types</h2>
<ul>

<li><a href="#Any">Any</a></li>

</ul>




Expand All @@ -196,6 +203,11 @@ <h2>Functions</h2>
<ul>


<li><a href="#to_data">to_data</a></li>




<li><a href="#print">print</a></li>


Expand Down Expand Up @@ -290,6 +302,37 @@ <h1 id="module-name" class="module-name">



<section class="module-members">
<h1 id="module-types" class="module-member-kind">
<a href="#module-types">Types</a>
</h1>


<div class="member">
<div class="member-name">
<h2 id="Any">
<a href="#Any">
Any
</a>
</h2>

<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/helium-α/lib/test_kit.ak#L6-L7"></a>

</div>
<div class="custom-type-constructors">
<div class="rendered-markdown"></div>

<h3>Alias</h3>
<div class="constructor-row">
<svg class="icon icon-at"><use xlink:href="#icon-at"></use></svg>
<pre class="constructor-name"><code class="hljs aiken">Any = Data</code></pre>
</div>

</div>
</div>

</section>




Expand All @@ -300,11 +343,25 @@ <h1 id="module-functions" class="module-member-kind">
</h1>


<div class="member">
<div class="member-name">
<h2 id="to_data"><pre class="hljs language-aiken">to_data(any: Any) -&gt; Data</pre></h2>

<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/helium-α/lib/test_kit.ak#L11-L14"></a>

</div>
<div class="rendered-markdown"><p>A convenient way of upcasting any serialisable type to <code>Data</code>
instead of doing <code>let data: Data = any</code></p>
</div>
</div>



<div class="member">
<div class="member-name">
<h2 id="print"><pre class="hljs language-aiken">print(label: ByteArray, data: Data) -&gt; Void</pre></h2>

<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/hydrogen-α/lib/test_kit.ak#L9-L13"></a>
<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/helium-α/lib/test_kit.ak#L19-L23"></a>

</div>
<div class="rendered-markdown"><p>Pretty-print data with label. This function calls
Expand Down Expand Up @@ -436,9 +493,9 @@ <h2 id="print"><pre class="hljs language-aiken">print(label: ByteArray, data: Da
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script src="./js/lunr.min.js?v=1.1.9"></script>
<script src="./js/index.js?v=1736322070"></script>
<script src="./js/index.js?v=1736788049"></script>
<!-- Load the search index using JSONP to avoid CORS issues -->
<script src="./search-data.js?v=1736322070"></script>
<script src="./search-data.js?v=1736788049"></script>
<script>
void function() {
if (typeof tippy !== "undefined") {
Expand Down
16 changes: 8 additions & 8 deletions docs/test_kit/collections.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@
<h2>
<a href="../">test_kit</a>
<span id="project-version">
<span>hydrogen-α </span>
<span>helium-α </span>
</span>
<script>
"use strict";

if ("undefined" !== typeof versionNodes) {
const currentVersion = "vhydrogen-α";
const currentVersion = "vhelium-α";
if (! versionNodes.find(element => element.version === currentVersion)) {
versionNodes.unshift({ version: currentVersion, url: "#" });
}
Expand Down Expand Up @@ -333,7 +333,7 @@ <h2 id="List" class="module-heading"><a href="#List">List</a></h3>
<div class="member-name">
<h2 id="list_and"><pre class="hljs language-aiken">list_and(bool_list: List&lt;Bool&gt;) -&gt; Bool</pre></h2>

<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/hydrogen-α/lib/test_kit/collections.ak#L7-L9"></a>
<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/helium-α/lib/test_kit/collections.ak#L7-L9"></a>

</div>
<div class="rendered-markdown"><p>Tells whether all of the <code>booleans</code> are <code>true</code></p>
Expand All @@ -346,7 +346,7 @@ <h2 id="list_and"><pre class="hljs language-aiken">list_and(bool_list: List&lt;B
<div class="member-name">
<h2 id="list_or"><pre class="hljs language-aiken">list_or(bool_list: List&lt;Bool&gt;) -&gt; Bool</pre></h2>

<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/hydrogen-α/lib/test_kit/collections.ak#L12-L14"></a>
<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/helium-α/lib/test_kit/collections.ak#L12-L14"></a>

</div>
<div class="rendered-markdown"><p>Tells whether any of the <code>booleans</code> is <code>true</code></p>
Expand All @@ -365,7 +365,7 @@ <h2 id="Zip" class="module-heading"><a href="#Zip">Zip</a></h3>
<div class="member-name">
<h2 id="zip3"><pre class="hljs language-aiken">zip3(az: List&lt;a&gt;, bz: List&lt;b&gt;, cz: List&lt;c&gt;) -&gt; List&lt;(a, b, c)&gt;</pre></h2>

<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/hydrogen-α/lib/test_kit/collections.ak#L19-L22"></a>
<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/helium-α/lib/test_kit/collections.ak#L19-L22"></a>

</div>
<div class="rendered-markdown"><p>Combine 3 lists together into a list of 3-tuple.</p>
Expand All @@ -378,7 +378,7 @@ <h2 id="zip3"><pre class="hljs language-aiken">zip3(az: List&lt;a&gt;, bz: List&
<div class="member-name">
<h2 id="unzip3"><pre class="hljs language-aiken">unzip3(abc: List&lt;(a, b, c)&gt;) -&gt; (List&lt;a&gt;, List&lt;b&gt;, List&lt;c&gt;)</pre></h2>

<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/hydrogen-α/lib/test_kit/collections.ak#L25-L32"></a>
<a class="member-source" alt="view source" title="view source" target="_blank" href="https://github.com/aiken-extra/test_kit/blob/helium-α/lib/test_kit/collections.ak#L25-L32"></a>

</div>
<div class="rendered-markdown"><p>Decompose a list of 3-tuple into a tuple of 3 lists.</p>
Expand Down Expand Up @@ -508,9 +508,9 @@ <h2 id="unzip3"><pre class="hljs language-aiken">unzip3(abc: List&lt;(a, b, c)&g
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script src="../js/lunr.min.js?v=1.1.9"></script>
<script src="../js/index.js?v=1736322070"></script>
<script src="../js/index.js?v=1736788049"></script>
<!-- Load the search index using JSONP to avoid CORS issues -->
<script src="../search-data.js?v=1736322070"></script>
<script src="../search-data.js?v=1736788049"></script>
<script>
void function() {
if (typeof tippy !== "undefined") {
Expand Down
Loading
Loading