Skip to content

Randomness

[Source]

All draw methods are partial: they error during replay when the recorded choice sequence is exhausted or when a type/range mismatch is detected. In plain mode (user-constructed Randomness), draws never error.

Integer methods generate values in the closed interval [min, max]. Floating-point methods scale onto [min, max]; min is always reachable, max is an approximate upper bound due to floating-point rounding.

class ref Randomness

Constructors

create

[Source]

new ref create(
  seed1: U64 val = 42,
  seed2: U64 val = 0)
: Randomness ref^

Parameters

  • seed1: U64 val = 42
  • seed2: U64 val = 0

Returns


Public Functions

u8

[Source]

Generate a U8 in closed interval [min, max].

fun ref u8(
  min: U8 val = U8.min_value(),
  max: U8 val = U8.max_value())
: U8 val ?

Parameters

  • min: U8 val = U8.min_value()
  • max: U8 val = U8.max_value()

Returns

  • U8 val ?

u16

[Source]

Generate a U16 in closed interval [min, max].

fun ref u16(
  min: U16 val = U16.min_value(),
  max: U16 val = U16.max_value())
: U16 val ?

Parameters

  • min: U16 val = U16.min_value()
  • max: U16 val = U16.max_value()

Returns


u32

[Source]

Generate a U32 in closed interval [min, max].

fun ref u32(
  min: U32 val = U32.min_value(),
  max: U32 val = U32.max_value())
: U32 val ?

Parameters

  • min: U32 val = U32.min_value()
  • max: U32 val = U32.max_value()

Returns


u64

[Source]

Generate a U64 in closed interval [min, max].

fun ref u64(
  min: U64 val = U64.min_value(),
  max: U64 val = U64.max_value())
: U64 val ?

Parameters

  • min: U64 val = U64.min_value()
  • max: U64 val = U64.max_value()

Returns


u128

[Source]

Generate a U128 in closed interval [min, max].

fun ref u128(
  min: U128 val = U128.min_value(),
  max: U128 val = U128.max_value())
: U128 val ?

Parameters

  • min: U128 val = U128.min_value()
  • max: U128 val = U128.max_value()

Returns


ulong

[Source]

Generate a ULong in closed interval [min, max].

fun ref ulong(
  min: ULong val = ULong.min_value(),
  max: ULong val = ULong.max_value())
: ULong val ?

Parameters

  • min: ULong val = ULong.min_value()
  • max: ULong val = ULong.max_value()

Returns


usize

[Source]

Generate a USize in closed interval [min, max].

fun ref usize(
  min: USize val = USize.min_value(),
  max: USize val = USize.max_value())
: USize val ?

Parameters

  • min: USize val = USize.min_value()
  • max: USize val = USize.max_value()

Returns


i8

[Source]

Generate an I8 in closed interval [min, max].

fun ref i8(
  min: I8 val = I8.min_value(),
  max: I8 val = I8.max_value())
: I8 val ?

Parameters

  • min: I8 val = I8.min_value()
  • max: I8 val = I8.max_value()

Returns

  • I8 val ?

i16

[Source]

Generate an I16 in closed interval [min, max].

fun ref i16(
  min: I16 val = I16.min_value(),
  max: I16 val = I16.max_value())
: I16 val ?

Parameters

  • min: I16 val = I16.min_value()
  • max: I16 val = I16.max_value()

Returns


i32

[Source]

Generate an I32 in closed interval [min, max].

fun ref i32(
  min: I32 val = I32.min_value(),
  max: I32 val = I32.max_value())
: I32 val ?

Parameters

  • min: I32 val = I32.min_value()
  • max: I32 val = I32.max_value()

Returns


i64

[Source]

Generate an I64 in closed interval [min, max].

fun ref i64(
  min: I64 val = I64.min_value(),
  max: I64 val = I64.max_value())
: I64 val ?

Parameters

  • min: I64 val = I64.min_value()
  • max: I64 val = I64.max_value()

Returns


i128

[Source]

Generate an I128 in closed interval [min, max].

fun ref i128(
  min: I128 val = I128.min_value(),
  max: I128 val = I128.max_value())
: I128 val ?

Parameters

  • min: I128 val = I128.min_value()
  • max: I128 val = I128.max_value()

Returns


ilong

[Source]

Generate an ILong in closed interval [min, max].

fun ref ilong(
  min: ILong val = ILong.min_value(),
  max: ILong val = ILong.max_value())
: ILong val ?

Parameters

  • min: ILong val = ILong.min_value()
  • max: ILong val = ILong.max_value()

Returns


isize

[Source]

Generate an ISize in closed interval [min, max].

fun ref isize(
  min: ISize val = ISize.min_value(),
  max: ISize val = ISize.max_value())
: ISize val ?

Parameters

  • min: ISize val = ISize.min_value()
  • max: ISize val = ISize.max_value()

Returns


f32

[Source]

Generate an F32 in the range from min to max.

fun ref f32(
  min: F32 val = 0.0,
  max: F32 val = 1.0)
: F32 val ?

Parameters

  • min: F32 val = 0.0
  • max: F32 val = 1.0

Returns


f64

[Source]

Generate an F64 in the range from min to max.

fun ref f64(
  min: F64 val = 0.0,
  max: F64 val = 1.0)
: F64 val ?

Parameters

  • min: F64 val = 0.0
  • max: F64 val = 1.0

Returns


bool

[Source]

Generate a random Bool value.

fun ref bool()
: Bool val ?

Returns


forced_bool

[Source]

Record a predetermined Bool. The shrinker will not attempt to change this choice. Use when the outcome is fixed by the generator's structure (e.g., elements below a collection minimum).

fun ref forced_bool(
  value: Bool val)
: Bool val ?

Parameters

Returns


shuffle[T: T]

[Source]

Shuffle the array in place using Fisher-Yates, recording one integer choice per element as the swap index.

fun ref shuffle[T: T](
  array: Array[T] ref)
: None val ?

Parameters

Returns


start_span

[Source]

Mark the beginning of a structural span in the choice sequence. Spans let the shrinker understand generator structure — for example, which choices belong to a single collection element.

fun ref start_span(
  label: SpanLabel)
: None val

Parameters

Returns


end_span

[Source]

Close the most recently opened span. If discard is true, the span is marked as discarded (e.g., a filter rejection).

Errors if no span is open (mismatched start_span/end_span calls).

fun ref end_span(
  discard: Bool val = false)
: None val ?

Parameters

  • discard: Bool val = false

Returns