Skip to content

Commit

Permalink
Make aqua tests pass (fix an ambiguity)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuszmaul committed Jan 23, 2025
1 parent d3b8d29 commit a7eb1e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ version = "0.3.2"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
Aqua = "0.7, 0.8"
julia = "1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Statistics", "Test", "Serialization"]
test = ["Aqua", "Statistics", "Test", "Serialization"]
3 changes: 2 additions & 1 deletion src/BitIntegers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ promote_rule(::Type{Float16}, ::Type{<:XBI}) = Float16
(::Type{T})(x::AbstractFloat) where {T<:XBI} = T(BigInt(x))::T
# to disambiguate:
(::Type{T})(x::Float16) where {T<:XBI} = T(BigInt(x))::T

# to disambiguate:
(::Type{T})(x::BigFloat) where {T<:XBI} = T(BigInt(x))::T

# * comparisons

Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,15 @@ end
end
end
end

@testset "aqua" begin
using Aqua
Aqua.test_all(BitIntegers; deps_compat = false, piracies=false)
Aqua.test_deps_compat(BitIntegers; ignore=[:Random], check_extras=false)
# BitIntegers defines methods such as `<(::UBS, ::UBU)` which is (probably
# benign) type piracy.
Aqua.test_piracies(BitIntegers; treat_as_own = [Int128, Int16, Int64, Int32, Int8])

# And test the new method for disambiguation
@test Int256(BigFloat(3)) === Int256(3)
end

0 comments on commit a7eb1e6

Please sign in to comment.