(html (head (title "sph-lib (sph test)") (link (@ (rel "stylesheet") (type "text/css") (href "/css/sph.css"))) (meta (@ (name "viewport") (content "width=device-width,initial-scale=1"))) #f) (body () (div (@ (class top)) (nav (a (@ (href "/")) "start") ", " (a (@ (href "/feed.xml")) "feed")) "") (div (@ (class "middle")) (div (@ (class mtime) (title "last modification time of the current page")) "2023-04-05") (section (h1 "(sph test)") (div (p "automated code testing with composable modules.") (p "part of " (a (@ (href "../../sph-lib.html")) "sph-lib")) ((section (@ (class "library-description")) (h1 "library description") (div (p "procedure-wrap: false/procedure:{test-proc test-name -> proc}") (p "# define-test-module") (p "test modules are typical modules/libraries that export only one procedure named \"execute\". the syntax defined here abstracts the definition.") (p "modules are used to give test modules a separated scope in which test module dependencies are integrated.") (p "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") (p "possible composition, like the best solution at this point.") (p "the syntax defined here must be available in the environment in which the test module is loaded.") (p "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)") (p "# data structures:") (p "test-result: ([group-name] test-result ...)/vector") (p "# syntax") (p "test-settings-default-custom :: [any:unquoted-key any:value] ... -> list") (p "test-list :: symbol:name/(symbol:name any:io-data ...) ... -> ((symbol procedure [arguments expected] ...) ...)") (p "define-test") (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) ":: (name [arguments expected settings]) body ...")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) ":: name procedure body ...")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "define a procedure with the name test-{name} and the arity expected by the default evaluators")) (p "define-procedure-tests :: symbol:name symbol/literal-list") (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "define a variable with tests that can be executed with test-execute-procedures.")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "resolves procedures by name and normalises the test specification")) (p "test-execute-procedures-lambda :: test-list-arguments ... -> procedure:{settings -> test-result}") (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "create a procedure that executes procedure tests corresponding to test-spec.")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "can be used as the last expression in a test module")) (p "test-lambda") (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) ":: symbol:formals/([arguments expected settings]) body ... -> procedure")) (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "creates a normalised test procedure with the correct arity")) (p "assert-and :: [optional-title] expression ... -> vector:test-result") (p (((*ENTITY* "nbsp") (*ENTITY* "nbsp")) "creates a successful test result if all given expressions or assertions are successful test results or true")) (p "assert-equal :: [optional-title] expected expression -> vector:test-result"))) (section (@ (class "library-name")) (h1 "module name") (p "(sph test)")) (section (@ (class "library-exports")) (h1 "exported bindings") (div (div (@ (class "doc-bindings")) (div (@ (id "doc-b-" "assert-and") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "assert-and")) "" "") (div (@ (id "doc-b-" "assert-equal") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "assert-equal") " " (span (@ (class "first-sig")) "optional-title expected expr")) "" "") (div (@ (id "doc-b-" "assert-test-result") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "assert-test-result") " " (span (@ (class "first-sig")) "title expr continue")) (div (@ (class "rest-sig")) (div "string/false expression expression -> true/test-result:failure")) (div (@ (class "description")) (("assertions create test-result vectors only on failure")))) (div (@ (id "doc-b-" "assert-true") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "assert-true") " " (span (@ (class "first-sig")) "optional-title expr")) "" "") (div (@ (id "doc-b-" "define-procedure-tests") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "define-procedure-tests") " " (span (@ (class "first-sig")) "name test-spec ...")) "" (div (@ (class "description")) (("-> ((symbol procedure any ...) ...)")))) (div (@ (id "doc-b-" "define-test") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "define-test")) "" "") (div (@ (id "doc-b-" "define-test-module") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "define-test-module")) "" (div (@ (class "description")) (("using eval because exporting bindings created with define created by syntax was not working")))) (div (@ (id "doc-b-" "sph-test-description") (class "doc-b")) (div (span (@ (class "type")) "variable") ": " (span (@ (class "name")) "sph-test-description")) "" "") (div (@ (id "doc-b-" "test-create-result") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-create-result") " " (span (@ (class "first-sig")) "[success? title assert-title index result arguments expected] ->")) (div (@ (class "rest-sig")) (div "boolean string string integer any list any -> vector:test-result")) "") (div (@ (id "doc-b-" "test-execute-module") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-execute-module") " " (span (@ (class "first-sig")) "settings name ->")) (div (@ (class "rest-sig")) (div "list (symbol ...) -> test-result")) "") (div (@ (id "doc-b-" "test-execute-modules") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-execute-modules") " " (span (@ (class "first-sig")) "settings module-names ->")) (div (@ (class "rest-sig")) (div "list list -> test-result")) "") (div (@ (id "doc-b-" "test-execute-modules-by-prefix") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-execute-modules-by-prefix") " " (span (@ (class "first-sig")) "#:settings module-names ... ->")) "" (div (@ (class "description")) (("execute all test modules whose module name has the one of the given module name prefixes." (br) "\\\"path-search\\\" restricts the path where to search for test-modules." (br) "\\\"search-type\\\" does not execute modules that exactly match the module name prefix (where the module name prefix resolves to a regular file)")))) (div (@ (id "doc-b-" "test-execute-procedures") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-execute-procedures") " " (span (@ (class "first-sig")) "settings source ->")) (div (@ (class "rest-sig")) (div "list ((symbol:name procedure:test-proc any:data-in/out ...) ...) -> test-result")) "") (div (@ (id "doc-b-" "test-execute-procedures-lambda") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "test-execute-procedures-lambda") " " (span (@ (class "first-sig")) "test-spec ...")) "" "") (div (@ (id "doc-b-" "test-lambda") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "test-lambda")) "" "") (div (@ (id "doc-b-" "test-list") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "test-list") " " (span (@ (class "first-sig")) "test-spec ...")) "" "") (div (@ (id "doc-b-" "test-module-name-from-files") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-module-name-from-files") " " (span (@ (class "first-sig")) "a ->")) (div (@ (class "rest-sig")) (div "string -> list/error")) "") (div (@ (id "doc-b-" "test-result-success?") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-result-success?") " " (span (@ (class "first-sig")) "a ->")) "" "") (div (@ (id "doc-b-" "test-settings-default") (class "doc-b")) (div (span (@ (class "type")) "variable") ": " (span (@ (class "name")) "test-settings-default")) "" "") (div (@ (id "doc-b-" "test-settings-default-custom") (class "doc-b")) (div (span (@ (class "type")) "syntax") ": " (span (@ (class "name")) "test-settings-default-custom") " " (span (@ (class "first-sig")) "key/value ...")) "" "") (div (@ (id "doc-b-" "test-settings-default-custom-by-list") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "test-settings-default-custom-by-list") " " (span (@ (class "first-sig")) "key/value ->")) (div (@ (class "rest-sig")) (div "[key value] ... -> list")) (div (@ (class "description")) (("get the default test settings, with values possibly set to the values given with \\\"key/value\\\""))))))))))) ()))