Skip to content
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.

M3/heisenbug #11

Closed
wants to merge 15 commits into from
Closed
Prev Previous commit
Next Next commit
added test case for another bug
  • Loading branch information
mauro3 committed Apr 10, 2015
commit 4344c4ca2d0a2944522a5bf64fcfb87cd16c7c0a
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dispatch_bug1 = true # in traitdispatch.jl
traitdef_bug1 = true
varag_not_supported_bug = true
constructors_not_supported_bug = true
concrete_type_bug = true

# src/Traits.jl tests
type A1 end
Expand Down
33 changes: 22 additions & 11 deletions test/traitdef.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,15 @@ end
@test issubtrait(Tr13, Tr20)

@test issubtrait((Tr21,), (Tr20,))
@test issubtrait((Tr21,Tr11), (Tr20,Tr10))
@test issubtrait((Tr21,Tr11), (Tr20,Tr10))
@test !issubtrait((Tr21,Tr11), (Tr10,Tr20)) # todo: this should be true, as order shouldn't matter
@test issubtrait((Tr11,Tr21), (Tr10,Tr20))
@test !issubtrait((Tr21,Tr11), (Tr10,Tr20)) # todo: this should be true, I think

@test !issubtrait(Tr21{Int}, Tr20{Float64})
@test !issubtrait((Tr21{Int},), (Tr20{Float64},))

#--> need to be able to do this in terms of type variables.

# test functions parameterized on non-trait parameters. This isn't currently working:
# https://github.com/mauro3/Traits.jl/issues/2
# https://github.com/JuliaLang/julia/issues/9043

# Test functions parameterized on non-trait parameters.
###
@traitdef Pr0{X} begin
fn75{Y <: Integer}(X, Y) -> Y
end
Expand Down Expand Up @@ -208,8 +204,23 @@ fn77{Y<:Real}(a::Array,b::Y, c::Y) = a[1]
fn77{Y<:Number}(a::Array,b::Y, c::Y) = a[1]
@test istrait(Pr2{Array})

# test constraints

@traitdef Pr3{X} begin
fn78{X}(X,X)
end
fn78(b::Int, c::Int) = b
if concrete_type_bug
@test !istrait(Pr3{Int}) # this should not fail!
else
@test istrait(Pr3{Int}) # this should not fail!
end
fn78(b::Real, c::Real) = b
@test !istrait(Pr3{Real})
fn78{T}(b::T, c::T) = b
@test istrait(Pr3{Real})

# Test constraints
###
@traitdef Cr20{X} begin
length(X) -> Any

Expand Down Expand Up @@ -355,6 +366,6 @@ if !varag_not_supported_bug
@test istrait(TT46{Array{Int,1}}, verbose=true)
# @test istrait(TT46{Array{Int}}, verbose=true) # this does not pass currently because of https://github.com/JuliaLang/julia/issues/10642
@test istrait(TT46{Array}, verbose=true)
end
end

end # !constructors_not_supported_bug
end # !constructors_not_supported_bug