Skip to content

Commit

Permalink
Merge pull request #3 from timholy/teh/fix_0.5
Browse files Browse the repository at this point in the history
Fix 0.5 deprecations and breakages
  • Loading branch information
mauro3 authored Jul 25, 2016
2 parents 03b6a65 + 711fd91 commit e0d4285
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
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


0 comments on commit e0d4285

Please sign in to comment.