Acton standard libraryTesting
fuzz
fuzz.tolk standard library file
Module for fuzz-testing helpers.
This module contains helpers intended specifically for parameterized tests
annotated with dotted @test.fuzz annotations: @test.fuzz,
@test.fuzz(<runs>), or @test.fuzz({ ... }).
Examples:
import "@acton/testing/expect"
import "@acton/testing/fuzz"
@test.fuzz
get fun `test balance stays bounded`(value: int) {
val bounded = fuzz.bound(value, 0, 100);
fuzz.assume(bounded != 13);
expect(bounded >= 0).toBeTrue();
}Definitions
fuzz
struct fuzzRoot module for fuzz-testing helpers.
This structure groups fuzz-specific helpers under a dedicated namespace.
Source codefuzz.assume
fun fuzz.assume(
condition: bool,
message: string = "",
loc: string = reflect.sourceLocationAsString(),
): voidRejects the current fuzz input when condition is false.
Outside fuzz tests this is reported as a regular failure.
Source codefuzz.bound
fun fuzz.bound<T>(
value: T,
minValue: T,
maxValue: T,
loc: string = reflect.sourceLocationAsString(),
): TMaps an integer-like value into the inclusive range [minValue, maxValue].
Values already in range stay unchanged, while out-of-range values wrap back into the target interval.
Source codeLast updated on