Helios API/ API Reference/ Classes/

FuzzyTest

Helper class for performing fuzzy property-based tests of Helios scripts.

Index

Constructors

constructor

new FuzzyTest(seed?, runsPerTest?, simplify?, printMessages?)

The simplify argument specifies whether optimized versions of the Helios sources should also be tested.

Parameters

NameTypeDescription
seed?number
runsPerTest?number
simplify?booleanIf true then also test the simplified program
printMessages?boolean-

Methods

ascii

ascii(minLength?, maxLength?): ValueGenerator

Returns a generator for strings with ascii characters from 32 (space) to 126 (tilde).

Parameters

NameType
minLength?number
maxLength?number

Returns

ValueGenerator

asciiBytes

asciiBytes(minLength?, maxLength?): ValueGenerator

Returns a generator for bytearrays containing only valid ascii characters

Parameters

NameType
minLength?number
maxLength?number

Returns

ValueGenerator

bool

bool(): ValueGenerator

Returns a generator for booleans, wrapped with ConstrData

Returns

ValueGenerator

bytes

bytes(minLength?, maxLength?): ValueGenerator

Returns a generator for bytearrays

Parameters

NameType
minLength?number
maxLength?number

Returns

ValueGenerator

constr

constr(tag, ...fieldGenerators): ValueGenerator

Returns a generator for tagged constr

Parameters

NameType
tagnumber | NumberGenerator
...fieldGeneratorsValueGenerator[]

Returns

ValueGenerator

int

int(min?, max?): ValueGenerator

Returns a generator for whole numbers between min and max, wrapped with IntData

Parameters

NameType
min?number
max?number

Returns

ValueGenerator

list

list(itemGenerator, minLength?, maxLength?): ValueGenerator

Returns a generator for lists

Parameters

NameType
itemGeneratorValueGenerator
minLength?number
maxLength?number

Returns

ValueGenerator

map

map(keyGenerator, valueGenerator, minLength?, maxLength?): ValueGenerator

Returns a generator for maps

Parameters

NameType
keyGeneratorValueGenerator
valueGeneratorValueGenerator
minLength?number
maxLength?number

Returns

ValueGenerator

newRand

newRand(): NumberGenerator

Returns

NumberGenerator

object

object(...itemGenerators): ValueGenerator

Returns a generator for objects

Parameters

NameType
...itemGeneratorsValueGenerator[]

Returns

ValueGenerator

option

option(someGenerator, noneProbability?): ValueGenerator

Returns a generator for options

Parameters

NameType
someGeneratorValueGenerator
noneProbability?number

Returns

ValueGenerator

rawBool

rawBool(): () => boolean

Returns a generator for booleans,

Returns

fn

▸ (): boolean

Returns a generator for booleans,

Returns

boolean

rawBytes

rawBytes(minLength?, maxLength?): () => number[]

Returns a generator for number[]

Parameters

NameType
minLength?number
maxLength?number

Returns

fn

▸ (): number[]

Returns a generator for number[]

Returns

number[]

rawInt

rawInt(min?, max?): () => bigint

Returns a gernator for whole numbers between min and max

Parameters

NameType
min?number
max?number

Returns

fn

▸ (): bigint

Returns a gernator for whole numbers between min and max

Returns

bigint

real

real(min?, max?): ValueGenerator

Parameters

NameType
min?number
max?number

Returns

ValueGenerator

reset

reset(): void

Returns

void

string

string(minLength?, maxLength?): ValueGenerator

Returns a generator for strings containing any utf-8 character.

Parameters

NameType
minLength?number
maxLength?number

Returns

ValueGenerator

test

test(argGens, src, propTest, nRuns?, simplify?): Promise<void>

Perform a fuzzy/property-based test-run of a Helios source. One value generator must be specified per argument of main.

Throws an error if the propTest fails.

The propTest can simply return a boolean, or can return an object with boolean values, and if any of these booleans is false the propTest fails (the keys can be used to provide extra information).

Parameters

NameType
argGensValueGenerator[]
srcstring
propTestPropertyTest
nRuns?number
simplify?boolean

Returns

Promise<void>

  • throws an error if any of the property tests fail

testParams

testParams(paramGenerators, paramArgs, src, propTest, nRuns?, simplify?): Promise<void>

Parameters

NameType
paramGeneratorsObject
paramArgsstring[]
srcstring
propTestPropertyTest
nRuns?number
simplify?boolean

Returns

Promise<void>

utf8Bytes

utf8Bytes(minLength?, maxLength?): ValueGenerator

Returns a generator for bytearrays the are also valid utf8 strings

Parameters

NameTypeDescription
minLength?numberlength of the string, not of the bytearray!
maxLength?numberlength of the string, not of the bytearray!

Returns

ValueGenerator