Skip to content

Commit

Permalink
Use documented ItemStack constructor for tests (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
S-S-X authored Jan 15, 2024
1 parent b27eb0c commit ebe381c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion technic/spec/hv_network_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("HV machine network", function()
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:room_for_item(listname or "src", itemstack) then
inv:set_stack(listname or "src", 1, ItemStack())
inv:set_stack(listname or "src", 1, ItemStack(nil))
end
inv:add_item(listname or "src", itemstack)
end
Expand Down
2 changes: 1 addition & 1 deletion technic/spec/lv_network_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("LV machine network", function()
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:room_for_item(listname or "src", itemstack) then
inv:set_stack(listname or "src", 1, ItemStack())
inv:set_stack(listname or "src", 1, ItemStack(nil))
end
inv:add_item(listname or "src", itemstack)
end
Expand Down
4 changes: 2 additions & 2 deletions technic/spec/tools_compatibility_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ describe("Technic power tool compatibility", function()
end)

before_each(function()
set_charge_stack(ItemStack())
set_discharge_stack(ItemStack())
set_charge_stack(ItemStack(nil))
set_discharge_stack(ItemStack(nil))
end)

it("is registered", function()
Expand Down
20 changes: 10 additions & 10 deletions technic/spec/tools_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ describe("Technic power tool", function()
describe("API", function()

setup(function()
set_charge_stack(ItemStack())
set_discharge_stack(ItemStack())
set_charge_stack(ItemStack(nil))
set_discharge_stack(ItemStack(nil))
mineunit:set_current_modname("mymod")
mineunit:execute_on_joinplayer(player)
end)
Expand Down Expand Up @@ -149,8 +149,8 @@ describe("Technic power tool", function()
end

setup(function()
set_charge_stack(ItemStack())
set_discharge_stack(ItemStack())
set_charge_stack(ItemStack(nil))
set_discharge_stack(ItemStack(nil))
mineunit:set_current_modname("mymod")
register_test_tool("t1_1", 1, 1)
register_test_tool("t1_2", 1, 2)
Expand Down Expand Up @@ -263,8 +263,8 @@ describe("Technic power tool", function()
local itemdef = minetest.registered_items[itemname]

setup(function()
set_charge_stack(ItemStack())
set_discharge_stack(ItemStack())
set_charge_stack(ItemStack(nil))
set_discharge_stack(ItemStack(nil))
mineunit:execute_on_joinplayer(player)
end)

Expand Down Expand Up @@ -308,8 +308,8 @@ describe("Technic power tool", function()
local itemdef = minetest.registered_items[itemname]

setup(function()
set_charge_stack(ItemStack())
set_discharge_stack(ItemStack())
set_charge_stack(ItemStack(nil))
set_discharge_stack(ItemStack(nil))
mineunit:execute_on_joinplayer(player)
player:get_inventory():set_stack("main", 1, itemname)
end)
Expand Down Expand Up @@ -401,8 +401,8 @@ describe("Technic power tool", function()
-- Some wood for chainsaw
{{{x=-10,y=0,z=-10},{x=10,y=10,z=10}}, "default:wood"},
})
set_charge_stack(ItemStack())
set_discharge_stack(ItemStack())
set_charge_stack(ItemStack(nil))
set_discharge_stack(ItemStack(nil))
mineunit:execute_on_joinplayer(player)
set_player_stack(itemname)
end)
Expand Down
4 changes: 2 additions & 2 deletions technic_cnc/spec/api_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("CNC API", function()
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
inventory:set_stack("src", 1, "default:stone 42")
inventory:set_stack("dst", 1, ItemStack())
inventory:set_stack("dst", 1, ItemStack(nil))
local materialstack = inventory:get_stack("src", 1)

-- Test CNC cutting process
Expand All @@ -82,7 +82,7 @@ describe("CNC API", function()
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
inventory:set_stack("src", 1, "default:badstone 42")
inventory:set_stack("dst", 1, ItemStack())
inventory:set_stack("dst", 1, ItemStack(nil))
local materialstack = inventory:get_stack("src", 1)

-- Test CNC cutting process
Expand Down
4 changes: 2 additions & 2 deletions technic_cnc/spec/technic_cnc_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Technic CNC", function()
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:room_for_item(listname or "src", itemstack) then
inv:set_stack(listname or "src", 1, ItemStack())
inv:set_stack(listname or "src", 1, ItemStack(nil))
end
inv:add_item(listname or "src", itemstack)
end
Expand All @@ -48,7 +48,7 @@ describe("Technic CNC", function()
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for index=1, inv:get_size(listname or "dst") do
inv:set_stack(listname or "dst", index, ItemStack())
inv:set_stack(listname or "dst", index, ItemStack(nil))
end
end

Expand Down

0 comments on commit ebe381c

Please sign in to comment.