Skip to content

Commit e1fafa8

Browse files
committed
tests: fix doctest tests that broke due to Julia parser changes
1 parent 457d2f7 commit e1fafa8

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

test/doctests/doctestapi.jl

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,56 @@ Stacktrace:
143143
[...]
144144
```
145145
"""
146-
module ParseErrorSuccess end
146+
module ParseErrorSuccess_1x00 end
147+
148+
"""
149+
```jldoctest
150+
julia> map(tuple, 1/(i+j) for i=1:2, j=1:2, [1:4;])
151+
ERROR: ParseError:
152+
# Error @ none:1:44
153+
map(tuple, 1/(i+j) for i=1:2, j=1:2, [1:4;])
154+
# └ ── invalid iteration spec: expected one of `=` `in` or `∈`
155+
Stacktrace:
156+
[...]
157+
```
158+
```jldoctest
159+
julia> 1.2.3
160+
ERROR: ParseError:
161+
# Error @ none:1:1
162+
1.2.3
163+
└──┘ ── invalid numeric constant
164+
# Error @ none:1:5
165+
1.2.3
166+
# ╙ ── extra tokens after end of expression
167+
Stacktrace:
168+
[...]
169+
```
170+
```jldoctest
171+
println(9.8.7)
172+
# output
173+
ERROR: ParseError:
174+
# Error @ none:1:9
175+
println(9.8.7)
176+
# └──┘ ── invalid numeric constant
177+
# Error @ none:1:13
178+
println(9.8.7)
179+
# ╙ ── Expected `)`
180+
Stacktrace:
181+
[...]
182+
```
183+
```jldoctest
184+
julia> Meta.ParseError("foo")
185+
Base.Meta.ParseError("foo", nothing)
186+
187+
julia> Meta.ParseError("foo") |> throw
188+
ERROR: ParseError("foo")
189+
Stacktrace:
190+
[...]
191+
```
192+
"""
193+
module ParseErrorSuccess_1x10 end
194+
# The JuliaSyntax swap in 1.10 changed the printing of parse errors quite considerably
195+
ParseErrorSuccess() = (VERSION >= v"1.10.0-DEV.1520") ? ParseErrorSuccess_1x10 : ParseErrorSuccess_1x00
147196

148197
"""
149198
```jldoctest
@@ -254,7 +303,7 @@ module BadDocTestKwargs3 end
254303
end
255304

256305
# Parse errors in doctests (https://github.com/JuliaDocs/Documenter.jl/issues/1046)
257-
run_doctest(nothing, [ParseErrorSuccess]) do result, success, backtrace, output
306+
run_doctest(nothing, [ParseErrorSuccess()]) do result, success, backtrace, output
258307
@test success
259308
@test result isa Test.DefaultTestSet
260309
end

0 commit comments

Comments
 (0)