Next: , Previous: , Up: API  


1.8 (veritas prelude)

1.8.1 Macros

Macro: evaluate-thunks x

Evaluate thunks one after another, keeping their order.

The result list lines up with the input list.

Macro: evaluate-thunks-concurrently x

Run thunks concurrently in fibers and collect what they return.

Blocks until every thunk has reported back through a shared channel. A thunk that raises sends a formatted error string instead of a value, so one failure cannot hang the run. Results come back in completion order, which is not the order of thunks.

(evaluate-thunks-concurrently
 (list (lambda () (sleep 1) 'delayed)
       (lambda () 'instant)))
⇒ (instant delayed)

1.8.2 Parameters

Parameter: current-collector

Default value:

#f

1.8.3 Procedures

Procedure: call-with-timeout seconds thunk KEY: #:on-timeout

Run thunk with an optional deadline of seconds seconds.

When seconds is a positive real number the work runs in its own fiber and, if it has not finished by then, the fiber is aborted and the result of calling on-timeout is returned instead. When seconds is #f (the default, meaning no deadline) thunk is simply called and its result is returned.

thunk must return a single value. The caller never waits for more than seconds, and the runaway fiber is terminated rather than left running.

(call-with-timeout 5
                   (lambda () (expensive-computation))
                   #:on-timeout (lambda () 'gave-up))
Procedure: capture-result-and-output thunk

Call thunk and return a result-and-output record.

The record holds what thunk returned together with everything it printed, so a test’s output can be reported next to its result.

Procedure: collect-assertion-successful xs

Return the outcome of every assertion in xs as a flat list.

Booleans only: #t for a pass, #f for a failure.

Procedure: collect-assertion-successful* xs

Return the assertion outcomes found inside xs.

Knows assertion, pre-test, test and suite results, and recurses into lists. Unspecified values, benchmarks and #t contribute nothing; an unrecognized type raises.

Procedure: collect-in! item

Record item in the active collector, and return item.

Does nothing else when no collector is bound, which is what building a case outside a body - at load time, or inside an assertion that runs later - looks like. #f is never recorded: a case a filter dropped is not a case.

Procedure: collector-items collector

Return what collector recorded, in the order the items were built.

Procedure: collector? value

Return #t when value is a collector made by make-collector.

Procedure: deduplicate-values values

Return values without the entries that are the same object as an earlier one.

Identity, not equality, decides: the same case built twice is two cases, while the same case both recorded and returned by one form is one.

Procedure: display-all-results vc all-results

Print and log every test outcome inside all-results using reporter client vc.

Iterates over the compilation of all-results. Evaluates types dynamically:

  • suite-result: Displays suite output, followed by inner test results.
  • pre-test-result: Logs the test identity via vc and displays inner assertions.
  • benchmark-result: Dispatches to log-benchmark.

Throws an explicit error if an unrecognized result type is processed.

Procedure: display-assertion-results assertion-results

Print the captured output of each record in assertion-results.

A record that is not an assertion gets printed as an error instead of bringing down the reporter.

Procedure: flatten-cases value case? expand OPT: depth

Return the cases value stands for, in order, leaving out what is not one.

case? recognises a case, expand evaluates a thunk-shaped body form, lists (of any depth) are walked, and anything else - an unspecified value, a number, a nested task in a place that wants assertions - contributes nothing. depth bounds the recursion, so a thunk that keeps returning thunks is a value that is ignored rather than a run that never ends.

Procedure: flatten-list xs

Flatten xs into a single list, however deeply it nests.

An atom that is not a list comes back wrapped in a one-element list.

Procedure: getenv-or var KEY: #:default

Return environment variable var, or default when it is unset.

var is a symbol. Anything that goes wrong while reading it yields default as well.

Procedure: make-collector

Return a fresh collector: a mutable list head of recorded items.

Procedure: make-timeout-assertion-result KEY: #:vc #:name #:timeout

Build the failed assertion-result reported for a timeout.

name is the timed task, timeout the seconds it was given and vc the client used to report it. A timeout fails the run exactly like any other failed assertion.

Procedure: nullary-procedure? proc

Return #t when proc can be called with no arguments at all.

A body form is wrapped in such a thunk by the DSL, and a thunk of this shape is therefore a body still to be evaluated rather than a case to run.

Procedure: procedure-required-arity proc

Return how many arguments proc needs, or #f when that is unknown.

Guile reports a procedure’s arity as the list (required optional rest?), or as several values on older versions; both are read here.


Next: (veritas reporter), Previous: (veritas model), Up: API