Skip to content

Commit

Permalink
Fix docstring tests on Julia nightly / 1.11.
Browse files Browse the repository at this point in the history
This addresses #523 by handling the new return type of `@doc` on Julia 1.11 nightly builds when the REPL module isn't loaded, which differs from the behavior of `@doc` on earlier versions of Julia.
  • Loading branch information
ztangent authored Sep 5, 2024
1 parent 5f8520b commit b704034
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/dsl/dynamic_dsl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,24 @@ end

@testset "docstrings" begin

function doc_to_str(doc)
if doc isa Base.Docs.DocStr
# Handle @doc behavior in Julia 1.11 when REPL is not loaded
return doc.text[1]
else
# Handle pre-Julia 1.11 behavior of @doc
return strip(string(doc))
end
end

"""
my documentation
"""
@gen function foo(x)
return x + 1
end

io = IOBuffer()
print(io, @doc foo)
@test String(take!(io)) == "my documentation\n"
@test doc_to_str(@doc(foo)) == "my documentation"

end

Expand Down

0 comments on commit b704034

Please sign in to comment.