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

Move signif tests to appropriate file and grab one last one #26056

Merged
merged 1 commit into from
Feb 16, 2018
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
25 changes: 25 additions & 0 deletions test/floatfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,28 @@ end
@test float(typeof(complex(x, x))) == typeof(float(complex(x, x)))
end
end

@testset "significant digits" begin
# (would be nice to have a smart vectorized
# version of signif)
@test signif(123.456,1) ≈ 100.
@test signif(123.456,3) ≈ 123.
@test signif(123.456,5) ≈ 123.46
@test signif(123.456,8,2) ≈ 123.5
@test signif(123.456,2,4) ≈ 128.0
@test signif(0.0, 1) === 0.0
@test signif(-0.0, 1) === -0.0
@test signif(1.2, 2) === 1.2
@test signif(1.0, 6) === 1.0
@test signif(0.6, 1) === 0.6
@test signif(7.262839104539736, 2) === 7.3
@test isinf(signif(Inf, 3))
@test isnan(signif(NaN, 3))
@test signif(1.12312, 1000) === 1.12312
@test signif(Float32(7.262839104539736), 3) === Float32(7.26)
@test signif(Float32(7.262839104539736), 4) === Float32(7.263)
@test signif(Float32(1.2), 3) === Float32(1.2)
@test signif(Float32(1.2), 5) === Float32(1.2)
@test signif(Float16(0.6), 2) === Float16(0.6)
@test signif(Float16(1.1), 70) === Float16(1.1)
end
23 changes: 0 additions & 23 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1777,29 +1777,6 @@ end
@test 0x1.fffffffffffffp1023 == realmax()
@test isinf(nextfloat(0x1.fffffffffffffp1023))
end
@testset "significant digits" begin
# (would be nice to have a smart vectorized
# version of signif)
@test signif(123.456,1) ≈ 100.
@test signif(123.456,3) ≈ 123.
@test signif(123.456,5) ≈ 123.46
@test signif(123.456,8,2) ≈ 123.5
@test signif(0.0, 1) === 0.0
@test signif(-0.0, 1) === -0.0
@test signif(1.2, 2) === 1.2
@test signif(1.0, 6) === 1.0
@test signif(0.6, 1) === 0.6
@test signif(7.262839104539736, 2) === 7.3
@test isinf(signif(Inf, 3))
@test isnan(signif(NaN, 3))
@test signif(1.12312, 1000) === 1.12312
@test signif(Float32(7.262839104539736), 3) === Float32(7.26)
@test signif(Float32(7.262839104539736), 4) === Float32(7.263)
@test signif(Float32(1.2), 3) === Float32(1.2)
@test signif(Float32(1.2), 5) === Float32(1.2)
@test signif(Float16(0.6), 2) === Float16(0.6)
@test signif(Float16(1.1), 70) === Float16(1.1)
end
@testset "issue #1308" begin
@test hex(~UInt128(0)) == "f"^32
@test (~0)%UInt128 == ~UInt128(0)
Expand Down