Skip to content

Commit 678750e

Browse files
committed
Allow to instantiate InventoryItem with priority of any Integer type
This is a further fix to ensure DocInventories runs well on 32-bit systems.
1 parent 7dd3a41 commit 678750e

5 files changed

Lines changed: 18 additions & 4 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 = "DocInventories"
22
uuid = "43dc2714-ed3b-44b5-b226-857eda1aa7de"
33
authors = ["Michael Goerz <mail@michaelgoerz.net>"]
4-
version = "0.3.1"
4+
version = "0.3.1+dev"
55

66
[deps]
77
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"

src/inventory.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ end
146146
Base.length(inventory::Inventory) = length(inventory._items)
147147
Base.iterate(inventory::Inventory) = iterate(inventory._items)
148148
Base.iterate(inventory::Inventory, state) = iterate(inventory._items, state)
149-
Base.getindex(inventory::Inventory, ind::Int64) = getindex(inventory._items, ind)
149+
Base.getindex(inventory::Inventory, ind::Int) = getindex(inventory._items, ind)
150150
Base.firstindex(inventory::Inventory) = firstindex(inventory._items)
151151
Base.lastindex(inventory::Inventory) = lastindex(inventory._items)
152152
Base.eltype(::Inventory) = InventoryItem

src/inventory_item.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct InventoryItem
105105
name::AbstractString,
106106
domain::AbstractString,
107107
role::AbstractString,
108-
priority::Int,
108+
priority::Integer,
109109
uri::AbstractString,
110110
dispname::AbstractString
111111
)

src/sphinx_format.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function read_inventory(
150150
name=m["name"],
151151
domain=m["domain"],
152152
role=m["role"],
153-
priority=parse(Int64, m["priority"]),
153+
priority=parse(Int, m["priority"]),
154154
uri=m["uri"],
155155
dispname=m["dispname"],
156156
)

test/test_inventory_item.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ using IOCapture: IOCapture
9090
end
9191

9292

93+
@testset "IventoryItem on 32-bit" begin
94+
item = InventoryItem("f" => "#f"; priority=Int32(1))
95+
@test item.priority == 1
96+
item = InventoryItem("f" => "#f"; priority=Int64(1))
97+
@test item.priority == 1
98+
item = InventoryItem("f" => "#f"; priority=UInt8(1))
99+
@test item.priority == 1
100+
item = InventoryItem("f" => "#f"; priority=Int8(1))
101+
@test item.priority == 1
102+
item = InventoryItem("f" => "#f"; priority=1)
103+
@test item.priority == 1
104+
end
105+
106+
93107
@testset "invalid IventoryItem" begin
94108
@test_throws ArgumentError begin
95109
InventoryItem(

0 commit comments

Comments
 (0)