From 6fff0eecd883dd70a2680b4b1fd85a95279d2241 Mon Sep 17 00:00:00 2001 From: ztangent Date: Wed, 4 Sep 2024 22:29:19 -0400 Subject: [PATCH] Fix docstring test for static modeling language. --- test/dsl/static_dsl.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/dsl/static_dsl.jl b/test/dsl/static_dsl.jl index dc360ec2..ea8dabaa 100644 --- a/test/dsl/static_dsl.jl +++ b/test/dsl/static_dsl.jl @@ -558,9 +558,16 @@ trace, = generate(foo, (), constraints) end @testset "docstrings" begin - io = IOBuffer() - print(io, @doc model) - @test String(take!(io)) == "my documentation\n" + 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 + @test doc_to_str(@doc(model)) == "my documentation\n" end @testset "one-line definitions" begin