Skip to content

Commit 68047ba

Browse files
committed
tests/lapi: add table.clear test
The patcha adds a test for `table.clear()` function that is present in LuaJIT. Follows up the commit ee032e7 ("tests/lapi: add table tests").
1 parent 9b0e24a commit 68047ba

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/lapi/table_clear_test.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--[[
2+
SPDX-License-Identifier: ISC
3+
Copyright (c) 2023-2025, Sergey Bronnikov.
4+
5+
Double-emitting of IR_NEWREF for the same key on the snap replay,
6+
https://github.com/LuaJIT/LuaJIT/issues/1128
7+
8+
X86/X64 load fusion conflict detection doesn't detect table.clear,
9+
https://github.com/LuaJIT/LuaJIT/issues/1117
10+
11+
Problem of HREFK with table.clear,
12+
https://github.com/LuaJIT/LuaJIT/issues/792
13+
14+
Add support for freeing memory manually,
15+
https://github.com/LuaJIT/LuaJIT/issues/620
16+
17+
Synopsis: table.clear(tbl)
18+
]]
19+
20+
local luzer = require("luzer")
21+
local test_lib = require("lib")
22+
23+
if test_lib.lua_version() ~= "LuaJIT" then
24+
print("Unsupported version.")
25+
os.exit(0)
26+
end
27+
28+
local table_clear = require("table.clear")
29+
30+
local function TestOneInput(buf)
31+
local fdp = luzer.FuzzedDataProvider(buf)
32+
local count = fdp:consume_integer(0, test_lib.MAX_INT64)
33+
local tbl = fdp:consume_strings(test_lib.MAX_STR_LEN, count)
34+
table_clear(tbl)
35+
end
36+
37+
local args = {
38+
artifact_prefix = "table_clear_",
39+
}
40+
luzer.Fuzz(TestOneInput, nil, args)

0 commit comments

Comments
 (0)