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

Added tests for math.jl functions #9568

Merged
merged 1 commit into from
Jan 3, 2015
Merged
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
19 changes: 19 additions & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,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)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess one slightly more concise syntax for testing approximate equality of a tuple-returning function would be by splatting into an array like @test_approx_eq [modf(convert(elty,1.2))...] elty[0.2, 1.0]. There's more syntax features going on there so maybe that's unnecessarily complicated.

@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