From 60f2c9e9bbc5c979292dea36a93d77dcf1a281c3 Mon Sep 17 00:00:00 2001 From: felix Date: Fri, 17 Feb 2017 11:56:08 +0000 Subject: [PATCH] add more tests #12814 #16922 #17943 #18892 #19159 #19413 #19041 #19985 --- test/subtype.jl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/subtype.jl b/test/subtype.jl index 61c87cb2b4bc6..528d88c5637a4 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -939,3 +939,36 @@ f11407{K,V}(::Dict{K,V},::Dict{Any,V}) = 1 f11407{K,V}(::Dict{K,V},::Dict{K,Any}) = 2 d11407 = Dict{Any,Any}() @test_throws MethodError f11407(d11407,d11407) + +# #12814 +abstract type A12814{N, T} end +struct B12814{N, T} <: A12814{N, T} + x::NTuple{N, T} +end +Base.call{T <: A12814, X <: Array}(::Type{T}, x::X) = 1 +@test_throws MethodError B12814{3, Float32}([1,2,3]) + +# #16922 +U16922{T} = Union{AbstractVector{T}, AbstractVector{Nullable{T}}} +@test AbstractArray{Nullable{Int},1} <: U16922{Int} + +# #17943 +@test_throws TypeError Int{} + +# #18892, dup #19159 #19413 +f18892(x) = 1 +f18892{T}(x::T) = 2 +@test f18892(0) == 2 + +# #19041 +mutable struct A19041{K} end +A19041(K::Type) = A19041{K}() +struct B19041{T} end +f19041{K}(x::A19041{K}) = deepcopy(x) +@test f19041(A19041(B19041)) == A19041{B19041}() + +# #19985 +f19985{T<:Union{Int32,Int64}}(x::T, y...) = (length(y), f(y[1], y[2:end]...)...) +f19985{T<:Union{Int32,Int64}}(x::T) = (100) +@test f(1,rand(1)...) == (1,100) +