mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-11-04 02:49:18 +00:00 
			
		
		
		
	Amend test
This commit is contained in:
		
							parent
							
								
									059a3f9bed
								
							
						
					
					
						commit
						1844b0cfd8
					
				
					 1 changed files with 18 additions and 21 deletions
				
			
		| 
						 | 
					@ -25,13 +25,24 @@ local N = 10
 | 
				
			||||||
type World = jecs.WorldShim
 | 
					type World = jecs.WorldShim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST("world", function()
 | 
					TEST("world", function()
 | 
				
			||||||
    do CASE "should not error when removing a component that entity doesn't have"
 | 
					    do CASE "should allow remove a component that doesn't exist on entity"
 | 
				
			||||||
        local world = jecs.World.new() :: World
 | 
							local world = jecs.World.new()
 | 
				
			||||||
		local A = world:component()
 | 
					
 | 
				
			||||||
		local e = world:entity()
 | 
							local Health = world:entity()
 | 
				
			||||||
		world:remove(e, A)
 | 
							local Poison = world:component()
 | 
				
			||||||
		CHECK(true)
 | 
					
 | 
				
			||||||
    end
 | 
							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")
 | 
						do CASE("should find every component id")
 | 
				
			||||||
		local world = jecs.World.new() :: World
 | 
							local world = jecs.World.new() :: World
 | 
				
			||||||
		local A = world:component()
 | 
							local A = world:component()
 | 
				
			||||||
| 
						 | 
					@ -231,20 +242,6 @@ TEST("world", function()
 | 
				
			||||||
		CHECK(world:get(id1, Health) == 50)
 | 
							CHECK(world:get(id1, Health) == 50)
 | 
				
			||||||
	end
 | 
						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")
 | 
						do CASE("should increment generation")
 | 
				
			||||||
		local world = jecs.World.new()
 | 
							local world = jecs.World.new()
 | 
				
			||||||
		local e = world:entity()
 | 
							local e = world:entity()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue