Skip to content

Commit 2971816

Browse files
macdomus
authored andcommitted
Need to use 'something()' rather than 'coalesce()' because findfirst(… (#25)
* Need to use 'something()' rather than 'coalesce()' because findfirst() returns 'nothing' when there is no match' * Remove 0.6 from CI scripts * Bumped Julia version in REQUIRE to 0.7-beta2 and removed (for now) dependence on compat * Added Compat back to REQUIRES and updated both of the CI scripts * Forgot to remove 0.6 Julia version
1 parent e059f99 commit 2971816

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
88
- nightly
99
notifications:
1010
email: false

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
julia 0.6
1+
julia 0.7-beta2
22
Compat 0.64.0

appveyor.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: latest
5+
6+
platform:
7+
- x86
8+
- x64
9+
10+
## uncomment the following lines to allow failures on nightly julia
11+
## (tests will run but not make your overall status red)
12+
#matrix:
13+
# allow_failures:
14+
# - julia_version: latest
715

816
branches:
917
only:
@@ -17,19 +25,12 @@ notifications:
1725
on_build_status_changed: false
1826

1927
install:
20-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
21-
# Download most recent Julia Windows binary
22-
- ps: (new-object net.webclient).DownloadFile(
23-
$env:JULIA_URL,
24-
"C:\projects\julia-binary.exe")
25-
# Run installer silently, output to C:\projects\julia
26-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
28+
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/master/bin/install.ps1'))
2729

2830
build_script:
29-
# Need to convert from shallow to complete for Pkg.clone to work
30-
- IF EXIST .git\shallow (git fetch --unshallow)
31-
- C:\projects\julia\bin\julia -e "versioninfo();
32-
Pkg.clone(pwd(), \"FixedPointDecimals\"); Pkg.build(\"FixedPointDecimals\")"
31+
- echo "%JL_BUILD_SCRIPT%"
32+
- julia -e "%JL_BUILD_SCRIPT%"
3333

3434
test_script:
35-
- C:\projects\julia\bin\julia -e "Pkg.test(\"FixedPointDecimals\")"
35+
- echo "%JL_TEST_SCRIPT%"
36+
- julia -e "%JL_TEST_SCRIPT%"

src/FixedPointDecimals.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ module FixedPointDecimals
2727

2828
export FixedDecimal, RoundThrows
2929

30-
using Compat
31-
3230
import Base: reinterpret, zero, one, abs, sign, ==, <, <=, +, -, /, *, div, rem, divrem,
3331
fld, mod, fldmod, fld1, mod1, fldmod1, isinteger, typemin, typemax,
3432
realmin, realmax, print, show, string, convert, parse, promote_rule, min, max,
@@ -209,7 +207,7 @@ as a floating point number.
209207
This is equivalent to counting the number of bits needed to represent the
210208
integer, excluding any trailing zeros.
211209
"""
212-
required_precision(n::Integer) = ndigits(n, 2) - trailing_zeros(n)
210+
required_precision(n::Integer) = ndigits(n, base=2) - trailing_zeros(n)
213211

214212
"""
215213
_apply_exact_float(f, T, x::Real, i::Integer)
@@ -387,7 +385,7 @@ function parse(::Type{FD{T, f}}, str::AbstractString, mode::RoundingMode=RoundNe
387385
end
388386

389387
# Parse exponent information
390-
exp_index = coalesce(findfirst(==('e'), str), 0)
388+
exp_index = something(findfirst(==('e'), str), 0)
391389
if exp_index > 0
392390
exp = parse(Int, str[(exp_index + 1):end])
393391
sig_end = exp_index - 1
@@ -398,7 +396,7 @@ function parse(::Type{FD{T, f}}, str::AbstractString, mode::RoundingMode=RoundNe
398396

399397
# Remove the decimal place from the string
400398
sign = T(first(str) == '-' ? -1 : 1)
401-
dec_index = coalesce(findfirst(==('.'), str), 0)
399+
dec_index = something(findfirst(==('.'), str), 0)
402400
sig_start = sign < 0 ? 2 : 1
403401
if dec_index > 0
404402
int_str = str[sig_start:(dec_index - 1)] * str[(dec_index + 1):sig_end]

0 commit comments

Comments
 (0)