Skip to content

Commit

Permalink
Added tests for math.jl functions
Browse files Browse the repository at this point in the history
(cherry picked from commit 0542cb1)
ref PR #9568
  • Loading branch information
kshyatt authored and tkelman committed Jan 4, 2015
1 parent e6ce7d9 commit f4bd89f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f4bd89f

Please sign in to comment.