Skip to content

Commit

Permalink
subtype: add tests for Vararg expansion.
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed Aug 31, 2022
1 parent 51edded commit 8590407
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2020,3 +2020,63 @@ end
#issue #43082
struct X43082{A, I, B<:Union{Ref{I},I}}; end
@testintersect(Tuple{X43082{T}, Int} where T, Tuple{X43082{Int}, Any}, Tuple{X43082{Int}, Int})

#issue #36443
let C = Tuple{Val{3},Int,Int,Int},
As = (Tuple{Val{N},Vararg{T,N}} where {T,N},
Tuple{Val{N},Vararg{T,N}} where {N,T}),
Bs = (Tuple{Val{3},Int,Vararg{T,N}} where {T,N},
Tuple{Val{3},Int,Vararg{T,N}} where {N,T},
Tuple{Val{3},Int,Vararg{T}} where {T},
Tuple{Val{3},Int,Vararg{T,2}} where {T})
for A in As, B in Bs
@testintersect(A, B, C)
end
end

let A = Tuple{Type{Val{N}},Tuple{Vararg{T,N}} where T} where N,
C = Tuple{Type{Val{2}},Tuple{T,T} where T}
@testintersect(A, Tuple{Type{Val{2}},Tuple{Vararg{T,N}} where T} where N, C)
@testintersect(A, Tuple{Type{Val{2}},Tuple{T,Vararg{T,N}} where T} where N, C)
@testintersect(A, Tuple{Type{Val{2}},Tuple{T,T,Vararg{T,N}} where T} where N, C)
end

let f36443(::NTuple{N}=[(f36443,),(1,2)][2],::Val{N}=Val(2)) where{N} = 0
@test f36443() == 0;
end

let C = Tuple{Val{3},Int,Int,Int,Int},
As = (Tuple{Val{N},Int,Vararg{T,N}} where {T,N},
Tuple{Val{N},Int,Vararg{T,N}} where {N,T}),
Bs = (Tuple{Val{3},Vararg{T,N}} where {T,N},
Tuple{Val{3},Vararg{T,N}} where {N,T},
Tuple{Val{3},Vararg{T}} where {T})
for A in As, B in Bs
@testintersect(A, B, C)
end
end

#issue #37257
let T = Tuple{Val{N}, Any, Any, Vararg{Any,N}} where N,
C = Tuple{Val{1}, Any, Any, Any}
@testintersect(T, Tuple{Val{1}, Vararg{Any}}, C)
@testintersect(T, Tuple{Val{1}, Any, Vararg{Any}}, C)
@testintersect(T, Tuple{Val{1}, Any, Any, Vararg{Any}}, C)
@testintersect(T, Tuple{Val{1}, Any, Any, Any, Vararg{Any}}, C)
@testintersect(T, Tuple{Val{1}, Any, Any, Any, Any, Vararg{Any}}, Union{})
end

let A = Tuple{NTuple{N,Any},Val{N}} where {N},
C = Tuple{NTuple{4,Any},Val{4}}
@testintersect(A, Tuple{Tuple{Vararg{Any,N}},Val{4}} where {N}, C)
@testintersect(A, Tuple{Tuple{Vararg{Any}},Val{4}}, C)
@testintersect(A, Tuple{Tuple{Vararg{Any,N}} where {N},Val{4}}, C)

@testintersect(A, Tuple{Tuple{Any,Vararg{Any,N}},Val{4}} where {N}, C)
@testintersect(A, Tuple{Tuple{Any,Vararg{Any}},Val{4}}, C)
@testintersect(A, Tuple{Tuple{Any,Vararg{Any,N}} where {N},Val{4}}, C)

@testintersect(A, Tuple{Tuple{Any,Any,Any,Any,Any,Vararg{Any,N}},Val{4}} where {N}, Union{})
@testintersect(A, Tuple{Tuple{Any,Any,Any,Any,Any,Vararg{Any}},Val{4}}, Union{})
@testintersect(A, Tuple{Tuple{Any,Any,Any,Any,Any,Vararg{Any,N}} where {N},Val{4}}, Union{})
end

0 comments on commit 8590407

Please sign in to comment.