Skip to content

Commit b704034

Browse files
authored
Fix docstring tests on Julia nightly / 1.11.
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.
1 parent 5f8520b commit b704034

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/dsl/dynamic_dsl.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,16 +534,24 @@ end
534534

535535
@testset "docstrings" begin
536536

537+
function doc_to_str(doc)
538+
if doc isa Base.Docs.DocStr
539+
# Handle @doc behavior in Julia 1.11 when REPL is not loaded
540+
return doc.text[1]
541+
else
542+
# Handle pre-Julia 1.11 behavior of @doc
543+
return strip(string(doc))
544+
end
545+
end
546+
537547
"""
538548
my documentation
539549
"""
540550
@gen function foo(x)
541551
return x + 1
542552
end
543553

544-
io = IOBuffer()
545-
print(io, @doc foo)
546-
@test String(take!(io)) == "my documentation\n"
554+
@test doc_to_str(@doc(foo)) == "my documentation"
547555

548556
end
549557

0 commit comments

Comments
 (0)