Skip to content

Commit

Permalink
Fix typo in promote, add tests (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman authored Jan 16, 2025
1 parent 579d68d commit 6fbfd76
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnspecifiedTypes"
uuid = "42b3faec-625b-4613-8ddc-352bf9672b8d"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.1.1"
version = "0.1.2"

[compat]
julia = "1.10"
2 changes: 1 addition & 1 deletion src/unspecifiedzero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Base.:/(::Number, ::UnspecifiedZero) = throw(DivideError())
Base.:/(::UnspecifiedZero, ::UnspecifiedZero) = throw(DivideError())
Base.:-(::UnspecifiedZero) = UnspecifiedZero()

Base.promote_rule(::Type{<:UnspecifiedZero}, t::Type) = t2
Base.promote_rule(::Type{<:UnspecifiedZero}, t::Type) = t
Base.promote_rule(::Type{<:UnspecifiedZero}, ::Type{<:UnspecifiedZero}) = UnspecifiedZero
Base.promote_type(::Type{<:Complex{<:UnspecifiedZero}}, t::Type) = complex(t)
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d"

[compat]
Aqua = "0.8.9"
Expand Down
16 changes: 16 additions & 0 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UnspecifiedTypes: UnspecifiedZero
using Test: @testset, @test

@testset "UnspecifiedTypes (eltype=$elt)" for elt in (
Float32, Float64, Complex{Float32}, Complex{Float64}
)
for x in (elt(2) + UnspecifiedZero(), UnspecifiedZero() + elt(2))
@test x isa elt
@test x === elt(2)
end

for x in (elt(2) * UnspecifiedZero(), UnspecifiedZero() * elt(2))
@test x isa UnspecifiedZero
@test x === UnspecifiedZero()
end
end

0 comments on commit 6fbfd76

Please sign in to comment.