Skip to content

QuickCheq: property based testing

Overview

For a general overview of QuickCheq, please refer to the QuickCheq section of the userguide.

.qch.genS.arb

Parameter(s):

Name Type Description
<param> dict Generator definition
<param>.arb fn
<param>.shrink fn
<param>.less fn
<param>.maxSize fn

Returns:

Name Type Description
fn generator

.qch.genS.shrink

Parameter(s):

Name Type Description
<param> dict Generator definition
<param>.arb fn
<param>.shrink fn
<param>.less fn
<param>.maxSize fn

Returns:

Name Type Description
fn create a number of possibly shrunk values from a value

.qch.genS.less

Parameter(s):

Name Type Description
<param> dict Generator definition
<param>.arb fn
<param>.shrink fn
<param>.less fn
<param>.maxSize fn

Returns:

Name Type Description
fn return true if left arg is less than right arg

.qch.genS.with.maxSize

Parameter(s):

Name Type Description
fn maximum size/length to generate
<param> dict Generator definition
<param>.arb fn
<param>.shrink fn
<param>.less fn
<param>.maxSize fn

Returns:

Name Type Description
<returns> dict Generator definition
<returns>.arb fn
<returns>.shrink fn
<returns>.less fn
<returns>.maxSize fn

.qch.genS.maxSize

Parameter(s):

Name Type Description
<param> dict Generator definition
<param>.arb fn
<param>.shrink fn
<param>.less fn
<param>.maxSize fn

Returns:

Name Type Description
fn maximum size/length to generate

.qch.genS.new

Generator definition

Parameter(s):

Name Type Description
(fn; fn; fn; fn) A tuple of:
    generator
    create a number of possibly shrunk values from a value
    return true if left arg is less than right arg
    maximum size/length to generate

.qch.check

Check a property holds

.qch.discard

Return this value from a property to discard the test.

Example:

 .qch.summary .qch.check .qch.forall[.qch.g.boolean[]] {
         if [not x; : .qch.discard];
         : x
     }
 /=> OK, passed 97 tests, discarded 100 tests.

.qch.forall

Create a new property of a single argument.

Note - There are 7 versions of this function. Each version expects a different number of spec definitions. This was done so that the spec definitions are separated in the api, and not forced into an unintuitive list.

.qch.forall1

Create a new property of a single argument.

.qch.forall2

Create a new property of two arguments.

.qch.forall3

Create a new property of three arguments.

.qch.forall4

Create a new property of four arguments.

.qch.forall5

Create a new property of five arguments.

.qch.forall6

Create a new property of six arguments.

.qch.forall7

Create a new property of seven arguments.

.qch.quick

Deprecated

Create and run a property of a single argument. An error is thrown if the property failed. Otherwise, return true. This is used to interface with qCumber.

Note - There are 7 versions of this function. Each version expects a different number of spec definitions. This was done so that the spec definitions are separated in the api, and not forced into an unintuitive list.

These functions are deprecated. Please use property blocks if testing within qcumber test files.

.qch.quick1

Deprecated

Create and run a property of one argument.

Parameter(s):

Name Type Description
spec dict
prop fn

Returns:

Name Type Description
boolean

See Also: .qch.quick

.qch.quick2

Deprecated

Create and run a property of two arguments.

See Also: .qch.quick

.qch.quick3

Deprecated

Create and run a property of three arguments.

See Also: .qch.quick

.qch.quick4

Deprecated

Create and run a property of four arguments.

See Also: .qch.quick

.qch.quick5

Deprecated

Create and run a property of five arguments.

See Also: .qch.quick

.qch.quick6

Deprecated

Create and run a property of six arguments.

See Also: .qch.quick

.qch.quick7

Deprecated

Create and run a property of seven arguments.

See Also: .qch.quick

.qch.setTimes

Set the number of times to run each property globally.

Example:

 .qch.setTimes 10

Example:

 .qch.setTimes 1000

.qch.summary

Summarize a single run.

Example:

 .qch.summary .qch.check .qch.forall[.qch.g.int[]] {x=x}
 /=> Ok, passed 100 tests.

.qch.with.classifier

Add a classifier to a property.

Example:

 intensify : { x + 2 };

 // Want this to hold
 prop_intensify : { (x + 2) = intensify x };

 // An optional classifier to get random distribution information
 // on the generated data
 classifier: { $[x>0; "positive"; x=0; "zero"; "negative"] };

 .qch.summary .qch.check
     .qch.with.times[500]                    // Run 500 random tests (optional)
     .qch.with.classifier[classifier]        // Run this classifier on each input (optional)
     .qch.forall [.qch.g.int[]] prop_intensify;

 /=> "OK, passed 500 tests."
 /=> "   Classifications:"
 /=> "      53.70741% negative"
 /=> "      46.29259% positive"

.qch.with.times

Set the number of times to run a specific property.

Example:

 intensify : { x + 2 };

 // Want this to hold
 prop_intensify : { (x + 2) = intensify x };

 .qch.summary .qch.check
     .qch.with.times[500]                    // Run 500 random tests (optional)
     .qch.with.classifier[classifier]        // Run this classifier on each input (optional)
     .qch.forall [.qch.g.int[]] prop_intensify;

 /=> "OK, passed 500 tests."
 /=> "   Classifications:"
 /=> "      53.70741% negative"
 /=> "      46.29259% positive"