This section will describe the methods of QuickCheck
‣ QC_MakeRandomArgument( ObjectDescription, RandomSource, limit ) | ( function ) |
Create a random object as described by ObjectDescription of size at most limit using RandomSource. How limit is interpreted will vary depending on the type of object.
‣ QC_Check( arguments, function[, config] ) | ( function ) |
Run tests on function with arguments as described in arguments.
‣ QC_CheckEqual( arguments, functionL, functionR[, config] ) | ( function ) |
Check that, given the same list of arguments as described in arguments, functionL and function return the same value.
‣ QC_LastFailure( ) | ( function ) |
Return the function called, and arguments given, if the most recent call to QC_Check or QC_CheckEqual failed on a particular input.
Returns a record containing args (the arguments) and a function func (if QC_Check failed) or a list of functions funcs (if QC_CheckEqual failed). Returns false otherwise.
‣ QC_RerunLastFailure( ) | ( function ) |
Rerun the last test which failed, as given by QC_LastFailure (3.1-4). This is most useful if a test in a '.tst' file failed, as this will allow the test to enter the break loop. Returns fail if QC_LastFailure (3.1-4) returns false.
‣ QC_SetConfig( config ) | ( function ) |
Set config options for QuickCheck globally, by passing a record. It is not required to set all options.
Current options are:
tests: Number of tests to run (default 500)
limit: The size of the largest object to create (default 9)
ramp: Number of tests, including skipped ones, to run at each size before increasing it (default 30)
seed: Initial random seed (default 1)
catchErrors: If true, an error in the tested function counts as a failure; if false, it enters the break loop (default true)
‣ QC_GetConfig( ) | ( function ) |
Get the current global configuration for QuickCheck, as a record
‣ QC_Skip | ( global variable ) |
A function tested by QC_Check (3.1-2) or QC_CheckEqual (3.1-3) can return QC_Skip if its arguments do not satisfy its requirements (for example, if it needs an intransitive group, or an integer which is not prime). Skipped tests do not count as failures or towards the number of tests. To avoid infinite loops, if 100 times the requested number of tests are skipped, the check stops and returns false.
‣ QC_RegisterFilterGen( filter, gen ) | ( function ) |
Register gen as a generator for arguments described by the filter filter. gen is called as gen(rs, limit), where rs is a random source and limit a positive integer bounding the size of the value. It is up to gen to decide how to interpret limit. Smaller values of limit are used first, so simple inputs are tested before complex ones. Values not in filter are discarded and regenerated, with an error after 100 attempts. This lets a generator serve a more specific filter, for example an abelian permutation group when only a gen for permutation groups has been installed.
An argument description is either a filter with a registered generator (see QC_RegisterFilterGen (3.1-9)), or a function gen(rs, limit). The functions below build descriptions from other descriptions.
‣ QC_ListOf( desc ) | ( function ) |
Describes a list of between 0 and limit values described by desc.
gap> QC_Check([QC_ListOf(QC_PairOf(IsPosInt))], > l -> ForAll(l, p -> Length(p) = 2 and ForAll(p, IsPosInt))); true
‣ QC_FixedLengthListOf( desc, len ) | ( function ) |
Describes a list of len values described by desc.
‣ QC_PairOf( desc ) | ( function ) |
Describes a list of length two, whose entries are described by desc.
‣ QC_SetOf( desc ) | ( function ) |
Describes a set of between 0 and limit values described by desc.
‣ QC_ElementOf( coll ) | ( function ) |
Describes a random element of the collection coll. This ignores limit.
generated by GAPDoc2HTML