From 3a1be853019c584d1146e7649715e9c353f50302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Baru=C4=8Di=C4=87?= Date: Tue, 19 Nov 2024 13:10:49 +0100 Subject: [PATCH] Remove `Base.convert(::Type{Decimal}, ::Real)` 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. --- src/conversion.jl | 2 -- test/runtests.jl | 10 ---------- test/test_constructor.jl | 8 -------- 3 files changed, 20 deletions(-) delete mode 100644 test/test_constructor.jl diff --git a/src/conversion.jl b/src/conversion.jl index 3ba1307..9de0fd8 100644 --- a/src/conversion.jl +++ b/src/conversion.jl @@ -24,8 +24,6 @@ function Decimal(x::AbstractFloat) return Decimal(s, c, q) end -Base.convert(::Type{Decimal}, x::Real) = Decimal(x) - function Base.BigFloat(x::Decimal) y = BigFloat(x.c) if x.q ≥ 0 diff --git a/test/runtests.jl b/test/runtests.jl index 083fa01..b94c506 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,18 +3,8 @@ using Test @testset "Decimals" begin -global d = [ - Decimal(false, 2, -1) - Decimal(false, 1, -1) - Decimal(false, 100, -4) - Decimal(false, 1512, -2) - Decimal(true, 3, -2) - Decimal(true, 4, -6) -] - include("test_arithmetic.jl") include("test_bigint.jl") -include("test_constructor.jl") include("test_context.jl") include("test_decimal.jl") include("test_equals.jl") diff --git a/test/test_constructor.jl b/test/test_constructor.jl deleted file mode 100644 index fb82d73..0000000 --- a/test/test_constructor.jl +++ /dev/null @@ -1,8 +0,0 @@ -using Decimals -using Test - -@testset "Decimal constructor" begin - -@test d isa Vector{Decimal} - -end