# HG changeset patch # User Tassilo Philipp # Date 1649681435 -7200 # Node ID f8856e29b51215de719df36c3f7e9abc4059be84 # Parent 1a813b706de4e137747ba1bfe6a7a6e0b81cca1c - tests: made "ordered" signature generation code shareable, and added possibility to specify return types, separately (mainly to include 'void') diff -r 1a813b706de4 -r f8856e29b512 test/callback_suite/make-signatures.lua --- a/test/callback_suite/make-signatures.lua Sun Apr 10 22:03:16 2022 +0200 +++ b/test/callback_suite/make-signatures.lua Mon Apr 11 14:50:35 2022 +0200 @@ -9,26 +9,9 @@ end -function orderedSignature(x) - local signature = "" - local typeindex - local nargtypes = #types - while x >= nargtypes do - typeindex = 1 + (x % nargtypes) - signature = signature .. string.sub(types, typeindex, typeindex) - x = math.floor( x / nargtypes ) - end - typeindex = 1 + x - signature = signature .. ")" .. string.sub(types, typeindex, typeindex) - return signature -end - - function orderedSignatures() - local i - for i = 0, ncases-1 do - io.write( orderedSignature(offset+i*step) .. "\n" ) - end + package.path = '../common/?.lua;' .. package.path + require"ordered-sig" end diff -r 1a813b706de4 -r f8856e29b512 test/common/ordered-sig.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/common/ordered-sig.lua Mon Apr 11 14:50:35 2022 +0200 @@ -0,0 +1,39 @@ +-- !does not generates sigs with aggregates! + +-- following knobs control generation: + +-- required to be defined by who is using this: +-- ncases +-- types + +-- optional: +-- rtypes (if not set, it'll be 'v'..types) + + +-------------------------------- + +if rtypes == nil then + rtypes = "v"..types +end + +local i +for i = 0, ncases-1 do + local s = "" + local typeindex + local ntypes = #types + local nrtypes = #rtypes + local x = offset+i*step + if x >= nrtypes then + local y = math.floor(x / nrtypes) - 1 + while y >= ntypes do + typeindex = 1 + (y % ntypes) + s = s .. string.sub(types, typeindex, typeindex) + y = math.floor(y / ntypes) - 1 + end + typeindex = 1 + (y % ntypes) + s = s .. string.sub(types, typeindex, typeindex) + end + typeindex = 1 + (x % nrtypes) + io.write(s .. ")" .. string.sub(rtypes, typeindex, typeindex) .. "\n") +end +