From 0480ae20e5a56dcd0f051d207e4edf901c602e21 Mon Sep 17 00:00:00 2001 From: Mauro Date: Wed, 8 Aug 2018 16:12:39 +0000 Subject: [PATCH] Julia 1.0 (#58) * Julia 1.0 Fixes #57 Update appveyor script --- .travis.yml | 3 +- REQUIRE | 2 +- appveyor.yml | 31 +++-- src/SimpleTraits.jl | 8 +- src/base-traits.jl | 10 +- test/base-traits-inference.jl | 3 +- test/base-traits.jl | 6 +- test/runtests-oldfn-syntax.jl | 246 ---------------------------------- test/runtests.jl | 11 -- 9 files changed, 35 insertions(+), 285 deletions(-) delete mode 100644 test/runtests-oldfn-syntax.jl diff --git a/.travis.yml b/.travis.yml index e55dcb5..0525194 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ os: - linux - osx julia: + - 0.7 - nightly # matrix: # allow_failures: @@ -12,4 +13,4 @@ notifications: # uncomment the following lines to override the default test script script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("SimpleTraits"); Pkg.test("SimpleTraits"; coverage=false)' + - julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("SimpleTraits"); Pkg.test("SimpleTraits"; coverage=false)' diff --git a/REQUIRE b/REQUIRE index 30dbed4..d4b1e2d 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ -julia 0.7- +julia 0.7 MacroTools 0.3.2 diff --git a/appveyor.yml b/appveyor.yml index 4ddedc1..2819b1c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,18 @@ environment: matrix: - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" + - julia_version: 0.7 + - julia_version: 1.0 +# - julia_version: latest + +platform: + - x86 # 32-bit + - x64 # 64-bit + +## uncomment the following lines to allow failures on nightly julia +## (tests will run but not make your overall status red) +#matrix: +# allow_failures: +# - julia_version: latest branches: only: @@ -15,19 +26,11 @@ notifications: on_build_status_changed: false install: - - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" -# Download most recent Julia Windows binary - - ps: (new-object net.webclient).DownloadFile( - $env:JULIA_URL, - "C:\projects\julia-binary.exe") -# Run installer silently, output to C:\projects\julia - - C:\projects\julia-binary.exe /S /D=C:\projects\julia + - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) build_script: -# Need to convert from shallow to complete for Pkg.clone to work - - IF EXIST .git\shallow (git fetch --unshallow) - - C:\projects\julia\bin\julia -e "versioninfo(); - Pkg.clone(pwd(), \"SimpleTraits\"); Pkg.build(\"SimpleTraits\")" + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" test_script: - - C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"SimpleTraits\")" +- C:\julia\bin\julia --check-bounds=yes -e "using Pkg; Pkg.test(\"SimpleTraits\"; coverage=false)" diff --git a/src/SimpleTraits.jl b/src/SimpleTraits.jl index e47049d..c591cbe 100644 --- a/src/SimpleTraits.jl +++ b/src/SimpleTraits.jl @@ -1,5 +1,3 @@ -__precompile__() - module SimpleTraits using MacroTools const curmod = nameof(@__MODULE__) @@ -474,10 +472,8 @@ end # generates: X1, X2,... or x1, x2.... (just symbols not actual TypeVar) struct 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.done(::GenerateTypeVars, state) = false +Base.iterate(::GenerateTypeVars{:upcase}, state=1) = (Symbol("X$state"), state+1) # X1,.. +Base.iterate(::GenerateTypeVars{:lcase}, state=1) = (Symbol("x$state"), state+1) # x1,... #### # Annotating the source location diff --git a/src/base-traits.jl b/src/base-traits.jl index 3c3876f..bab43cf 100644 --- a/src/base-traits.jl +++ b/src/base-traits.jl @@ -15,7 +15,8 @@ export IsLeafType, IsConcrete, IsBits, IsImmutable, IsContiguous, IsIndexLinear, "Trait of all isbits-types" @traitdef IsBits{X} -@traitimpl IsBits{X} <- isbits(X) +Base.@pure _isbits(X) = X.isbitstype +@traitimpl IsBits{X} <- _isbits(X) "Trait of all immutable types" @traitdef IsImmutable{X} @@ -62,8 +63,11 @@ Base.@deprecate_binding IsFastLinearIndex IsIndexLinear "Trait of all iterator types" @traitdef IsIterator{X} @generated function SimpleTraits.trait(::Type{IsIterator{X}}) where {X} - error("Not supported in Julia 0.7, due to fallbacks. Should work again in 1.0") - # hasmethod(iterate, Tuple{X}) ? :(IsIterator{X}) : :(Not{IsIterator{X}}) + if VERSION:Int, :IsIterator=>:(Dict{Int,Int})] for (bt, tp) in basetrs - bt==:IsIterator && continue # errors currently - bt==:IsIndexLinear && continue # this is a false negative, not sure why + bt==:IsIterator && VERSION1))==1 -@test f11(Dict(5.5=>1))==2 - -@traitfn f11t{T<:Number}(x::Dict{T}::Tr1) = 1 -@traitfn f11t{T<:Number}(x::Dict{T}::(!Tr1)) = 2 -@test f11t(Dict(1=>1))==1 -@test f11t(Dict(5.5=>1))==2 - -## -@traitfn f12t(::::Tr1) = 1 -@traitfn f12t(::::(!Tr1)) = 2 -@test f12t(1)==1 -@test f12t(5.5)==2 - - -### -# @traitimpl Tr{X} <- istr(X) -@traitdef TrArrow1{X} -isarrow(X) = eltype(X)<:Integer ? true : false -@traitimpl TrArrow1{X} <- isarrow(X) -@test istrait(TrArrow1{Vector{Int}}) -@test !istrait(TrArrow1{Vector{Float64}}) - -@traitdef TrArrow2{X} -@traitimpl Not{TrArrow2{X}} <- isarrow(X) -@test !istrait(TrArrow2{Vector{Int}}) -@test istrait(TrArrow2{Vector{Float64}}) diff --git a/test/runtests.jl b/test/runtests.jl index 8bfc6ae..34effe5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -263,14 +263,3 @@ end include("base-traits.jl") include("base-traits-inference.jl") include("backtraces.jl") - -##### -# Old function syntax -#### -# throws lots of deprecation warnings! -# TODO remove with Julia 0.7 -module OldFnSyntax -println("\n") -println("The following warnings are ok as they test deprecated code:\n") -include("runtests-oldfn-syntax.jl") -end