LiterateTest.jl

LiterateTest.configFunction
LiterateTest.config(; overloads...) -> config::Dict{Symbol,Any}

Construct a config dictionary that can be passed to Literate.markdown etc.

LiterateTest.config post-composes given preprocess function (default: identity) with LiterateTest.preprocess.

source
LiterateTest.preprocessFunction
LiterateTest.preprocess(code::AbstractString) -> code′::String

Remove testing related code from code.

See Testing LiterateTest.jl for examples of how it works.

Note

Currently, LiterateTest.preprocess is implemented as a plain line-based transformation. It may break with complex expressions.

source
LiterateTest.@evaltestMacro
@evaltest "$code" begin $tests end
@evaltest raw"$code" begin $tests end

Evaluate code, assign it to the variable ans, and then run tests.

This macro is meant to be processed by LiterateTest.preprocess.

source
LiterateTest.@evaltest_throwMacro
@evaltest_throw "$code" begin $tests end
@evaltest_throw raw"$code" begin $tests end

Evaluate code, assign the exception thrown to the variable ans, and then run tests.

This macro is meant to be processed by LiterateTest.preprocess.

source
LiterateTest.@dedentMacro
@dedent begin
    ex
end

A no-op macro that just evaluates ex.

This macro is meant to be processed by LiterateTest.preprocess.

source
LiterateTest.AssertAsTestModule
LiterateTest.AssertAsTest

A module that exports Test.@test as @assert.

An intended usage is to import @assert before including example file in test:

module MyTestExampels
using LiterateTest.AssertAsTest: @assert
include("../examples/file.jl")
end

This way, examples/file.jl can still use @assert for clean documentation while a better test failure messages are shown when running the tests.

Examples

julia> using LiterateTest.AssertAsTest: @assert

julia> @assert 1 == 1
Test Passed
source