Skip to content

Commit 4638697

Browse files
authored
Remove Base.convert(::Type{Decimal}, ::Real) (#99)
The method is unnecessary. We define constructors from `Real`s, which is enough for the fallback `convert` method to work. This commit also removes a useless test file.
1 parent 1a4e538 commit 4638697

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

src/conversion.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ function Decimal(x::AbstractFloat)
2424
return Decimal(s, c, q)
2525
end
2626

27-
Base.convert(::Type{Decimal}, x::Real) = Decimal(x)
28-
2927
function Base.BigFloat(x::Decimal)
3028
y = BigFloat(x.c)
3129
if x.q 0

test/runtests.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,8 @@ using Test
33

44
@testset "Decimals" begin
55

6-
global d = [
7-
Decimal(false, 2, -1)
8-
Decimal(false, 1, -1)
9-
Decimal(false, 100, -4)
10-
Decimal(false, 1512, -2)
11-
Decimal(true, 3, -2)
12-
Decimal(true, 4, -6)
13-
]
14-
156
include("test_arithmetic.jl")
167
include("test_bigint.jl")
17-
include("test_constructor.jl")
188
include("test_context.jl")
199
include("test_decimal.jl")
2010
include("test_equals.jl")

test/test_constructor.jl

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/test_decimal.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ using Decimals
22
using Test
33

44
@testset "Conversions" begin
5+
@testset "Decimal to Decimal" begin
6+
x = Decimal(1, 2, 3)
7+
@test Decimal(x) === x
8+
end
9+
510
@testset "$T" for T in [Float32, Float64, BigFloat]
611
@test T(Decimal(T(0.0))) == T(0.0)
712
@test T(Decimal(T(-0.0))) == T(-0.0)

0 commit comments

Comments
 (0)