Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Adjust conformance tests to account for array invariant #1289

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions tests/conformance/basic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -726,16 +726,15 @@ assert((function()
return sum
end)() == 15)

-- the reason why this test is interesting is that the table created here has arraysize=0 and a single hash element with key = 1.0
-- ipairs must iterate through that
-- ipairs will not iterate through hash part
assert((function()
local arr = { [1] = 42 }
local arr = { [1] = 1, [42] = 42, x = 10 }
local sum = 0
for i,v in ipairs(arr) do
sum = sum + v
end
return sum
end)() == 42)
end)() == 1)

-- the reason why this test is interesting is it ensures we do correct mutability analysis for locals
local function chainTest(n)
Expand Down
4 changes: 2 additions & 2 deletions tests/conformance/tables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ do

assert(table.find({false, true}, true) == 2)

-- make sure table.find checks the hash portion as well by constructing a table literal that forces the value into the hash part
assert(table.find({[(1)] = true}, true) == 1)
-- make sure table.find checks the hash portion as well
assert(table.find({[(2)] = true}, true, 2) == 2)
end

-- test table.concat
Expand Down
Loading