Skip to content

Commit

Permalink
Fixing the errors for v0.6. (#2)
Browse files Browse the repository at this point in the history
* Fixing the errors for v0.6.

* Removed 0.4 from travis-ci

* trying to fix for 0.5

* Ensuring minimal changes needed.
  • Loading branch information
sambitdash authored and anthonyclays committed Aug 10, 2017
1 parent 8ae444b commit 596e4b3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ os:
- linux
- osx
julia:
- 0.4
- 0.5
- 0.6
- nightly
notifications:
email: false
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.5
Primes
Compat
8 changes: 4 additions & 4 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Base: ==, isless, <=, <, >,
import Base: ==, isless, <=, <, >,
+, -, *, ^, max, min, div, %, gcd, lcm,
isqrt, isodd, iseven, one, isprime, factor, primes
isqrt, isodd, iseven, one

# Remember that RN is typealiased to RomanNumeral

Expand Down Expand Up @@ -34,11 +34,11 @@ for op in [:isodd, :iseven, :isprime]
end

# Who knew Romans did number theory
function Base.factor(num::RN)
function Primes.factor(num::RN)
factors = Dict{RN,RN}()
for (fac, mul) in factor(num.val)
factors[RN(fac)] = RN(mul)
end
factors
end
Base.primes(num::RN) = map(RN, primes(num.val))
Primes.primes(num::RN) = map(RN, Primes.primes(num.val))
2 changes: 1 addition & 1 deletion src/roman_conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function parseroman(str::String)
# Strip whitespace
str = m.captures[1]
# Make `str` uppercase
if !isupper(str); str = uppercase(str); end
if !all(isupper,str); str = uppercase(str); end
i = 1
val = 0
strlen = length(str)
Expand Down
6 changes: 4 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Compat

# Thrown when the string passed to `parseroman` is not a valid Roman numeral.
type InvalidRomanError <: Exception
str::String
Expand All @@ -20,7 +22,7 @@ macro rn_str(str)
RomanNumeral(str)
end

typealias RN RomanNumeral
const RN = RomanNumeral

# Standard functions
# Conversion + promotion
Expand All @@ -36,4 +38,4 @@ Base.print(io::IO, num::RN) = print(io, num.str)
Base.show(io::IO, num::RN) = write(io, num.str)

Base.length(num::RN) = length(num.str)
Base.hash(num::RN) = hash(num.str) $ hash(num.val)
Base.hash(num::RN) = @compat xor(hash(num.str), hash(num.val))
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using RomanNumerals
using Base.Test
using Primes

# Constructor tests
@test RomanNumeral(46) == RomanNumeral("XLVI")
Expand Down

0 comments on commit 596e4b3

Please sign in to comment.