# HG changeset patch # User Tassilo Philipp # Date 1649600308 -7200 # Node ID 01f928eb95842cbb5c5efa93b0b6967ef2849cdd # Parent 95f6f43178ed1c1e23e549314f4081d804ce4f15 - more test code generator code sharing diff -r 95f6f43178ed -r 01f928eb9584 test/call_suite/mk-cases.lua --- 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 = { } diff -r 95f6f43178ed -r 01f928eb9584 test/call_suite_aggrs/mk-cases.lua --- 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 diff -r 95f6f43178ed -r 01f928eb9584 test/callback_suite/mk-cases.lua --- 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 diff -r 95f6f43178ed -r 01f928eb9584 test/common/mk-cases.lua --- 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 = ''