diff --git a/test/core.jl b/test/core.jl index 853c26bcb0be3..7600100821e1a 100644 --- a/test/core.jl +++ b/test/core.jl @@ -68,6 +68,7 @@ let T = TypeVar(:T,true) @test typeintersect(Type{Array{T}}, Type{AbstractArray{T}}) === Bottom + @test typeintersect(Tuple{Vararg{T}},Tuple{Float64,Int}) === Bottom @test typeintersect(Type{Tuple{Bool,Vararg{Int}}}, Type{Tuple{Vararg{T}}}) === Bottom @test typeintersect(Type{Tuple{Bool,Vararg{Int}}}, Type{Tuple{T,Vararg{T}}}) === Bottom @@ -115,6 +116,26 @@ let T = TypeVar(:T,Union(Float32,Float64),true) @test typeintersect(AbstractArray, Matrix{T}) == Matrix{T} end +# Vararg{T,N} +let N = TypeVar(:N,true) + @test is(Bottom,typeintersect(Tuple{Array{Int,N},Vararg{Int,N}}, Tuple{Vector{Int},Real,Real,Real})) + @test is(Bottom,typeintersect(Tuple{Vector{Int},Real,Real,Real}, Tuple{Array{Int,N},Vararg{Int,N}})) + @test Tuple{Int,Vararg{Int,2}} == Tuple{Int,Int,Int} + @test Tuple{Int,Vararg{Int,2}} == Tuple{Int,Int,Vararg{Int,1}} + @test Tuple{Int,Vararg{Int,2}} == Tuple{Int,Int,Int,Vararg{Int,0}} + @test !(Tuple{Int,Vararg{Int,2}} <: Tuple{Int,Int,Int,Vararg{Int,1}}) + #@test !(Tuple{Int,Vararg{Int,2}} <: Tuple{Int,Vararg{Int,N}}) + @test Tuple{Int,Vararg{Int,N}} == Tuple{Int,Vararg{Int,N}} + #@test !(Tuple{Int,Vararg{Int,2}} <: Tuple{Int,Int,Vararg{Int}}) + @test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}},Tuple{Array{Int,0}}) == Tuple{Array{Int,0}} + @test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}},Tuple{Array{Int,2}}) == Bottom + + @test typeintersect(Tuple{Int,Vararg{Int,N}}, Tuple{Int,Int,Int,Vararg{Float64}}) == Tuple{Int,Int,Int} + @test typeintersect(Tuple{Int,Vararg{Int,N}}, Tuple{Int,Vararg{Float64}}) == Tuple{Int} + @test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}}, Tuple{Matrix{Int},Int,Int,Vararg{Float64}}) == Tuple{Matrix{Int},Int,Int} + @test typeintersect(Tuple{Array{Int,N},Vararg{Int,N}}, Tuple{Matrix{Int},Int,Vararg{Float64}}) == Bottom +end + @test isa(Int,Type{TypeVar(:T,Number)}) @test !isa(DataType,Type{TypeVar(:T,Number)}) @test DataType <: Type{TypeVar(:T,Type)}