Lua snake_case -> camelCase naming in tests

This commit is contained in:
Zef Hemel
2026-02-12 17:32:28 +01:00
parent 4979ac1907
commit 8592b3add6
11 changed files with 1118 additions and 1123 deletions
+19 -19
View File
@@ -1,18 +1,18 @@
local function assert_eq(actual, expected, msg)
local function assertEquals(actual, expected, msg)
if actual ~= expected then
error('assert_eq failed: ' .. msg)
error('assertEquals failed: ' .. msg)
end
end
local function assert_true(cond, msg)
local function assertTrue(cond, msg)
if not cond then
error('assert_true failed: ' .. msg)
error('assertTrue failed: ' .. msg)
end
end
local function assert_false(cond, msg)
local function assertFalse(cond, msg)
if cond then
error('assert_false failed: ' .. msg)
error('assertFalse failed: ' .. msg)
end
end
@@ -21,9 +21,9 @@ end
do
local f, err = load("return 40 + 2")
assert_eq(type(f), "function", "load must return function on success")
assert_eq(err, nil, "load must not return error on success")
assert_eq(f(), 42, "loaded chunk executes and returns")
assertEquals(type(f), "function", "load must return function on success")
assertEquals(err, nil, "load must not return error on success")
assertEquals(f(), 42, "loaded chunk executes and returns")
end
-- 2. No explicit return -> nil on call
@@ -31,9 +31,9 @@ end
do
local f, err = load("local x = 1; x = x + 1")
assert_eq(type(f), "function", "load returns function even without returns")
assert_eq(err, nil, "no error expected")
assert_eq(f(), nil, "chunk without return yields nil")
assertEquals(type(f), "function", "load returns function even without returns")
assertEquals(err, nil, "no error expected")
assertEquals(f(), nil, "chunk without return yields nil")
end
-- 3. Syntax error -> (nil, "error message"), no throw on load
@@ -41,8 +41,8 @@ end
do
local f, err = load("return 1 +")
assert_eq(f, nil, "syntax error: first result is nil")
assert_eq(type(err), "string", "syntax error: second result is error string")
assertEquals(f, nil, "syntax error: first result is nil")
assertEquals(type(err), "string", "syntax error: second result is error string")
end
-- 4. Runtime error when calling the returned function
@@ -51,8 +51,8 @@ do
local f = load("return 1 + {}") -- arithmetic on non-number at runtime
local ok, res = pcall(f)
assert_false(ok, "pcall must be false on runtime error")
assert_eq(type(res), "string", "pcall error message is string")
assertFalse(ok, "pcall must be false on runtime error")
assertEquals(type(res), "string", "pcall error message is string")
end
-- 5. Global reads are visible in loaded chunk
@@ -61,7 +61,7 @@ do
g = 41
local f = load("return g + 1")
assert_eq(f(), 42, "loaded chunk sees global env (read)")
assertEquals(f(), 42, "loaded chunk sees global env (read)")
end
-- 6. Global writes from loaded chunk update globals
@@ -69,6 +69,6 @@ do
h = 0
local f = load("h = 9")
assert_eq(f(), nil, "no explicit return")
assert_eq(h, 9, "global updated by loaded chunk (write)")
assertEquals(f(), nil, "no explicit return")
assertEquals(h, 9, "global updated by loaded chunk (write)")
end