Acton
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 fuzz

Root module for fuzz-testing helpers.

This structure groups fuzz-specific helpers under a dedicated namespace.

Source code

fuzz.assume

fun fuzz.assume(
    condition: bool,
    message: string = "",
    loc: string = reflect.sourceLocationAsString(),
): void

Rejects the current fuzz input when condition is false.

Outside fuzz tests this is reported as a regular failure.

Source code

fuzz.bound

fun fuzz.bound<T>(
    value: T,
    minValue: T,
    maxValue: T,
    loc: string = reflect.sourceLocationAsString(),
): T

Maps 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 code

Last updated on

On this page