Mercurial > pub > dyncall > dyncall
annotate test/callback_suite/make-signatures.lua @ 495:45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
author | Tassilo Philipp |
---|---|
date | Mon, 21 Mar 2022 16:50:44 +0100 |
parents | 3e629dc19168 |
children | 1a813b706de4 |
rev | line source |
---|---|
0 | 1 require "config" |
2 require "math" | |
3 require "string" | |
4 | |
5 | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
6 function randomSignatures() |
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
7 package.path = '../common/?.lua;' .. package.path |
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
8 require"rand-sig" |
0 | 9 end |
10 | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
11 |
0 | 12 function orderedSignature(x) |
13 local signature = "" | |
14 local typeindex | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
15 local nargtypes = string.len(types) |
0 | 16 while true do |
17 if x < nargtypes then break end | |
18 typeindex = 1 + math.mod(x, nargtypes) | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
19 signature = signature .. string.sub(types, typeindex, typeindex) |
0 | 20 x = math.floor( x / nargtypes ) |
21 end | |
22 typeindex = 1 + x | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
23 signature = signature .. ")" .. string.sub(types, typeindex, typeindex) |
0 | 24 return signature |
25 end | |
26 | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
27 |
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
28 function orderedSignatures() |
0 | 29 local i |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
30 for i = 1, ncases do |
0 | 31 io.write( orderedSignature(offset+i*step) .. "\n" ) |
32 end | |
33 end | |
34 | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
35 |
0 | 36 function designedSignatures() |
37 for line in io.lines(designfile) do | |
38 io.write( line ) | |
39 io.write( "\n" ) | |
40 end | |
41 end | |
42 | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
43 |
0 | 44 if mode == "random" then |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
45 randomSignatures() |
0 | 46 elseif mode == "ordered" then |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
47 orderedSignatures() |
0 | 48 elseif mode == "designed" then |
49 designedSignatures() | |
50 else | |
495
45ac093ca822
- test/callback_suite: make it use shared random sig generator from call_suite and call_suite_aggrs
Tassilo Philipp
parents:
0
diff
changeset
|
51 error("'mode' must be 'random', 'ordered' or 'designed'") |
0 | 52 end |
53 | |
54 io.flush() | |
55 |