Using jldoctest across Julia versions

I am developing a library called Air that includes persistent collection types. (I don’t think this context is very important, but the link is included in case it helps.) As part of this I have a large number of jldoctest-style tests/examples. However, I can’t make them pass on multiple versions of Julia. Here’s a simple demonstration of why.

In Julia version 1.5.4:

julia> Vector([1,2,3])
3-element Array{Int64,1}:
 1
 2
 3

In Julia 1.6.0 (or nightly):

julia> Vector([1,2,3])
3-element Vector{Int64}:
 1
 2
 3

My tests in the library use custom types PArray and PVector, but since these tests depend on Base.show's implementation fo AbstractArray, the issue is the same as shown here. Note that the first prints PArray{Int64,1} while the second prints PVector{Int64}. Here’s another example:

1.5.4:

julia> Dict(:a => 1)
Dict{Symbol,Int64} with 1 entry:
  :a => 1

1.6.0:

julia> Dict(:a => 1)
Dict{Symbol, Int64} with 1 entry:
  :a => 1

Notice that in the first example there is no space between the type parameters (Diict{Symbol,Int64}) and in the second example there is a space (Dict{Symbol, Int64}).

How do I write jldoctest blocks that understand that different outputs should be produced depending on the Julia version? Or are these kinds of tests not possible across versions?

1 Like

Here’s a previous reply How to filter out errors due to alias of Type name when building documentation? - #2 by fredrikekre

2 Likes