Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compat
6 changes: 4 additions & 2 deletions src/SimpleTraits.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module SimpleTraits
const curmod = module_name(current_module())

using Compat

# This is basically just adding a few convenience functions & macros
# around Holy Traits.

Expand Down Expand Up @@ -202,8 +204,8 @@ end
type GenerateTypeVars{CASE}
end
Base.start(::GenerateTypeVars) = 1
Base.next(::GenerateTypeVars{:upcase}, state) = (symbol("X$state"), state+1) # X1,..
Base.next(::GenerateTypeVars{:lcase}, state) = (symbol("x$state"), state+1) # x1,...
Base.next(::GenerateTypeVars{:upcase}, state) = (Symbol("X$state"), state+1) # X1,..
Base.next(::GenerateTypeVars{:lcase}, state) = (Symbol("x$state"), state+1) # x1,...
Base.done(::GenerateTypeVars, state) = false

####
Expand Down
15 changes: 9 additions & 6 deletions test/base-traits.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SimpleTraits.BaseTraits
using Compat: view

@test istrait(IsAnything{Any})
@test istrait(IsAnything{Union{}})
Expand All @@ -14,17 +15,19 @@ using SimpleTraits.BaseTraits
@test istrait(IsImmutable{Float64})
@test !istrait(IsImmutable{Vector{Int}})

@test !istrait(IsCallable{Float64})
@test istrait(IsCallable{Function})

if VERSION>v"0.4-" # use @generated functions
@test istrait(IsContiguous{SubArray{Int64,1,Array{Int64,1},Tuple{UnitRange{Int64}},1}})
@test !istrait(IsContiguous{SubArray{Int64,1,Array{Int64,1},Tuple{StepRange{Int64,Int64}},1}})
a = collect(1:5)
b = view(a, 2:3)
c = view(a, 1:2:5)
@test istrait(IsContiguous{typeof(b)})
@test !istrait(IsContiguous{typeof(c)})

@test istrait(IsFastLinearIndex{Vector})
@test !istrait(IsFastLinearIndex{AbstractArray})

@test istrait(IsCallable{Base.AddFun})
if VERSION < v"0.5.0-dev"
@test istrait(IsCallable{Base.AddFun})
end
end