Skip to content
Closed
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
141 changes: 141 additions & 0 deletions lib/aiken/fuzz.ak
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,147 @@ fn nub(n: Int, fuzzer: Fuzzer<a>, st: List<a>) -> Fuzzer<a> {
}
}

/// A convenient way of generating tuples instead of doing [`map2`](#map2)
/// ```aiken
/// map2(
/// fuzzer_a, fuzzer_b,
/// fn(a, b) { (a, b) }
/// )
/// ```
pub fn tuple(a: Fuzzer<a>, b: Fuzzer<b>) -> Fuzzer<(a, b)> {
let a, b <- map2(a, b)
(a, b)
}

/// A convenient way of generating tuple3 instead of doing [`map3`](#map3)
/// ```aiken
/// map3(
/// fuzzer_a, fuzzer_b, fuzzer_c,
/// fn(a, b, c) { (a, b, c) }
/// )
/// ```
pub fn tuple3(a: Fuzzer<a>, b: Fuzzer<b>, c: Fuzzer<c>) -> Fuzzer<(a, b, c)> {
let a, b, c <- map3(a, b, c)
(a, b, c)
}

/// A convenient way of generating tuple4 instead of doing [`map4`](#map4)
/// ```aiken
/// map4(
/// fuzzer_a, fuzzer_b, fuzzer_c, fuzzer_d,
/// fn(a, b, c, d) { (a, b, c, d) }
/// )
/// ```
pub fn tuple4(
a: Fuzzer<a>,
b: Fuzzer<b>,
c: Fuzzer<c>,
d: Fuzzer<d>,
) -> Fuzzer<(a, b, c, d)> {
let a, b, c, d <- map4(a, b, c, d)
(a, b, c, d)
}

/// A convenient way of generating tuple5 instead of doing [`map5`](#map5)
/// ```aiken
/// map5(
/// fuzzer_a, fuzzer_b, fuzzer_c, fuzzer_d, fuzzer_e,
/// fn(a, b, c, d, e) { (a, b, c, d, e) }
/// )
/// ```
pub fn tuple5(
a: Fuzzer<a>,
b: Fuzzer<b>,
c: Fuzzer<c>,
d: Fuzzer<d>,
e: Fuzzer<e>,
) -> Fuzzer<(a, b, c, d, e)> {
let a, b, c, d, e <- map5(a, b, c, d, e)
(a, b, c, d, e)
}

/// A convenient way of generating tuple6 instead of doing [`map6`](#map6)
/// ```aiken
/// map6(
/// fuzzer_a, fuzzer_b, fuzzer_c, fuzzer_d, fuzzer_e, fuzzer_f,
/// fn(a, b, c, d, e, f) { (a, b, c, d, e, f) }
/// )
/// ```
pub fn tuple6(
a: Fuzzer<a>,
b: Fuzzer<b>,
c: Fuzzer<c>,
d: Fuzzer<d>,
e: Fuzzer<e>,
f: Fuzzer<f>,
) -> Fuzzer<(a, b, c, d, e, f)> {
let a, b, c, d, e, f <- map6(a, b, c, d, e, f)
(a, b, c, d, e, f)
}

/// A convenient way of generating tuple7 instead of doing [`map7`](#map7)
/// ```aiken
/// map7(
/// fuzzer_a, fuzzer_b, fuzzer_c, fuzzer_d, fuzzer_e, fuzzer_f, fuzzer_g,
/// fn(a, b, c, d, e, f, g) { (a, b, c, d, e, f, g) }
/// )
/// ```
pub fn tuple7(
a: Fuzzer<a>,
b: Fuzzer<b>,
c: Fuzzer<c>,
d: Fuzzer<d>,
e: Fuzzer<e>,
f: Fuzzer<f>,
g: Fuzzer<g>,
) -> Fuzzer<(a, b, c, d, e, f, g)> {
let a, b, c, d, e, f, g <- map7(a, b, c, d, e, f, g)
(a, b, c, d, e, f, g)
}

/// A convenient way of generating tuple8 instead of doing [`map8`](#map8)
/// ```aiken
/// map8(
/// fuzzer_a, fuzzer_b, fuzzer_c, fuzzer_d, fuzzer_e, fuzzer_f, fuzzer_g, fuzzer_h,
/// fn(a, b, c, d, e, f, g, h) { (a, b, c, d, e, f, g, h) }
/// )
/// ```
pub fn tuple8(
a: Fuzzer<a>,
b: Fuzzer<b>,
c: Fuzzer<c>,
d: Fuzzer<d>,
e: Fuzzer<e>,
f: Fuzzer<f>,
g: Fuzzer<g>,
h: Fuzzer<h>,
) -> Fuzzer<(a, b, c, d, e, f, g, h)> {
let a, b, c, d, e, f, g, h <- map8(a, b, c, d, e, f, g, h)
(a, b, c, d, e, f, g, h)
}

/// A convenient way of generating tuple9 instead of doing [`map9`](#map9)
/// ```aiken
/// map9(
/// fuzzer_a, fuzzer_b, fuzzer_c, fuzzer_d, fuzzer_e, fuzzer_f, fuzzer_g, fuzzer_h, fuzzer_i,
/// fn(a, b, c, d, e, f, g, h, i) { (a, b, c, d, e, f, g, h, i) }
/// )
/// ```
pub fn tuple9(
a: Fuzzer<a>,
b: Fuzzer<b>,
c: Fuzzer<c>,
d: Fuzzer<d>,
e: Fuzzer<e>,
f: Fuzzer<f>,
g: Fuzzer<g>,
h: Fuzzer<h>,
i: Fuzzer<i>,
) -> Fuzzer<(a, b, c, d, e, f, g, h, i)> {
let a, b, c, d, e, f, g, h, i <- map9(a, b, c, d, e, f, g, h, i)
(a, b, c, d, e, f, g, h, i)
}

// ## Combining

/// Combine a [Fuzzer](https://aiken-lang.github.io/prelude/aiken.html#Fuzzer) with the result of a another one.
Expand Down
Loading