Testing Utility - mtdol/cm GitHub Wiki
std_lib::testing.cm
Import
#:import
"std_lib::testing.cm"
import the testing utility
Running test files
Use
cm.rkt --test "file/directory" "file/directory" ...
to run the testing utility on a set of given testing files.
Testing files should ideally end in .test.cm
to differentiate them
from testable source code.
Functions
main
args -> void
args : string list
Takes every string
in args and treats it as either a file or directory.
Recursively loads all .cm
files in each file or directory, printing testing info as they are run.
print_failures?
:=
bool
static Determines whether debug info will be printed upon a test failure.
assert_equal
elem1 elem2 -> bool
elem1 : any, elem2 : any
Asserts that elem1 == elem2
.
Returns true
and logs success if true else returns false
and logs a test failure.
assert_not_equal
elem1 elem2 -> bool
elem1 : any, elem2 : any
Asserts that elem1 !== elem2
.
Returns true
and logs success if true else returns false
and logs a test failure.
assert_equalf
f elem1 elem2 -> bool
f : (any -> any -> bool), elem1 : any, elem2 : any
Asserts that f : elem1 : elem2
.
Returns true
and logs success if true else returns false
and logs a test failure.
assert_failure
f args -> bool
f : fun, args : list
Asserts that appl f args
raises an exception.
Returns true
and logs success if true else returns false
and logs a test failure.
assert_failure_id
id f args -> bool
id : string, f : fun, args : list
Asserts that appl f args
raises an exception with type id.
Returns true
and logs success if true else returns false
and logs a test failure.
> assert_failure_id : "CONTRACT" : add1 : "a"
true