[Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua>

Sergey Kaplun skaplun at tarantool.org
Mon Jan 29 13:45:11 MSK 2024


This patch declares functions as local to avoid pollution of the global
environment. It separates the body of the test in the `do` `while` block
and includes the test in <index>.

Part of tarantool/tarantool#9398
---
 .../lib/ffi/ffi_gcstep_recursive.lua          | 27 ++++++++++---------
 test/LuaJIT-tests/lib/ffi/index               |  1 +
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
index cb19df11..f6e0b009 100644
--- a/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
+++ b/test/LuaJIT-tests/lib/ffi/ffi_gcstep_recursive.lua
@@ -1,6 +1,6 @@
 -- From Robert G. Jakabosky, 2012-03-20
 
-local N=tonumber(arg[1] or 10000)
+local N= 10000
 
 local ffi=require"ffi"
 
@@ -19,7 +19,7 @@ local function obj_to_id(ptr)
   return tonumber(ffi.cast('uintptr_t', ffi.cast('void *', ptr)))
 end
 
-function obj_type_Buffer_push(val)
+local function obj_type_Buffer_push(val)
   local obj = Buffer(val)
   local id = obj_to_id(obj)
   nobj_obj_flags[id] = true
@@ -31,7 +31,7 @@ local function Buffer_new(len)
   return obj_type_Buffer_push(buf)
 end
 
-function obj_type_Buffer_delete(obj)
+local function obj_type_Buffer_delete(obj)
   local id = obj_to_id(obj)
   if not nobj_obj_flags[id] then return nil end
   nobj_obj_flags[id] = nil
@@ -52,15 +52,16 @@ Buffer_mt.__index.close = Buffer_close
 
 ffi.metatype(Buffer, Buffer_mt)
 
-local cdata = {}
-for x=1,2 do
-  cdata = {}
-  for i=1,N do
-    cdata[i] = Buffer_new(1)
+do --- buffer test
+  local cdata = {}
+  for x=1,2 do
+    cdata = {}
+    for i=1,N do
+      cdata[i] = Buffer_new(1)
+    end
+    for i=1,N do
+      cdata[i]:close()
+    end
+    cdata = nil
   end
-  for i=1,N do
-    cdata[i]:close()
-  end
-  cdata = nil
 end
-
diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
index b11e5aa4..8236ab98 100644
--- a/test/LuaJIT-tests/lib/ffi/index
+++ b/test/LuaJIT-tests/lib/ffi/index
@@ -9,6 +9,7 @@ ffi_callback.lua
 ffi_const.lua
 ffi_convert.lua
 ffi_enum.lua
+ffi_gcstep_recursive.lua
 istype.lua
 jit_array.lua
 jit_complex.lua
-- 
2.43.0



More information about the Tarantool-patches mailing list