Kaya 0.5.2 module reference for Testing

List of modules in this version

Testing module

This module contains functions for development of unit testing libraries. Tests are defined with add, and then the test set is run with run

program test;

Bool predicate(Int a) = (a%2 == 0);

Void() test1() {
    xs = randomIntArray(10,1000);
    ys = filter(predicate,xs);
    assert(all(predicate,ys));
}

Void main() {
    init();
    add(@test1,10,"Filtering");
    run();
}

Note that random values in this module are generated using Builtins::rand, a generator with high speed but poor quality. For higher quality random values, consider using Lfrand or another generator. For most testing, this will not be important.

Data types

Functions

kaya@kayalang.org | Last modified 13 July 2009 | Supported by Durham CompSoc | Powered by Kaya