Lcl · Core · Packages · Libraries
Test Framework for LCL
A simple but capable test framework written in pure LCL.
Usage:
load lib/Test.lcl
Test::suite "My Feature" {
Test::before {
;; Setup code runs before each test
}
Test::case "should do something" {
let result [my_func 1 2]
Test::eq $result 3
}
Test::case "should fail on bad input" {
Test::raises {
my_func "bad" "input"
}
}
}
Test::run ;;; Run all suites and print resultsTestTest::suite name bodyRegister a test suite
Test::case name bodyRegister a test case within the current suite
Test::before bodyTest::after bodySet up code to run after each test in the current suite
Test::eq actual expected (msg {})Assertion: two values are equal (with optional message)
Test::neq actual unexpected (msg {})Assertion: two values are not equal (with optional message)
Test::assert cond (msg {})Assertion: condition is true (with optional message)
Test::true cond (msg {})Alias for assert
Test::false cond (msg {})Assertion: condition is false (with optional message)
Test::empty valAssertion: value is empty (empty string or empty list)
Test::not_empty valTest::opaque valAssertion: value is opaque
Test::not_opaque valAssertion: value is not opaque
Test::raises bodyAssertion: code raises an error
Test::raises_with body expected_textAssertion: code raises an error containing specific text
Test::gt actual expectedAssertion: value is greater than expected
Test::lt actual expectedAssertion: value is less than expected
Test::gte actual expectedAssertion: value is greater than or equal to expected
Test::lte actual expectedAssertion: value is less than or equal to expected
Test::contains lst elemAssertion: list contains element
Test::str_contains haystack needleAssertion: string contains substring
Test::len_eq lst expectedAssertion: list has expected length
Test::skip reasonSkip the current test with a reason
Test::runRun all registered test suites
Test::resetClear all registered suites (useful for testing the framework itself)