From b704034664ac53e73bafba81114eece93af791df Mon Sep 17 00:00:00 2001 From: ztangent Date: Wed, 4 Sep 2024 22:17:26 -0400 Subject: [PATCH] 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. --- test/dsl/dynamic_dsl.jl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/dsl/dynamic_dsl.jl b/test/dsl/dynamic_dsl.jl index 758b83e5..52b23f33 100644 --- a/test/dsl/dynamic_dsl.jl +++ b/test/dsl/dynamic_dsl.jl @@ -534,6 +534,16 @@ 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 """ @@ -541,9 +551,7 @@ end 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