From f4bd89faf894eb7d1a232b290b46c9c77db2cc09 Mon Sep 17 00:00:00 2001 From: kshyatt Date: Fri, 2 Jan 2015 23:11:33 -0500 Subject: [PATCH] Added tests for math.jl functions (cherry picked from commit 0542cb165adb8e7490923d0ce6ef3eeaeb8e13aa) ref PR #9568 --- test/math.jl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/math.jl b/test/math.jl index ef14e86eb7dc6..d6a07e1c8ee38 100644 --- a/test/math.jl +++ b/test/math.jl @@ -324,3 +324,22 @@ end for z in (1.234, 1.234 + 5.678im, [1.234, 5.678]) @test_approx_eq cis(z) exp(im*z) end + +# modf +for elty in (Float32, Float64) + @test_approx_eq modf( convert(elty,1.2) )[1] convert(elty,0.2) + @test_approx_eq modf( convert(elty,1.2) )[2] convert(elty,1.0) + @test_approx_eq modf( convert(elty,1.0) )[1] convert(elty,0.0) + @test_approx_eq modf( convert(elty,1.0) )[2] convert(elty,1.0) +end + +# frexp +for elty in (Float32, Float64) + @test frexp( convert(elty,0.5) ) == (convert(elty,0.5),0) + @test frexp( convert(elty,4.0) ) == (convert(elty,0.5),3) + @test_approx_eq frexp( convert(elty,10.5) )[1] convert(elty,0.65625) + @test frexp( convert(elty,10.5) )[2] == 4 + @test_approx_eq frexp( [ convert(elty,4.0) convert(elty,10.5) ] )[1][1] convert(elty,0.5) + @test_approx_eq frexp( [ convert(elty,4.0) convert(elty,10.5) ] )[1][2] convert(elty,0.65625) + @test frexp( [ convert(elty,4.0) convert(elty,10.5) ] )[2] == [ 3 4 ] +end