LiterateTest.jl
LiterateTest
— ModuleLiterateTest.config
— FunctionLiterateTest.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
.
LiterateTest.preprocess
— FunctionLiterateTest.preprocess(code::AbstractString) -> code′::String
Remove testing related code from code
.
See Testing LiterateTest.jl for examples of how it works.
Currently, LiterateTest.preprocess
is implemented as a plain line-based transformation. It may break with complex expressions.
LiterateTest.preprocess_juliaformatter
— FunctionLiterateTest.preprocess_juliaformatter(code::AbstractString) -> code′::String
Remove #! format: off
and #! format: on
. Note that LiterateTest.preprocess
does the same preprocessing.
LiterateTest.@evaltest
— Macro@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
.
LiterateTest.@evaltest_throw
— Macro@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
.
LiterateTest.@testset_error
— Macro@testset_error expr
expr
must contain a try
-catch
block.
LiterateTest.@dedent
— Macro@dedent begin
ex
end
A no-op macro that just evaluates ex
.
This macro is meant to be processed by LiterateTest.preprocess
.
LiterateTest.AssertAsTest
— ModuleLiterateTest.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