Lua: fix some subtle Lua-isms

This commit is contained in:
Zef Hemel
2025-03-09 15:37:38 +01:00
parent 29c2781c11
commit 242ae73078
9 changed files with 737 additions and 34 deletions
+12
View File
@@ -52,8 +52,20 @@ function multi_return()
return 1, 2
end
function addAll(...)
local total = 0
for i, v in ipairs({ ... }) do
total = total + v
end
return total
end
local a, b = multi_return()
assert(a == 1 and b == 2)
assert(addAll(1, 2, 3) == 6)
-- Test multiple return values in expressions
assertEqual(addAll(multi_return()), 3)
assertEqual(#{multi_return()}, 2)
local a, b, c = 0, multi_return()
assert(a == 0 and b == 1 and c == 2)