automated code testing with composable modules.
part of sph-lib
procedure-wrap: false/procedure:{test-proc test-name -> proc}
# define-test-module
test modules are typical modules/libraries that export only one procedure named "execute". the syntax defined here abstracts the definition.
modules are used to give test modules a separated scope in which test module dependencies are integrated.
there might be alternatives to using modules - for example evaluating files in custom environments that use the import statement. but modules seem, because of their
possible composition, like the best solution at this point.
the syntax defined here must be available in the environment in which the test module is loaded.
to archieve this, the definition is initially evaluated in the top-level environment (loading/definition) and the module object is later resolved using environment* (resolving)
# data structures:
test-result: ([group-name] test-result ...)/vector
# syntax
test-settings-default-custom :: [any:unquoted-key any:value] ... -> list
test-list :: symbol:name/(symbol:name any:io-data ...) ... -> ((symbol procedure [arguments expected] ...) ...)
define-test
:: (name [arguments expected settings]) body ...
:: name procedure body ...
define a procedure with the name test-{name} and the arity expected by the default evaluators
define-procedure-tests :: symbol:name symbol/literal-list
define a variable with tests that can be executed with test-execute-procedures.
resolves procedures by name and normalises the test specification
test-execute-procedures-lambda :: test-list-arguments ... -> procedure:{settings -> test-result}
create a procedure that executes procedure tests corresponding to test-spec.
can be used as the last expression in a test module
test-lambda
:: symbol:formals/([arguments expected settings]) body ... -> procedure
creates a normalised test procedure with the correct arity
assert-and :: [optional-title] expression ... -> vector:test-result
creates a successful test result if all given expressions or assertions are successful test results or true
assert-equal :: [optional-title] expected expression -> vector:test-result
(sph test)