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
Name | Type | Description |
---|---|---|
seed? | number | |
runsPerTest? | number | |
simplify? | boolean | If 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
Name | Type |
---|---|
minLength? | number |
maxLength? | number |
Returns
asciiBytes
▸ asciiBytes(minLength?
, maxLength?
): ValueGenerator
Returns a generator for bytearrays containing only valid ascii characters
Parameters
Name | Type |
---|---|
minLength? | number |
maxLength? | number |
Returns
bool
▸ bool(): ValueGenerator
Returns a generator for booleans, wrapped with ConstrData
Returns
bytes
▸ bytes(minLength?
, maxLength?
): ValueGenerator
Returns a generator for bytearrays
Parameters
Name | Type |
---|---|
minLength? | number |
maxLength? | number |
Returns
constr
▸ constr(tag
, ...fieldGenerators
): ValueGenerator
Returns a generator for tagged constr
Parameters
Name | Type |
---|---|
tag | number | NumberGenerator |
...fieldGenerators | ValueGenerator [] |
Returns
int
▸ int(min?
, max?
): ValueGenerator
Returns a generator for whole numbers between min and max, wrapped with IntData
Parameters
Name | Type |
---|---|
min? | number |
max? | number |
Returns
list
▸ list(itemGenerator
, minLength?
, maxLength?
): ValueGenerator
Returns a generator for lists
Parameters
Name | Type |
---|---|
itemGenerator | ValueGenerator |
minLength? | number |
maxLength? | number |
Returns
map
▸ map(keyGenerator
, valueGenerator
, minLength?
, maxLength?
): ValueGenerator
Returns a generator for maps
Parameters
Name | Type |
---|---|
keyGenerator | ValueGenerator |
valueGenerator | ValueGenerator |
minLength? | number |
maxLength? | number |
Returns
newRand
▸ newRand(): NumberGenerator
Returns
object
▸ object(...itemGenerators
): ValueGenerator
Returns a generator for objects
Parameters
Name | Type |
---|---|
...itemGenerators | ValueGenerator [] |
Returns
option
▸ option(someGenerator
, noneProbability?
): ValueGenerator
Returns a generator for options
Parameters
Name | Type |
---|---|
someGenerator | ValueGenerator |
noneProbability? | number |
Returns
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
Name | Type |
---|---|
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
Name | Type |
---|---|
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
Name | Type |
---|---|
min? | number |
max? | number |
Returns
reset
▸ reset(): void
Returns
void
string
▸ string(minLength?
, maxLength?
): ValueGenerator
Returns a generator for strings containing any utf-8 character.
Parameters
Name | Type |
---|---|
minLength? | number |
maxLength? | number |
Returns
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
Name | Type |
---|---|
argGens | ValueGenerator [] |
src | string |
propTest | PropertyTest |
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
Name | Type |
---|---|
paramGenerators | Object |
paramArgs | string [] |
src | string |
propTest | PropertyTest |
nRuns? | number |
simplify? | boolean |
Returns
Promise
<void
>
utf8Bytes
▸ utf8Bytes(minLength?
, maxLength?
): ValueGenerator
Returns a generator for bytearrays the are also valid utf8 strings
Parameters
Name | Type | Description |
---|---|---|
minLength? | number | length of the string, not of the bytearray! |
maxLength? | number | length of the string, not of the bytearray! |