Skip to content

Commit

Permalink
Drop support for Julia 0.6 (#47)
Browse files Browse the repository at this point in the history
* Drop Julia 0.6 support

* Drop Compat dependency

* Drop sprintcompact

* Test against Julia 1.1

* Add Project.toml
  • Loading branch information
omus authored and ararslan committed Feb 11, 2019
1 parent 1fd5ca2 commit 07d24d9
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.jl.cov
*.jl.*.cov
*.jl.mem

Manifest.toml
16 changes: 3 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@ os:
- linux
- osx
julia:
- 0.6
- 1.0
- 1.1
- nightly
notifications:
email: false
after_success:
- |
julia -e '
VERSION >= v"0.7.0-DEV.3656" && using Pkg
VERSION >= v"0.7.0-DEV.5183" || cd(Pkg.dir("FixedPointDecimals"))
Pkg.add("Coverage"); using Coverage
Coveralls.submit(process_folder())'
- |
julia -e '
VERSION >= v"0.7.0-DEV.3656" && using Pkg
VERSION >= v"0.7.0-DEV.5183" || cd(Pkg.dir("FixedPointDecimals"))
Pkg.add("Coverage"); using Coverage
Codecov.submit(process_folder())'
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
13 changes: 13 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "FixedPointDecimals"
uuid = "fb4d412d-6eee-574d-9565-ede6634db7b0"
authors = ["Fengyang Wang <[email protected]>", "Curtis Vogt <[email protected]>"]

[compat]
julia = "0.7, 1.0"

[extras]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Printf", "Test"]
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
julia 0.6
Compat 1.1.0
julia 0.7
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- julia_version: 0.6
- julia_version: 1
- julia_version: 1.0
- julia_version: 1.1
- julia_version: nightly

platform:
Expand Down
15 changes: 2 additions & 13 deletions src/FixedPointDecimals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ module FixedPointDecimals

export FixedDecimal, RoundThrows

using Compat: lastindex, something

import Compat: floatmin, floatmax

import Base: reinterpret, zero, one, abs, sign, ==, <, <=, +, -, /, *, div, rem, divrem,
fld, mod, fldmod, fld1, mod1, fldmod1, isinteger, typemin, typemax,
print, show, string, convert, parse, promote_rule, min, max,
trunc, round, floor, ceil, eps, float, widemul, decompose
floatmin, floatmax, trunc, round, floor, ceil, eps, float, widemul, decompose

const BitInteger = Union{Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64,
UInt64, Int128, UInt128}
Expand Down Expand Up @@ -223,14 +219,7 @@ as a floating point number.
This is equivalent to counting the number of bits needed to represent the
integer, excluding any trailing zeros.
"""
required_precision(::Integer)

# https://github.com/JuliaLang/julia/pull/27908
if VERSION < v"0.7.0-beta.183"
required_precision(n::Integer) = ndigits(n, 2) - trailing_zeros(n)
else
required_precision(n::Integer) = ndigits(n, base=2) - trailing_zeros(n)
end
required_precision(n::Integer) = ndigits(n, base=2) - trailing_zeros(n)

"""
_apply_exact_float(f, T, x::Real, i::Integer)
Expand Down
19 changes: 9 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using FixedPointDecimals
import FixedPointDecimals: FD, value
using Compat
using Compat.Test
using Compat.Printf
using FixedPointDecimals: FD, value
using Test
using Printf
using Base.Checked: checked_mul

include("utils.jl")
Expand Down Expand Up @@ -788,12 +787,12 @@ end

@testset "show" begin
@testset "compact" begin
@test sprintcompact(FD2(1.00)) == "1.0"
@test sprintcompact(FD2(1.23)) == "1.23"
@test sprintcompact(FD2(42.40)) == "42.4"
@test sprintcompact(FD2(-42.40)) == "-42.4"
@test sprintcompact(FD2(-0.01)) == "-0.01"
@test sprintcompact(FD2(0)) == "0.0"
@test sprint(show, FD2(1.00), context=:compact=>true) == "1.0"
@test sprint(show, FD2(1.23), context=:compact=>true) == "1.23"
@test sprint(show, FD2(42.40), context=:compact=>true) == "42.4"
@test sprint(show, FD2(-42.40), context=:compact=>true) == "-42.4"
@test sprint(show, FD2(-0.01), context=:compact=>true) == "-0.01"
@test sprint(show, FD2(0), context=:compact=>true) == "0.0"

@test repr(typemin(FixedDecimal{Int64, 2})) ==
"FixedDecimal{Int64,2}(-92233720368547758.08)"
Expand Down
6 changes: 0 additions & 6 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,3 @@ function ceil_alt(::Type{FD{T,f}}, val::AbstractFloat) where {T<:Integer, f}
s, v, r = integer_alt(T, f, val)
reinterpret(FD{T,f}, copysign(v + (s > 0 ? r : zero(T)), s))
end

if VERSION < v"0.7.0-DEV.4524"
sprintcompact(x...) = sprint(showcompact, x...)
else
sprintcompact(x...) = sprint(show, x..., context=:compact=>true)
end

0 comments on commit 07d24d9

Please sign in to comment.