Skip to content

Commit 6fbfd76

Browse files
authored
Fix typo in promote, add tests (#6)
1 parent 579d68d commit 6fbfd76

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "UnspecifiedTypes"
22
uuid = "42b3faec-625b-4613-8ddc-352bf9672b8d"
33
authors = ["ITensor developers <support@itensor.org> and contributors"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[compat]
77
julia = "1.10"

src/unspecifiedzero.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Base.:/(::Number, ::UnspecifiedZero) = throw(DivideError())
3232
Base.:/(::UnspecifiedZero, ::UnspecifiedZero) = throw(DivideError())
3333
Base.:-(::UnspecifiedZero) = UnspecifiedZero()
3434

35-
Base.promote_rule(::Type{<:UnspecifiedZero}, t::Type) = t2
35+
Base.promote_rule(::Type{<:UnspecifiedZero}, t::Type) = t
3636
Base.promote_rule(::Type{<:UnspecifiedZero}, ::Type{<:UnspecifiedZero}) = UnspecifiedZero
3737
Base.promote_type(::Type{<:Complex{<:UnspecifiedZero}}, t::Type) = complex(t)

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
44
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
55
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6+
UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d"
67

78
[compat]
89
Aqua = "0.8.9"

test/test_basics.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using UnspecifiedTypes: UnspecifiedZero
2+
using Test: @testset, @test
3+
4+
@testset "UnspecifiedTypes (eltype=$elt)" for elt in (
5+
Float32, Float64, Complex{Float32}, Complex{Float64}
6+
)
7+
for x in (elt(2) + UnspecifiedZero(), UnspecifiedZero() + elt(2))
8+
@test x isa elt
9+
@test x === elt(2)
10+
end
11+
12+
for x in (elt(2) * UnspecifiedZero(), UnspecifiedZero() * elt(2))
13+
@test x isa UnspecifiedZero
14+
@test x === UnspecifiedZero()
15+
end
16+
end

0 commit comments

Comments
 (0)