view test/callback_suite/make-signatures.lua @ 516:1a813b706de4

callback_suite: fixed 'ordered' mode config (was missing first line)
author Tassilo Philipp
date Sun, 10 Apr 2022 22:03:16 +0200
parents 45ac093ca822
children f8856e29b512
line wrap: on
line source

require "config"
require "math"
require "string"


function randomSignatures()
  package.path = '../common/?.lua;' .. package.path
  require"rand-sig"
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
end


function designedSignatures()
 for line in io.lines(designfile) do
   io.write( line )
   io.write( "\n" )
 end
end


if mode == "random" then
  randomSignatures()
elseif mode == "ordered" then
  orderedSignatures()
elseif mode == "designed" then
  designedSignatures()
else
  error("'mode' must be 'random', 'ordered' or 'designed'")
end

io.flush()