summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua44
1 files changed, 7 insertions, 37 deletions
diff --git a/tests/run.lua b/tests/run.lua
index 03aa725..131086f 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -28,6 +28,13 @@ local text_topology = require("clever_f.text_topology")
local target_plan = require("clever_f.target_plan")
local MemoryHost = require("clever_f.testing.memory_host")
+local assertions = dofile(root .. "/tests/assertions.lua")
+local same = assertions.same
+local truthy = assertions.truthy
+local falsy = assertions.falsy
+local fails = assertions.fails
+local list_same = assertions.list_same
+
local tests = {}
local passed = 0
@@ -35,43 +42,6 @@ local function test(name, body)
tests[#tests + 1] = { name = name, body = body }
end
-local function same(expected, actual, message)
- if expected ~= actual then
- error((message or "values differ")
- .. ": expected " .. tostring(expected)
- .. ", got " .. tostring(actual), 2)
- end
-end
-
-local function truthy(value, message)
- if not value then
- error(message or "value must be true", 2)
- end
-end
-
-local function falsy(value, message)
- if value then
- error(message or "value must be false", 2)
- end
-end
-
-local function fails(body, expected_text)
- local ok, failure = pcall(body)
- if ok then
- error("operation must fail", 2)
- end
- if expected_text and not tostring(failure):find(expected_text, 1, true) then
- error("failure does not contain '" .. expected_text .. "': " .. tostring(failure), 2)
- end
-end
-
-local function list_same(expected, actual)
- same(#expected, #actual, "list lengths differ")
- for index = 1, #expected do
- same(expected[index], actual[index], "list item " .. tostring(index) .. " differs")
- end
-end
-
test("Position validates one-based byte coordinates", function()
local position = domain.Position.new(1, 1)
same(1, position.line)