Skip to content

Commit b4460e6

Browse files
committed
Add more Vararg{T,N} tests
1 parent 4550bce commit b4460e6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/core.jl

+21
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ let T = TypeVar(:T,true)
6868

6969
@test typeintersect(Type{Array{T}}, Type{AbstractArray{T}}) === Bottom
7070

71+
@test typeintersect(Tuple{Vararg{T}},Tuple{Float64,Int}) === Bottom
7172
@test typeintersect(Type{Tuple{Bool,Vararg{Int}}}, Type{Tuple{Vararg{T}}}) === Bottom
7273
@test typeintersect(Type{Tuple{Bool,Vararg{Int}}}, Type{Tuple{T,Vararg{T}}}) === Bottom
7374

@@ -115,6 +116,26 @@ let T = TypeVar(:T,Union(Float32,Float64),true)
115116
@test typeintersect(AbstractArray, Matrix{T}) == Matrix{T}
116117
end
117118

119+
# Vararg{T,N}
120+
let N = TypeVar(:N,true)
121+
@test is(Bottom,typeintersect(Tuple{Array{Int,N},Vararg{Int,N}}, Tuple{Vector{Int},Real,Real,Real}))
122+
@test is(Bottom,typeintersect(Tuple{Vector{Int},Real,Real,Real}, Tuple{Array{Int,N},Vararg{Int,N}}))
123+
@test Tuple{Int,Vararg{Int,2}} == Tuple{Int,Int,Int}
124+
@test Tuple{Int,Vararg{Int,2}} == Tuple{Int,Int,Vararg{Int,1}}
125+
@test Tuple{Int,Vararg{Int,2}} == Tuple{Int,Int,Int,Vararg{Int,0}}
126+
@test !(Tuple{Int,Vararg{Int,2}} <: Tuple{Int,Int,Int,Vararg{Int,1}})
127+
#@test !(Tuple{Int,Vararg{Int,2}} <: Tuple{Int,Vararg{Int,N}})
128+
@test Tuple{Int,Vararg{Int,N}} == Tuple{Int,Vararg{Int,N}}
129+
#@test !(Tuple{Int,Vararg{Int,2}} <: Tuple{Int,Int,Vararg{Int}})
130+
@test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}},Tuple{Array{Int,0}}) == Tuple{Array{Int,0}}
131+
@test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}},Tuple{Array{Int,2}}) == Bottom
132+
133+
@test typeintersect(Tuple{Int,Vararg{Int,N}}, Tuple{Int,Int,Int,Vararg{Float64}}) == Tuple{Int,Int,Int}
134+
@test typeintersect(Tuple{Int,Vararg{Int,N}}, Tuple{Int,Vararg{Float64}}) == Tuple{Int}
135+
@test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}}, Tuple{Matrix{Int},Int,Int,Vararg{Float64}}) == Tuple{Matrix{Int},Int,Int}
136+
@test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}}, Tuple{Matrix{Int},Int,Vararg{Float64}}) == Bottom
137+
end
138+
118139
@test isa(Int,Type{TypeVar(:T,Number)})
119140
@test !isa(DataType,Type{TypeVar(:T,Number)})
120141
@test DataType <: Type{TypeVar(:T,Type)}

0 commit comments

Comments
 (0)