Lua: work to make more table APIs work with native JS arrays

This commit is contained in:
Zef Hemel
2025-03-10 17:31:02 +01:00
parent 7ff0d17ba1
commit 1881fa8af9
3 changed files with 86 additions and 25 deletions
+6 -1
View File
@@ -65,7 +65,7 @@ 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)
assertEqual(#{ multi_return() }, 2)
local a, b, c = 0, multi_return()
assert(a == 0 and b == 1 and c == 2)
@@ -393,6 +393,11 @@ local function collect_range(from, to, step)
return values
end
local tblNew = { 1, 2, 3 }
table.insert(tblNew, 4)
assertEqual(#tblNew, 4)
assertEqual(tblNew[4], 4)
local values1 = collect_range(1, 5, 2)
assert(#values1 == 3, "Range with step 2 should return 3 values")
assert(values1[1] == 1 and values1[2] == 3 and values1[3] == 5, "Range values with step 2 should be correct")