Skip to content

Commit 15d93b3

Browse files
committed
fix doctest tests too
1 parent 5feb4a9 commit 15d93b3

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

test/doctests/doctestapi.jl

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ local FILTER
120120
module DoctestFilters end
121121

122122
"""
123-
```jldoctest; filter = r"ERROR: (syntax|ParseError):(.*)" => s"ERROR: syntax: ..."
123+
```jldoctest
124124
julia> map(tuple, 1/(i+j) for i=1:2, j=1:2, [1:4;])
125125
ERROR: syntax: invalid iteration specification
126126
```
127-
```jldoctest; filter = r"ERROR: (syntax|ParseError):(.*)" => s"ERROR: syntax: ..."
127+
```jldoctest
128128
julia> 1.2.3
129129
ERROR: syntax: invalid numeric constant "1.2."
130130
```
131-
```jldoctest; filter = r"ERROR: (syntax|ParseError):(.*)" => s"ERROR: syntax: ..."
131+
```jldoctest
132132
println(9.8.7)
133133
# output
134134
ERROR: syntax: invalid numeric constant "9.8."
@@ -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)