Skip to content

Commit

Permalink
let Documenter.jl test Julia examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBreuer committed Mar 5, 2020
1 parent f2bcb5a commit 9c9dc3d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Thomas Breuer <[email protected]>", "Sebastian Gutsche <gutsch
version = "0.2.6"

[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand Down
2 changes: 1 addition & 1 deletion src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ julia> @gap (1,2,3)
GAP: (1,2,3)
julia> @gap (1,2)(3,4)
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
ERROR: LoadError: Error thrown by GAP: Error, no method found! For debugging hints type ?Recovery from NoMethodFound
[...]
julia> @gap [ 1,, 2 ]
Expand Down
23 changes: 17 additions & 6 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import Base: show
"""
get_symbols_in_module(module_t::Module) :: Array{Symbol,1}
> Returns all symbols in the module `module_t`.
Return all symbols in the module `module_t`.
This is used in the GAP function `ImportJuliaModuleIntoGAP`.
"""
function get_symbols_in_module(module_t)
module_name = string(nameof(module_t))
Expand All @@ -20,11 +21,21 @@ end
"""
call_with_catch( juliafunc, arguments )
> Returns a tuple `( ok, val )`
> where `ok` is either `true`, meaning that calling the function `juliafunc`
> with `arguments` returns the value `val`,
> or `false`, meaning that the function call runs into an error;
> in the latter case, `val` is set to the string of the error message.
Return a tuple `( ok, val )`
where `ok` is either `true`, meaning that calling the function `juliafunc`
with `arguments` returns the value `val`,
or `false`, meaning that the function call runs into an error;
in the latter case, `val` is set to the string of the error message.
# Examples
```jldoctest
julia> GAP.call_with_catch( sqrt, 2 )
(true, 1.4142135623730951)
julia> GAP.call_with_catch( sqrt, -2 )
(false, "DomainError(-2.0, \\"sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).\\")")
```
"""
function call_with_catch( juliafunc, arguments )
try
Expand Down
5 changes: 3 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using Test
using Test, Documenter, GAP

using GAP
DocMeta.setdocmeta!( GAP, :DocTestSetup, :( using GAP ); recursive = true )

include("basics.jl")
include("convenience.jl")
include("conversion.jl")
include("macros.jl")
include("help.jl")
include("testmanual.jl")
4 changes: 4 additions & 0 deletions test/testmanual.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@testset "manual examples" begin
doctest( GAP; manual = false )
end

0 comments on commit 9c9dc3d

Please sign in to comment.