diff test/common/mk-cases.lua @ 519:99819b874bac

test/call_suite_aggrs: - refactored generator code a bit to be simpler, write cleaner output, have better shareability and clarity - added rtypes w/ default value nil to config.lua, to self document - shared some code under test/common/ - fixed nonemptyaggrs sigs and cases.h (accidentally overwritten with cases having empty aggrs)
author Tassilo Philipp
date Mon, 11 Apr 2022 22:26:07 +0200
parents 01f928eb9584
children a2de1d0a73f3
line wrap: on
line diff
--- a/test/common/mk-cases.lua	Mon Apr 11 15:06:44 2022 +0200
+++ b/test/common/mk-cases.lua	Mon Apr 11 22:26:07 2022 +0200
@@ -2,6 +2,18 @@
   return s:gsub("^%s+",""):gsub("%s+$","")
 end
 
+-- parse array notation, e.g. returns "a", 4 for "a[4]"
+function split_array_decl(s)
+  local name = s
+  local n = nil  -- not an array
+  local i = s:find('%[')
+  if i ~= nil then
+    name = name:sub(1, i-1)
+    n = tonumber(s:sub(i):match('[0123456789]+'))
+  end
+  return name, n
+end
+
 function mkfuntab(n, prefix, t, array_name, with_cast)
   local s = { t.." "..array_name.."[] = {\n"}
   local cast = ''