From 711fd91672ad8a5a845b2d77fb35a0118e5ba99b Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 24 Jul 2016 12:51:06 -0500 Subject: [PATCH] Fix 0.5 deprecations and breakages --- REQUIRE | 1 + src/SimpleTraits.jl | 6 ++++-- test/base-traits.jl | 15 +++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 REQUIRE diff --git a/REQUIRE b/REQUIRE new file mode 100644 index 0000000..35c5fce --- /dev/null +++ b/REQUIRE @@ -0,0 +1 @@ +Compat diff --git a/src/SimpleTraits.jl b/src/SimpleTraits.jl index 59ff4ce..4b34b6b 100644 --- a/src/SimpleTraits.jl +++ b/src/SimpleTraits.jl @@ -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. @@ -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 #### diff --git a/test/base-traits.jl b/test/base-traits.jl index a86cbde..980fc63 100644 --- a/test/base-traits.jl +++ b/test/base-traits.jl @@ -1,4 +1,5 @@ using SimpleTraits.BaseTraits +using Compat: view @test istrait(IsAnything{Any}) @test istrait(IsAnything{Union{}}) @@ -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 - -