Skip to content

Commit

Permalink
Amend test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Jul 26, 2024
1 parent 059a3f9 commit 1844b0c
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions test/tests.luau
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ local N = 10
type World = jecs.WorldShim

TEST("world", function()
do CASE "should not error when removing a component that entity doesn't have"
local world = jecs.World.new() :: World
local A = world:component()
local e = world:entity()
world:remove(e, A)
CHECK(true)
end
do CASE "should allow remove a component that doesn't exist on entity"
local world = jecs.World.new()

local Health = world:entity()
local Poison = world:component()

local id = world:entity()
do
world:remove(id, Poison)
CHECK(true) -- Didn't error
end

world:set(id, Health, 50)
world:remove(id, Poison)

CHECK(world:get(id, Poison) == nil)
CHECK(world:get(id, Health) == 50)
end
do CASE("should find every component id")
local world = jecs.World.new() :: World
local A = world:component()
Expand Down Expand Up @@ -231,20 +242,6 @@ TEST("world", function()
CHECK(world:get(id1, Health) == 50)
end

do CASE("should allow remove that doesn't exist on entity")
local world = jecs.World.new()

local Health = world:entity()
local Poison = world:component()

local id = world:entity()
world:set(id, Health, 50)
world:remove(id, Poison)

CHECK(world:get(id, Poison) == nil)
CHECK(world:get(id, Health) == 50)
end

do CASE("should increment generation")
local world = jecs.World.new()
local e = world:entity()
Expand Down

0 comments on commit 1844b0c

Please sign in to comment.