aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.lua
diff options
context:
space:
mode:
authorame <[email protected]>2025-09-02 22:41:16 -0500
committerame <[email protected]>2025-09-02 22:41:16 -0500
commitaca474d31ede34347e776504b5a4228800d0e3a8 (patch)
treeec208c4df6f9334d7b20ffa18c4d6c3e84216306 /tests/tests.lua
parent2ac674735ba38c655be4f2e473b82974c76cf8c9 (diff)
better tests
Diffstat (limited to 'tests/tests.lua')
-rw-r--r--tests/tests.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/tests.lua b/tests/tests.lua
new file mode 100644
index 0000000..b4110d4
--- /dev/null
+++ b/tests/tests.lua
@@ -0,0 +1,44 @@
+llby = require("lullaby")
+
+local failed = {}
+local total = 0
+
+function yay(M)
+ print(string.format("\27[32m%s\27[0m passed", M))
+end
+
+function nay(M)
+ print(string.format("\27[31m%s\27[0m failed", M))
+end
+
+local search = ""
+if arg[1] ~= nil then
+ search = "*" .. arg[1] .. "*"
+end
+
+local handle = assert(io.popen("find tests/units/".. search .." -type f"))
+
+for file in handle:lines() do
+ total = total + 1
+ local f = loadfile(file)()
+
+ if f == true then
+ yay(file)
+ else
+ nay(file)
+ table.insert(failed, file)
+ end
+end
+
+if #failed > 0 then
+ print("\n--- failed units (".. #failed .."/".. total ..") ---")
+ for _,fail in ipairs(failed) do
+ nay(fail)
+ end
+ print("--- failed units (".. #failed .."/".. total ..") ---")
+else
+ print("passed all (".. total ..")")
+end
+
+handle:close()
+