Address final review nits on the assertions

- Suite.empty(value, name) checks a table has no entries and reports what it
  held, and Suite.throws(fn, message, name) asserts a function errors with the
  given message, so an unrelated error no longer passes as the expected one.
- Scalar comparisons and zero length checks go through eq and empty, and the
  announced messages and print output are compared by content, so a failure
  shows the actual data.
- get_roles() is asserted through sorted names rather than a count.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-26 10:48:43 +00:00
co-authored by Claude Fable 5
parent 3218351db6
commit 574a0a4b52
6 changed files with 73 additions and 35 deletions
+20
View File
@@ -91,6 +91,26 @@ function Framework.suite(extend_env)
Suite.check(deep_equal(a, b), name, ("%s ~= %s"):format(repr(a, 1), repr(b, 1)))
end
--- Check a table has no entries
function Suite.empty(value, name)
Suite.check(next(value) == nil, name, repr(value, 1))
end
--- Check a function raises an error containing the message
--- @param fn fun()
--- @param message string
--- @param name string
function Suite.throws(fn, message, name)
local ok, err = pcall(fn)
if ok then
Suite.fail(name, "did not error")
elseif not tostring(err):find(message, 1, true) then
Suite.fail(name, ("%s does not contain %s"):format(tostring(err), message))
else
Suite.pass(name)
end
end
--- Names of an array of values with a name property, such as roles,
--- players, forces, or events
--- @param values { name: string }[]