comparison test/suite_aggrs/rand-sig.lua @ 438:b4ddad459690

suite_aggr; - made generator produce unique signatures - reduced dcNewStruct() calls to once only per sig - added missing free()s - cleanup: removal of unused decl, func renaming for clarity, static for tu-local symbols, ...
author Tassilo Philipp
date Wed, 26 Jan 2022 13:37:19 +0100
parents 3d2c5d156d78
children 54c1dc2e6ea5
comparison
equal deleted inserted replaced
437:135c7fb49c2f 438:b4ddad459690
1 require"config" 1 require"config"
2 2
3 -- assure aggr chars are present in pairs (can be weighted, though), to avoid 3 -- assure aggr chars are present in pairs (can be weighted, though), to avoid
4 -- inf loops 4 -- inf loops
5 if string.match(types,'{') and not string.match(types,'}') then types = types..'}' end 5 if string.match(types,'{') and not string.match(types,'}') then types = types..'}' end
6 -- @@@ unions, arrays
7 6
8 rtypes = "v"..types 7 rtypes = "v"..types
9 8
10 9
11 function mkstruct(n_nest, maxdepth) 10 function mkstruct(n_nest, maxdepth)
39 end 38 end
40 39
41 40
42 math.randomseed(seed) 41 math.randomseed(seed)
43 local id 42 local id
43 local uniq_sigs = { }
44 for i = 1, ncases do 44 for i = 1, ncases do
45 local nargs = math.random(minargs,maxargs) 45 local nargs = math.random(minargs,maxargs)
46 local l = '' 46 local l = ''
47 repeat 47 repeat
48 id = math.random(#rtypes) 48 id = math.random(#rtypes)
49 local sig = { mktype(rtypes:sub(id,id), 0, math.random(maxaggrdepth)) } -- random depth avoids excessive nesting 49 local sig = { mktype(rtypes:sub(id,id), 0, math.random(maxaggrdepth)) } -- random depth avoids excessive nesting
50 for j = 1, nargs do 50 for j = 1, nargs do
51 id = math.random(#types) 51 id = math.random(#types)
52 sig[#sig+1] = mktype(types:sub(id,id), 0, math.random(maxaggrdepth)) -- random depth avoids excessive nesting 52 sig[#sig+1] = mktype(types:sub(id,id), 0, math.random(maxaggrdepth)) -- random depth avoids excessive nesting
53 end 53 end
54 l = table.concat(sig) 54 l = table.concat(sig)
55 -- reject sigs without any aggregate, as this is about aggrs after all 55 -- reject dupes and sigs without any aggregate, as this is about aggrs after all
56 until string.match(l, '{') ~= nil 56 until string.match(l, '{') ~= nil and uniq_sigs[l] == nil
57 uniq_sigs[l] = 1
57 io.write(l.."\n") 58 io.write(l.."\n")
58 end 59 end
59 60