Skip to content

Commit

Permalink
Merge pull request #13985 from JuliaLang/ksh/sm0ltest
Browse files Browse the repository at this point in the history
Various tests for a few missing dispatches
  • Loading branch information
hayd committed Nov 14, 2015
2 parents 7cda13f + b2459a6 commit e17b4bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,15 @@ for T in (Float32, Float64)
@test isnan(log1p(convert(T,NaN)))
@test_throws DomainError log1p(convert(T,-2.0))
end
@test_approx_eq exp10(5) exp10(5.0)

for T in (Int, Float64, BigFloat)
@test_approx_eq deg2rad(T(180)) 1pi
@test_approx_eq deg2rad(T[45, 60]) [pi/T(4), pi/T(3)]
@test_approx_eq rad2deg([pi/T(4), pi/T(3)]) [45, 60]
@test_approx_eq rad2deg(T(1)*pi) 180
@test_approx_eq rad2deg(T(1)) rad2deg(true)
@test_approx_eq deg2rad(T(1)) deg2rad(true)
end

# degree-based trig functions
Expand Down
5 changes: 5 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,11 @@ end
@test !isprime(0xffffffffffffffc7)
@test !isprime(0xffffffffffffffc9)

for T in [Int8,UInt8,Int16,UInt16,Int128,UInt128]
@test isprime(T(2))
@test !isprime(T(4))
end

# issue #5210
@test prod([ k^v for (k,v) in factor(typemax(UInt32)) ]) == typemax(UInt32)
@test prod([ k^v for (k,v) in factor(typemax(Int8)) ]) == typemax(Int8)
Expand Down
13 changes: 13 additions & 0 deletions test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ end
@test intersect(reverse(typemin(Int):2:typemax(Int)),typemin(Int):2:typemax(Int)) == reverse(typemin(Int):2:typemax(Int))
@test intersect(typemin(Int):2:typemax(Int),reverse(typemin(Int):2:typemax(Int))) == typemin(Int):2:typemax(Int)

@test intersect(UnitRange(1,2),3) == UnitRange(3,2)
@test intersect(UnitRange(1,2), UnitRange(1,5), UnitRange(3,7), UnitRange(4,6)) == UnitRange(4,3)

@test sort(UnitRange(1,2)) == UnitRange(1,2)
@test sort!(UnitRange(1,2)) == UnitRange(1,2)

@test 0 in UInt(0):100:typemax(UInt)
@test last(UInt(0):100:typemax(UInt)) in UInt(0):100:typemax(UInt)
@test -9223372036854775790 in -9223372036854775790:100:9223372036854775710
Expand Down Expand Up @@ -243,6 +249,7 @@ end
@test (1:2:6) + 0.3 == 1+0.3:2:5+0.3
@test (1:2:6) - 1 == 0:2:4
@test (1:2:6) - 0.3 == 1-0.3:2:5-0.3
@test 2 .- (1:3) == 1:-1:-1

# operations between ranges and arrays
@test all(([1:5;] + (5:-1:1)) .== 6)
Expand Down Expand Up @@ -523,6 +530,8 @@ end
@test convert(StepRange, 0:5) === 0:1:5
@test convert(StepRange{Int128,Int128}, 0.:5) === Int128(0):Int128(1):Int128(5)

@test_throws ArgumentError StepRange(1.1,1,5.1)

@test promote(0f0:inv(3f0):1f0, 0.:2.:5.) === (0:1/3:1, 0.:2.:5.)
@test convert(FloatRange{Float64}, 0:1/3:1) === 0:1/3:1
@test convert(FloatRange{Float64}, 0f0:inv(3f0):1f0) === 0:1/3:1
Expand Down Expand Up @@ -561,6 +570,10 @@ replstr(x) = stringmime("text/plain", x)
# to cover the designated screen size.
@test replstr(0:10^9) == "1000000001-element UnitRange{$Int}:\n 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,…,999999998,999999999,1000000000"

@test sprint(io -> show(io,UnitRange(1,2))) == "1:2"
@test sprint(io -> show(io,StepRange(1,2,5))) == "1:2:5"


# Issue 11049 and related
@test promote(linspace(0f0, 1f0, 3), linspace(0., 5., 2)) ===
(linspace(0., 1., 3), linspace(0., 5., 2))
Expand Down

0 comments on commit e17b4bd

Please sign in to comment.