Previous: (veritas shuffle), Up: API
Evaluate a list of thunks concurrently using Guile Fibers.
Each zero-argument procedure in the list thunks is spawned inside its own concurrent fiber thread. This macro blocks the execution of the calling fiber until all spawned thunks have reported their results back through a shared channel.
Exceptions raised within individual fibers are caught safely to avoid hanging or silent termination, returning a formatted error string instead.
Note: The output list order corresponds to the exact completion order of the fibers, meaning it is non-deterministic.
(evaluate-thunks-concurrently
(list (lambda () (sleep 1) 'delayed)
(lambda () 'instant)))
⇒ (instant delayed)
Returns a function taking a VC (veritas-context) that returns an assertion checking that expect and got are approximately equal.
Two values are considered approximately equal if their difference is smaller than epsilon.
This is useful for floating-point computations.
(assert-approximate #:expect 3.14
#:got 3.141
#:epsilon 0.01)
Returns a function taking a VC (veritas-context) that returns an
assertion checking that expect and got are structurally
equal using equal? predicate.
This is the standard assertion for comparing lists, strings, vectors, and other compound data structures.
It is a convenience wrapper around assert.
The expected value.
The value to compare against.
A string to identify the assertion in the logs.
(assert-equal #:expect '(1 2 3)
#:got '(1 2 3)
#:name "Lists should match")
Returns a function taking a VC (veritas-context) that returns an
assertion checking that expect and got are equivalent using
eqv? predicate.
This is useful for comparing numbers, characters, and symbols where value equivalence matters.
It is a convenience wrapper around assert.
The expected value.
The value to compare against.
A string to identify the assertion in the logs.
(assert-eqv #:expect 42
#:got (+ 40 2))
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"))
Returns a function taking a VC (veritas-context) that returns an
assertion checking that x is #f.
This is a convenience wrapper for boolean falsehood assertions.
(assert-false (< 5 2)
#:name "5 is not less than 2")
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))
Returns a function taking a VC (veritas-context) that returns an assertion checking that expect and got are not approximately equal.
This assertion passes when the difference between the values is greater than or equal to epsilon.
It is the inverse of assert-approximate.
(assert-not-approximate #:expect 3.14
#:got 3.5
#:epsilon 0.01)
Returns a function taking a VC (veritas-context) that returns an
assertion checking that expect and got are not identical
using eq?.
This assertion passes when the two values do not share identity.
It is the inverse of assert-eq.
(assert-not-eq #:expect '(1 2)
#:got '(1 2))
Returns a function taking a VC (veritas-context) that returns an
assertion checking that expect and got are not structurally
equal using equal?.
This assertion is useful when testing for inequality of compound values.
It is the inverse of assert-equal.
(assert-not-equal #:expect '(1 2 3)
#:got '(1 2 4))
Returns a function taking a VC (veritas-context) that returns an
assertion checking that expect and got are not equivalent
using eqv?.
This assertion is useful when values should differ in meaning or representation.
It is the inverse of assert-eqv.
(assert-not-eqv #:expect 1
#:got 2)
Returns a function taking a VC (veritas-context) that returns an
assertion checking that x is #t.
This is a convenience wrapper for boolean truth assertions.
(assert-true (> 5 2)
#:name "5 is greater than 2")
Register a micro-benchmarking task block to assess execution latency characteristics.
Accepts configuration settings:
Utilizes Guile’s native statistical profiler engine (statprof) to
capture performance statistics and call-stack diagnostics across loop
evaluations. Returns a benchmark-result record mapping details
for each index.
Collect and flatten all assertion success statuses found in xs.
Processes the arbitrary test result tree or list structure xs,
extracts all underlying assertion outcomes, and returns a flat list
containing only booleans indicating success (#t) or failure
(#f).
(collect-assertion-successful my-test-suite-record) ⇒ (#t #t #f #t)
Execute filtering on name against an execution substring restriction.
Performs a case-insensitive validation check. If restriction is
specified and matched anywhere inside name, returns result.
If no restriction filter is configured (#f), bypasses checks and
cleanly forwards result.
Otherwise, if a restriction is specified but not found inside the name
string, returns #f.
(do-if-string-contained #:name "User Authentication Unit Spec"
#:restriction "Auth"
#:result 'run-me)
⇒ run-me
Return a new list containing the elements of xs in a randomized permutation.
Implements the modern Fisher–Yates (also known as the Knuth) shuffle algorithm. To ensure optimal performance, the input list xs is copied into an internal vector to leverage O(1) random access and mutation. The elements are shuffled in-place within the vector before being converted back into a standard Scheme list.
Every invocation automatically re-initializes Guile’s internal
*random-state* variable using system entropy via
random-state-from-platform to ensure high-quality pseudo-random
distribution.
If xs is empty or contains only a single element, it is returned unmodified.
(fisher-yates-shuffle '(1 2 3 4 5)) ⇒ (4 1 5 3 2) ; Note: Output is randomized and non-deterministic
Returns #t if the absolute difference between a and b
is smaller than epsilon.
This is useful for comparing floating-point values where exact equality may not be reliable.
The first numeric value.
The second numeric value.
The maximum allowed difference.
(is-approximate? 3.14159 3.14160
#:epsilon 0.0001)
⇒ #t
Aggregate multiple relevant test definitions inside a structured module container named name.
Supports high-level execution choreography parameters:
#t.
#t, uses
asynchronous Guile Fiber blocks to execute tests concurrently.
Returns a composite function wrapper mapping across standard validation
configurations. Captures and isolation-binds all textual test output
streams inside a single consolidated suite-result signature
record.
Construct an isolated, executable unit test block named name.
Defines individual specification properties via keyword parameters:
#t, prints raw assertion results dump
structures directly to standard out.
Returns an execution closure capturing the system context, which
evaluates all internal assertion cases sequentially. Standard output
written during assertion tracking is safely bound, captured, and
returned inside an encapsulated pre-test-result data structure.
(test "Addition Validation"
#:before (lambda (vc) (display "Initializing..."))
(assert-equal #:expect 4 #:got (+ 2 2)))
Top-level execution runtime wrapper engine designed to orchestrate test execution runs.
Evaluates positional task variables sequentially or concurrently, providing orchestration hooks:
Previous: (veritas shuffle), Up: API