Add luaurc

This commit is contained in:
Ukendio 2024-07-06 23:30:14 +02:00
parent c0e73273d1
commit 60c6177815
4 changed files with 30 additions and 25 deletions

6
.luaurc Normal file
View file

@ -0,0 +1,6 @@
{
"aliases": {
"jecs": "C:/Users/Marcus/Documents/packages/jecs/src",
"testkit": "C:/Users/Marcus/Documents/packages/jecs/testkit"
}
}

View file

@ -7,8 +7,7 @@ local function TITLE(title: string)
print()
print(testkit.color.white(title))
end
local jecs = require("../lib/init")
local jecs = require("../src/init")
local mirror = require("../mirror/init")
type i53 = number
@ -50,8 +49,8 @@ do
world:set(e, G, true)
world:set(e, H, true)
BENCH("Update Data", function()
for _ = 1, 100 do
BENCH("Update Data", function()
for _ = 1, 100 do
world:set(e, A, false)
world:set(e, B, false)
world:set(e, C, false)
@ -166,8 +165,8 @@ do
world:set(e, G, true)
world:set(e, H, true)
BENCH("Update Data", function()
for _ = 1, 100 do
BENCH("Update Data", function()
for _ = 1, 100 do
world:set(e, A, false)
world:set(e, B, false)
world:set(e, C, false)
@ -243,4 +242,4 @@ do
view_bench(ecs, D1, D2, D3, D4, D5, D6, D7, D8)
end
end
end

View file

@ -35,7 +35,7 @@ local color = {
end,
gray = function(s: string): string
return if disable_ansi then s else `\27[30;1m{s}\27[0m`
return if disable_ansi then s else `\27[38;1m{s}\27[0m`
end,
}

View file

@ -1,5 +1,5 @@
local jecs = require("../lib/init")
local testkit = require("../testkit")
local jecs = require("@jecs")
local testkit = require("@testkit")
local __ = jecs.Wildcard
local ECS_ID, ECS_GENERATION = jecs.ECS_ID, jecs.ECS_GENERATION
local ECS_GENERATION_INC = jecs.ECS_GENERATION_INC
@ -35,7 +35,7 @@ TEST("world", function()
local count = 0
for componentId in world:query(jecs.Component) do
if componentId ~= A and componentId ~= B then
if componentId ~= A and componentId ~= B then
error("found entity")
end
count += 1
@ -44,7 +44,7 @@ TEST("world", function()
CHECK(count == 2)
end
do CASE("should remove its components")
do CASE("should remove its components")
local world = jecs.World.new() :: World
local A = world:component()
local B = world:component()
@ -63,7 +63,7 @@ TEST("world", function()
end
do CASE("iterator should not drain the query")
do CASE("iterator should not drain the query")
local world = jecs.World.new() :: World
local A = world:component()
local B = world:component()
@ -73,22 +73,22 @@ TEST("world", function()
world:set(eB, B, true)
local eAB = world:entity()
world:set(eAB, A, true)
world:set(eAB, B, true)
world:set(eAB, B, true)
local q = world:query(A)
local i = 0
local j = 0
for _ in q do
for _ in q do
i+=1
end
for _ in q do
for _ in q do
j+=1
end
CHECK(i == j)
end
do CASE("should be able to get next results")
do CASE("should be able to get next results")
local world = jecs.World.new() :: World
world:component()
local A = world:component()
@ -99,12 +99,12 @@ TEST("world", function()
world:set(eB, B, true)
local eAB = world:entity()
world:set(eAB, A, true)
world:set(eAB, B, true)
world:set(eAB, B, true)
local q = world:query(A)
local e, data = q:next()
while e do
while e do
CHECK(
if e == eA then data == true
elseif e == eAB then data == true
@ -389,15 +389,15 @@ TEST("world", function()
CHECK(count == 2)
end
do CASE "should be able to add/remove matching entity during iteration"
do CASE "should be able to add/remove matching entity during iteration"
local world = jecs.World.new()
local Name = world:component()
for i = 1, 5 do
for i = 1, 5 do
local e = world:entity()
world:set(e, Name, tostring(e))
end
local count = 0
for id, name in world:query(Name) do
for id, name in world:query(Name) do
count += 1
CHECK(id == tonumber(name))
@ -407,7 +407,7 @@ TEST("world", function()
end
CHECK(count == 5)
end
do CASE "should allow adding a matching entity during iteration"
local world = jecs.World.new()
local A = world:component()
@ -420,7 +420,7 @@ TEST("world", function()
world:add(e2, B)
local count = 0
for id in world:query(A) do
for id in world:query(A) do
local e = world:entity()
world:add(e, A)
world:add(e, B)
@ -443,7 +443,7 @@ TEST("world", function()
world:add(e2, B)
local count = 0
for id in world:query(A) do
for id in world:query(A) do
world:add(id, B)
count += 1