From 3a9e9941fa460a4e0fcb142e7c0939c5d07a2f84 Mon Sep 17 00:00:00 2001 From: Katie Hyatt Date: Fri, 13 Nov 2015 18:33:38 -0800 Subject: [PATCH 1/3] Few more math tests --- test/math.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/math.jl b/test/math.jl index 28aaf9c14475f..d13e2ff93201d 100644 --- a/test/math.jl +++ b/test/math.jl @@ -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 From adff4be374695f5ab1a5378e0f47611075fdd132 Mon Sep 17 00:00:00 2001 From: Katie Hyatt Date: Fri, 13 Nov 2015 18:34:02 -0800 Subject: [PATCH 2/3] Show and intersection tests --- test/ranges.jl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/ranges.jl b/test/ranges.jl index b94bf4194fbb3..0f5e6d3c90ede 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -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 @@ -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) @@ -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 @@ -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)) From b2459a64da9e6b3832168915bb63dd46701ba6f6 Mon Sep 17 00:00:00 2001 From: Katie Hyatt Date: Fri, 13 Nov 2015 18:34:11 -0800 Subject: [PATCH 3/3] isprime for various int types --- test/numbers.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/numbers.jl b/test/numbers.jl index 1cac324542b3e..8973ceb1468d1 100644 --- a/test/numbers.jl +++ b/test/numbers.jl @@ -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)