Next: (veritas model), Up: API
This module is a Scheme testing library that provides a comprehensive set of assertion functions. At its core is the assert-equal* procedure, a flexible and powerful tool for comparing an expected value against a result. Beyond simple value comparison, the module offers a set of tools for testing program behavior related to error handling. These functions provide a complete assertion toolkit, enabling developers to write robust tests that cover both expected outcomes and predictable failures, thereby improving the reliability and quality of their Scheme code.
Undocumented procedure.
Undocumented procedure.
Returns a function taking a VC (veritas-context) that returns an assertion that two values are equal based on a given comparison procedure. This is the core assertion procedure that the other ‘assert-equal‘ variants are built upon. It’s used to compare an expected value with a computed value.
The got parameter can be a value or a special list to compute a
value dynamically. If got is a list starting with compute
,
comp
, or computare
, the second element of the list is
evaluated to get the actual value for comparison.
For example, (assert-equal* #:got '(compute (+ 1 1)) ...)
would
evaluate (+ 1 1)
to 2
before the comparison.
The expected value.
The value to compare against, or a list to be computed.
The comparison procedure, which should be a function of two arguments, e.g., ‘equal?‘, ‘eqv?‘, or ‘eq?‘.
A doc string to identify the assertion in the logs.
(assert-equal* #:expect 3 #:got (+ 1 1 1) #:compare equal? #:name "Ensuring addition works") ⇒ #<procedure 7f58ec5ce390 at veritas/assert.scm:69:2 (vc)> ;; Upon applying vc to the procedure we will compute the assertion: `((assertion-successful . #t) (assertion-name "Ensuring addition works"))
Undocumented procedure.
Returns a function taking a VC (veritas-context) that returns an assertion that checks that a thunk (a procedure with no arguments) raises an error when called. This is a crucial function for testing error-handling logic. It attempts to execute the provided thunk. If an error is caught during its execution, the assertion passes. If the thunk completes without raising an error, the assertion fails.
A procedure of no arguments to be executed.
A string to identify the assertion in the logs.
(assert-error (lambda () (sum-list-elements '(1 2 "a" 4))) #:name "Should fail when list contains non-numbers") ⇒ #<procedure 8f58ec5ce390 at veritas/assert.scm:69:2 (vc)> ;; Upon applying vc to the procedure we will compute the assertion: `((assertion-successful . #t) (assertion-name "Should fail when list contains non-numbers"))
Undocumented procedure.
Returns a function taking a VC (veritas-context) that returns an assertion that checks that a thunk (a procedure with no arguments) does not raise an error when called. This is a crucial function for testing error-handling logic. It attempts to execute the provided thunk. If no error is caught during its execution, the assertion passes. If the thunk raises an error, the assertion fails.
A procedure of no arguments to be executed.
A string to identify the assertion in the logs.
(assert-no-error (lambda () (sum-list-elements '(1 2 "a" 4)))) ⇒ #<procedure 8f58ec5ce390 at veritas/assert.scm:69:2 (vc)> ;; Upon applying vc to the procedure we will compute the assertion: `((assertion-successful . #f))
Undocumented procedure.
Next: (veritas model), Up: API