Skip to content

Commit

Permalink
subtype: add test for eager Vararg expansion.
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed Sep 3, 2022
1 parent 7575257 commit 2d682f7
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,7 @@ function test_intersection()
Type{Tuple{Int,T}} where T<:Integer)
@testintersect(Type{<:Tuple{Any,Vararg{Any}}},
Type{Tuple{Vararg{Int,N}}} where N,
!Union{})

@test typeintersect(Type{<:Tuple{Any,Vararg{Any}}}, Type{Tuple{Vararg{Int,N}}} where N) != Type{Tuple{Int,Vararg{Int}}}
@test_broken typeintersect(Type{<:Tuple{Any,Vararg{Any}}}, Type{Tuple{Vararg{Int,N}}} where N) == Type{Tuple{Int,Vararg{Int,N}}} where N
@test_broken typeintersect(Type{<:Tuple{Any,Vararg{Any}}}, Type{Tuple{Vararg{Int,N}}} where N) != Type{<:Tuple{Int,Vararg{Int}}}
Type{Tuple{Int,Vararg{Int,N}}} where N)

@testintersect(Type{<:Array},
Type{AbstractArray{T}} where T,
Expand Down Expand Up @@ -2104,13 +2100,19 @@ let A = Tuple{NTuple{N, Int}, NTuple{N, Int}} where N,
Bs = (Tuple{Tuple{Int, Vararg{Any}}, Tuple{Int, Int, Vararg{Any}}},
Tuple{Tuple{Int, Vararg{Any,N1}}, Tuple{Int, Int, Vararg{Any,N2}}} where {N1,N2},
Tuple{Tuple{Int, Vararg{Any,N}} where {N}, Tuple{Int, Int, Vararg{Any,N}} where {N}})
Cerr = Tuple{Tuple{Int, Vararg{Int, N}}, Tuple{Int, Int, Vararg{Int, N}}} where {N}
C = Tuple{Tuple{Int, Int, Vararg{Int, N}}, Tuple{Int, Int, Vararg{Int, N}}} where {N}
for B in Bs
C = typeintersect(A, B)
@test C == typeintersect(B, A) != Union{}
@test C != Cerr
# TODO: The ideal result is Tuple{Tuple{Int, Int, Vararg{Int, N}}, Tuple{Int, Int, Vararg{Int, N}}} where {N}
@test_broken C != Tuple{Tuple{Int, Vararg{Int}}, Tuple{Int, Int, Vararg{Int}}}
@testintersect(A, B, C)
end
A = Tuple{NTuple{N, Int}, Tuple{Int, Vararg{Int, N}}} where N
C = Tuple{Tuple{Int, Vararg{Int, N}}, Tuple{Int, Int, Vararg{Int, N}}} where {N}
for B in Bs
@testintersect(A, B, C)
end
A = Tuple{Tuple{Int, Vararg{Int, N}}, NTuple{N, Int}} where N
C = Tuple{Tuple{Int, Int, Int, Vararg{Int, N}}, Tuple{Int, Int, Vararg{Int, N}}} where {N}
for B in Bs
@testintersect(A, B, C)
end
end

Expand All @@ -2123,12 +2125,9 @@ let A = Pair{NTuple{N, Int}, NTuple{N, Int}} where N,
Bs = (Pair{<:Tuple{Int, Vararg{Int}}, <:Tuple{Int, Int, Vararg{Int}}},
Pair{Tuple{Int, Vararg{Int,N1}}, Tuple{Int, Int, Vararg{Int,N2}}} where {N1,N2},
Pair{<:Tuple{Int, Vararg{Int,N}} where {N}, <:Tuple{Int, Int, Vararg{Int,N}} where {N}})
Cerr = Pair{Tuple{Int, Vararg{Int, N}}, Tuple{Int, Int, Vararg{Int, N}}} where {N}
C = Pair{Tuple{Int, Int, Vararg{Int, N}}, Tuple{Int, Int, Vararg{Int, N}}} where {N}
for B in Bs
C = typeintersect(A, B)
@test C == typeintersect(B, A) != Union{}
@test C != Cerr
@test_broken C != B
@testintersect(A, B, C)
end
end

Expand Down

0 comments on commit 2d682f7

Please sign in to comment.