Testing

#import Tests.Testing;

Test framework for ASA. Tracks pass/fail counts across all test calls and prints a summary at the end. Import this module to use the test runner.

Example:

#import Tests.Testing;

beginSection("Arithmetic");
test(1 + 1 == 2, "1 + 1 should equal 2");
test(2 * 3 == 6, "2 * 3 should equal 6");
printSummary();

Functions


test(expression, failureMessage)

test :: (expression : bool, failureMessage : string)

Evaluates an expression. Currently accepts a boolean. In the future, any expression type will be accepted - lambdas, values, etc. On pass, increments passCount silently. On failure, increments failCount and prints the failure message in red along with the current section name. TODO: The expression argument will accept any expression type:

test(true == false, "This should fail");
test({ x = 4; }, "This should not fail");
test(bool(){ return false; }, "This should fail");
test(bool(){ return true; }, "This should not fail");

Arguments

expression
bool
The expression to evaluate
failureMessage
string
The message to display if the test fails

printSummary()

printSummary :: ()

Prints a pass/fail summary of all test() calls so far. Exits the process with code 1 if any tests failed, 0 if all passed.