comparison test/callback_suite/mk-cases.lua @ 514:01f928eb9584

- more test code generator code sharing
author Tassilo Philipp
date Sun, 10 Apr 2022 16:18:28 +0200
parents 95f6f43178ed
children 1a813b706de4
comparison
equal deleted inserted replaced
513:95f6f43178ed 514:01f928eb9584
1 require "config" 1 require "config"
2 2
3 function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end 3 -- use shared helpers to generate cases
4 package.path = '../common/?.lua;' .. package.path
5 require"mk-cases"
6
7
4 function mkcase(id,sig) 8 function mkcase(id,sig)
9 local sig = trim(sig)
5 local rtype = string.sub(sig, -1) 10 local rtype = string.sub(sig, -1)
6 local i = 1 11 local i = 1
7 local args = { rtype } 12 local args = { rtype }
8 while i < #sig do 13 while i < #sig do
9 c = string.sub(sig, i, i) 14 c = string.sub(sig, i, i)
17 end 22 end
18 i = i + 1 23 i = i + 1
19 end 24 end
20 return "F" .. (#args-1) .. "(f" .. id .. "," .. table.concat(args,',') .. ")\n" 25 return "F" .. (#args-1) .. "(f" .. id .. "," .. table.concat(args,',') .. ")\n"
21 end 26 end
22
23 -- use shared helpers to generate cases
24 package.path = '../common/?.lua;' .. package.path
25 require"mk-cases"
26
27 27
28 function mkall() 28 function mkall()
29 -- force minargs for ordered mode 29 -- force minargs for ordered mode
30 if mode == "ordered" then 30 if mode == "ordered" then
31 minargs = 0 31 minargs = 0