diff test/suite_aggrs/rand-sig.lua @ 462:653b65580cb4

suite_aggr: - added arrays (inside of structs/unions, only, as only way to pass/return them by value) - cleanups and pregen of source
author Tassilo Philipp
date Tue, 01 Feb 2022 21:44:18 +0100
parents 236015fdf7a8
children bd8f5da2c74b
line wrap: on
line diff
--- a/test/suite_aggrs/rand-sig.lua	Mon Jan 31 14:41:11 2022 +0100
+++ b/test/suite_aggrs/rand-sig.lua	Tue Feb 01 21:44:18 2022 +0100
@@ -6,6 +6,8 @@
 pairs_op = { '{', '<' } --, '[' }
 pairs_cl = { '}', '>' } --, ']' }
 
+aggr_op_pattern = '[%'..table.concat(pairs_op,'%')..']'
+
 for i = 1, #pairs_op do
   if string.find(types, '%'..pairs_op[i]) and not string.find(types, '%'..pairs_cl[i]) then
     types = types..pairs_cl[i]
@@ -21,6 +23,11 @@
     local id = math.random(#types)
     local t = types:sub(id,id)
     s = s..mktype(t, n_nest, maxdepth, o)
+
+    -- member (which cannot be first char) as array? Disallow multidimensional arrays
+    if #s > 1 and t ~= c and s:sub(-1) ~= ']' and math.random(arraydice) == 1 then
+      s = s..'['..math.random(maxarraylen)..']'
+    end
   until t == c
 
   return s
@@ -73,7 +80,6 @@
 math.randomseed(seed)
 local id
 local uniq_sigs = { }
-local aggr_op_pattern = '[%'..table.concat(pairs_op,'%')..']'
 for i = 1, ncases do
   local l = ''
   repeat