From cbc32a50817206d0be83b1630d2f9dbee13808da Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 10 Apr 2017 15:07:27 -0400 Subject: [PATCH] add tests for issues #10207, #10178, #12939 --- test/core.jl | 16 ++++++++++++++++ test/inference.jl | 7 +++++++ test/staged.jl | 12 ++++++++++++ 3 files changed, 35 insertions(+) diff --git a/test/core.jl b/test/core.jl index 2016d2d5973ee..8fd63755a1f13 100644 --- a/test/core.jl +++ b/test/core.jl @@ -81,6 +81,22 @@ _bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1 @test _bound_vararg_specificity_1(Array{Int,1}, 1) == 1 @test _bound_vararg_specificity_1(Array{Int,2}, 1, 1) == 0 +# issue #12939 +module Issue12939 +abstract type Abs; end +struct Foo <: Abs; end +struct Bar; val::Int64; end +struct Baz; val::Int64; end +f{T}(::Type{T}, x::T) = T(3) +f{T <: Abs}(::Type{Bar}, x::T) = Bar(2) +f(::Type{Bar}, x) = Bar(1) +f(::Type{Baz}, x) = Baz(1) +f{T <: Abs}(::Type{Baz}, x::T) = Baz(2) +end + +@test Issue12939.f(Issue12939.Baz,Issue12939.Foo()) === Issue12939.Baz(2) +@test Issue12939.f(Issue12939.Bar,Issue12939.Foo()) === Issue12939.Bar(2) + # issue #11840 TT11840{T} = Tuple{T,T} f11840(::Type) = "Type" diff --git a/test/inference.jl b/test/inference.jl index 7cf7f368551f6..b0673e8e1ba25 100644 --- a/test/inference.jl +++ b/test/inference.jl @@ -738,3 +738,10 @@ let e = code_typed(f21175, ())[1].first.code[1]::Expr @test e.head === :return @test e.args[1] == Core.QuoteNode(902221) end + +# issue #10207 +type T10207{A, B} + a::A + b::B +end +@test code_typed(T10207, (Int,Any))[1].second == T10207{Int,T} where T diff --git a/test/staged.jl b/test/staged.jl index c9066742eff76..28bb661fe361e 100644 --- a/test/staged.jl +++ b/test/staged.jl @@ -213,3 +213,15 @@ end # issue #19897 @test code_lowered(staged_t1, (Int,Int)) isa Array # check no error thrown + +# issue #10178 +@generated function f10178(x::X) where X + :(x) +end +g10178(x) = f10178(x) +@test g10178(5) == 5 +@generated function f10178(x::X) where X + :(2x) +end +g10178(x) = f10178(x) +@test g10178(5) == 10