aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAlex Pickering <alex@cogarr.net>2026-02-01 13:14:32 -0600
committerAlexander M Pickering <alex@cogarr.net>2026-02-01 13:14:32 -0600
commit3a975db66a3711f34e8b64bb27a8eaca79fdeca9 (patch)
treefcc12f8f9d638ff575c1963796de76b7628854b4 /spec
downloadggj26-3a975db66a3711f34e8b64bb27a8eaca79fdeca9.tar.gz
ggj26-3a975db66a3711f34e8b64bb27a8eaca79fdeca9.tar.bz2
ggj26-3a975db66a3711f34e8b64bb27a8eaca79fdeca9.zip
Initial commitHEADmaster
Diffstat (limited to 'spec')
-rw-r--r--spec/ecs_spec.lua12
-rw-r--r--spec/log_spec.lua53
2 files changed, 65 insertions, 0 deletions
diff --git a/spec/ecs_spec.lua b/spec/ecs_spec.lua
new file mode 100644
index 0000000..d757a0c
--- /dev/null
+++ b/spec/ecs_spec.lua
@@ -0,0 +1,12 @@
+
+describe("ecs module", function()
+ it("should require without errors",function()
+ require("ecs")
+ end)
+ it("should serialize correctly",function()
+ local ecs = require("ecs")
+ ent = ecs.Entity(nil,{
+
+ })
+ end)
+end)
diff --git a/spec/log_spec.lua b/spec/log_spec.lua
new file mode 100644
index 0000000..2120c17
--- /dev/null
+++ b/spec/log_spec.lua
@@ -0,0 +1,53 @@
+describe("log module", function()
+ before_each(function()
+ local succ, log= pcall(require,"log")
+ if succ then log.reset() end
+ end)
+ it("should load",function()
+ require("log")
+ end)
+ it("should ingest a log",function()
+ local log = require("log")
+ log.log("test",nil,"blah")
+ end)
+ it("should return ingested logs from levels",function()
+ local log = require("log")
+ local ret = {}
+ log.log("test",nil,"blah")
+ log.of_level("blah",function(msg)
+ table.insert(ret, msg)
+ end)
+ assert(#ret == 1)
+ assert(ret[1].message == "test")
+ end)
+ it("should return ingested logs from tags", function()
+ local log = require("log")
+ local ret = {}
+ log.info("one",{"one"})
+ log.info("two",{"two"})
+ log.info("one two",{"one","two"})
+ log.of_tags({"one"},function(msg)
+ table.insert(ret,msg)
+ end)
+ assert(#ret == 2)
+ assert(ret[1].message == "one")
+ assert(ret[2].message == "one two")
+ end)
+ it("should allow observers to see the message stream", function()
+ local log = require("log")
+ local ret = {}
+ log.listen(function(chunk)
+ if chunk.level == "panic" then
+ table.insert(ret,chunk)
+ end
+ end)
+ log.info("one")
+ log.info("two")
+ assert(#ret == 0)
+ log.panic("three")
+ assert(#ret == 1)
+ log.info("four")
+ assert(#ret == 1)
+ assert(ret[1].message == "three")
+ end)
+end)