changeset 514:01f928eb9584

- more test code generator code sharing
author Tassilo Philipp
date Sun, 10 Apr 2022 16:18:28 +0200
parents 95f6f43178ed
children c9c546f8598b
files test/call_suite/mk-cases.lua test/call_suite_aggrs/mk-cases.lua test/callback_suite/mk-cases.lua test/common/mk-cases.lua
diffstat 4 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/test/call_suite/mk-cases.lua	Sun Apr 10 16:10:10 2022 +0200
+++ b/test/call_suite/mk-cases.lua	Sun Apr 10 16:18:28 2022 +0200
@@ -1,8 +1,13 @@
 require"math"
+
+-- use shared helpers to generate cases
+package.path = '../common/?.lua;' .. package.path
+require"mk-cases"
+
+
 local max = math.max
 local maxargs = 0
 
-function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end
 function mkcase(id,sig)
   local sig = trim(sig)
   local h = { "/* ",id,":",sig," */ ",sig:sub(-1), " f", id,"(","" }
@@ -22,11 +27,6 @@
   return table.concat(h,"")..table.concat(t,"")
 end
 
--- use shared helpers to generate cases
-package.path = '../common/?.lua;' .. package.path
-require"mk-cases"
-
-
 function mkall()
   local lineno = 0
   local sigtab = { }
--- a/test/call_suite_aggrs/mk-cases.lua	Sun Apr 10 16:10:10 2022 +0200
+++ b/test/call_suite_aggrs/mk-cases.lua	Sun Apr 10 16:18:28 2022 +0200
@@ -1,5 +1,11 @@
 require"config"
 require"math"
+
+-- use shared helpers to generate cases
+package.path = '../common/?.lua;' .. package.path
+require"mk-cases"
+
+
 local max_numargs = 0
 
 local aggrs = { }
@@ -20,7 +26,6 @@
 end
 
 
-function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end
 function mkcase(id,sig)
   local sig = trim(sig)
   local fsig = put_sig_rtype_first(sig)
@@ -110,11 +115,6 @@
   return table.concat(h,"")..table.concat(t,"")
 end
 
--- use shared helpers to generate cases
-package.path = '../common/?.lua;' .. package.path
-require"mk-cases"
-
-
 function split_array_decl(s)
   local name = s
   local n = nil  -- not an array
--- a/test/callback_suite/mk-cases.lua	Sun Apr 10 16:10:10 2022 +0200
+++ b/test/callback_suite/mk-cases.lua	Sun Apr 10 16:18:28 2022 +0200
@@ -1,7 +1,12 @@
 require "config"
 
-function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end
+-- use shared helpers to generate cases
+package.path = '../common/?.lua;' .. package.path
+require"mk-cases"
+
+
 function mkcase(id,sig)
+  local sig = trim(sig)
   local rtype = string.sub(sig, -1)
   local i = 1
   local args = { rtype }
@@ -20,11 +25,6 @@
   return "F" .. (#args-1) .. "(f" .. id .. "," .. table.concat(args,',') .. ")\n"
 end
 
--- use shared helpers to generate cases
-package.path = '../common/?.lua;' .. package.path
-require"mk-cases"
-
-
 function mkall()
   -- force minargs for ordered mode
   if mode == "ordered" then
--- a/test/common/mk-cases.lua	Sun Apr 10 16:10:10 2022 +0200
+++ b/test/common/mk-cases.lua	Sun Apr 10 16:18:28 2022 +0200
@@ -1,3 +1,7 @@
+function trim(s)
+  return s:gsub("^%s+",""):gsub("%s+$","")
+end
+
 function mkfuntab(n, prefix, t, array_name, with_cast)
   local s = { t.." "..array_name.."[] = {\n"}
   local cast = ''