Skip to content

Commit

Permalink
Merge pull request #24 from miguelraz/master
Browse files Browse the repository at this point in the history
Fixes for 1.0
  • Loading branch information
oxinabox authored Aug 11, 2018
2 parents 7db3f8d + 2e031b3 commit 50429d1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 56 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ os:
- linux
- osx
julia:
- 0.6
- 0.7
- 1.0
- nightly
notifications:
email: false
Expand Down Expand Up @@ -32,4 +33,4 @@ after_success:
# push coverage results to Coveralls
# - julia -e 'cd(Pkg.dir("InternedStrings")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("InternedStrings")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'Pkg.dir("InternedStrings"); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
julia 0.6
Compat 0.52
julia 0.7
53 changes: 24 additions & 29 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- 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"

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
matrix:
allow_failures:
- 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
- julia_version: nightly

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:
Expand All @@ -24,25 +26,18 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# 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 "VERSION < v\"0.7.0-DEV\" || (using InteractiveUtils);
versioninfo(); pkg = \"InternedStrings\";
if VERSION < v\"0.7.0-DEV.5183\"; Pkg.clone(pwd(), pkg); else ; Pkg.up(); end"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"InternedStrings\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
10 changes: 2 additions & 8 deletions src/InternedStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ Licensed under MIT License, see LICENSE.md
"""
module InternedStrings

using Compat

export @i_str, intern

Base.@deprecate_binding(InternedString, String, true)

@static if VERSION < v"0.7.0-DEV"
const ht_keyindex2! = Base.ht_keyindex2
else
using Base: ht_keyindex2!
end
using Base: ht_keyindex2!

########################
# The pool/interning lookup core code
Expand All @@ -42,7 +36,7 @@ end
# Not found, so add it,
# and mark it as a reference we track to delete!
kk::K = convert(K, key)
@compat finalizer(wkd.finalizer, kk) # finalizer is set on the strong ref
finalizer(wkd.finalizer, kk) # finalizer is set on the strong ref
@inbounds Base._setindex!(wkd.ht, nothing, WeakRef(kk), -index)
unlock(wkd.lock)
return kk # Return the strong ref
Expand Down
3 changes: 1 addition & 2 deletions test/all_kinds_of_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ end
@test addr_eq(ex1, ex2)
end

# Enable when https://github.com/JuliaLang/julia/issues/26939 is fixed
false && @testset "BigFloat" begin
@testset "BigFloat" begin
let
pi1 = intern(BigFloat(π))
@test pi1 == BigFloat(π)
Expand Down
6 changes: 3 additions & 3 deletions test/corefunctionality.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end
end
end

using Compat.GC
using Base.GC
@testset "Garbage Collection 1" begin let
empty!(InternedStrings.pool)
@test length(InternedStrings.pool)==0
Expand Down Expand Up @@ -89,8 +89,8 @@ end end
end end


using Compat.Random
srand(1)
using Random
Random.seed!(1)
@testset "Garbage Collection stress test" begin let
empty!(InternedStrings.pool)
oldpoolsize = length(InternedStrings.pool)
Expand Down
16 changes: 6 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using InternedStrings

const V6_COMPAT = VERSION < v"0.7.0-DEV"
@static if V6_COMPAT
using Base.Test
unsafe_wrap(::Type{Vector{UInt8}}, str) = Vector{UInt8}(str)
const objectid = object_id
else
using Test, Random
const gc = GC.gc
end
addr_eq(a,b) = pointer(a) === pointer(b)

using Test, Random, Base.GC

addr_eq(a::String, b::String) = pointer(a) === pointer(b)
addr_eq(a, b) = objectid(a) === objectid(b)


@testset "All kinds of types" begin include("all_kinds_of_types.jl") end
@testset "String macro" begin include("string_macro.jl") end
Expand Down

0 comments on commit 50429d1

Please sign in to comment.