Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various tests for a few missing dispatches #13985

Merged
merged 3 commits into from
Nov 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I think you can do this as

@test sprint(show,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