Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doc string tests in prep for Julia v1.11 release #16

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
using BitFlags
using Test, Serialization

# workaround for https://github.com/JuliaLang/julia/issues/54664
function extractdoc(doc)
# On v1.11 without REPL loaded, the @doc macro returns a Base.Docs.DocStr object;
# extract the stored string from the object.
doc isa Base.Docs.DocStr && return doc.text[1]
# Otherwise, assume we get something like a Markdown.MD object and just turn it into
# a string. (Strip trailing newline for consistency with above form.)
return strip(string(doc))
end

macro macrocall(ex)
@assert Meta.isexpr(ex, :macrocall)
ex.head = :call
Expand Down Expand Up @@ -95,10 +105,10 @@ end
#@testset "Documentation" begin
# docstring literal
"""My Docstring""" @bitflag DocFlag1 docflag1a
@test string(@doc(DocFlag1)) == "My Docstring\n"
@test extractdoc(@doc(DocFlag1)) == "My Docstring"
# docstring macro for non-string literals
@doc raw"""Raw Docstring""" @bitflag DocFlag2 docflag2a
@test string(@doc(DocFlag2)) == "Raw Docstring\n"
@test extractdoc(@doc(DocFlag2)) == "Raw Docstring"
#end

#@testset "Type properties" begin
Expand Down Expand Up @@ -333,9 +343,9 @@ end

# Documentation
"""My Docstring""" @bitflagx SDocFlag1 docflag
@test string(@doc(SDocFlag1)) == "My Docstring\n"
@test extractdoc(@doc(SDocFlag1)) == "My Docstring"
@doc raw"""Raw Docstring""" @bitflagx SDocFlag2 docflag
@test string(@doc(SDocFlag2)) == "Raw Docstring\n"
@test extractdoc(@doc(SDocFlag2)) == "Raw Docstring"

# Error conditions
# Too few arguments
Expand Down
Loading