rufus-lua-win 5.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (459) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +69 -0
  6. data/Rakefile +1 -0
  7. data/lib/rufus/lua/win.rb +18 -0
  8. data/lib/rufus/lua/win/version.rb +7 -0
  9. data/rufus-lua-win.gemspec +23 -0
  10. data/vendor/lua/bin/liblua.dll +0 -0
  11. data/vendor/lua/lib/lua/LuaXml.lua +119 -0
  12. data/vendor/lua/lib/lua/alien.lua +250 -0
  13. data/vendor/lua/lib/lua/alien/core.dll +0 -0
  14. data/vendor/lua/lib/lua/alien/struct.dll +0 -0
  15. data/vendor/lua/lib/lua/base.lua +536 -0
  16. data/vendor/lua/lib/lua/bin.lua +20 -0
  17. data/vendor/lua/lib/lua/bit.dll +0 -0
  18. data/vendor/lua/lib/lua/cdlua.dll +0 -0
  19. data/vendor/lua/lib/lua/cdluacontextplus.dll +0 -0
  20. data/vendor/lua/lib/lua/cdluagl.dll +0 -0
  21. data/vendor/lua/lib/lua/cdluaim.dll +0 -0
  22. data/vendor/lua/lib/lua/cdluapdf.dll +0 -0
  23. data/vendor/lua/lib/lua/copas.lua +543 -0
  24. data/vendor/lua/lib/lua/coxpcall.lua +57 -0
  25. data/vendor/lua/lib/lua/date.lua +745 -0
  26. data/vendor/lua/lib/lua/debug_ext.lua +84 -0
  27. data/vendor/lua/lib/lua/debug_init.lua +2 -0
  28. data/vendor/lua/lib/lua/des56.dll +0 -0
  29. data/vendor/lua/lib/lua/dist/config.lua +109 -0
  30. data/vendor/lua/lib/lua/dist/constraints.lua +271 -0
  31. data/vendor/lua/lib/lua/dist/depends.lua +601 -0
  32. data/vendor/lua/lib/lua/dist/git.lua +307 -0
  33. data/vendor/lua/lib/lua/dist/init.lua +278 -0
  34. data/vendor/lua/lib/lua/dist/manifest.lua +225 -0
  35. data/vendor/lua/lib/lua/dist/package.lua +583 -0
  36. data/vendor/lua/lib/lua/dist/sys.lua +367 -0
  37. data/vendor/lua/lib/lua/dist/utils.lua +130 -0
  38. data/vendor/lua/lib/lua/ex.dll +0 -0
  39. data/vendor/lua/lib/lua/fstable.lua +116 -0
  40. data/vendor/lua/lib/lua/getopt.lua +273 -0
  41. data/vendor/lua/lib/lua/git.lua +5 -0
  42. data/vendor/lua/lib/lua/git/core.dll +0 -0
  43. data/vendor/lua/lib/lua/git/objects.lua +121 -0
  44. data/vendor/lua/lib/lua/git/pack.lua +316 -0
  45. data/vendor/lua/lib/lua/git/protocol.lua +188 -0
  46. data/vendor/lua/lib/lua/git/repo.lua +283 -0
  47. data/vendor/lua/lib/lua/git/util.lua +233 -0
  48. data/vendor/lua/lib/lua/gzio.dll +0 -0
  49. data/vendor/lua/lib/lua/gzip.lua +81 -0
  50. data/vendor/lua/lib/lua/iconv.dll +0 -0
  51. data/vendor/lua/lib/lua/imlua.dll +0 -0
  52. data/vendor/lua/lib/lua/imlua_fftw.dll +0 -0
  53. data/vendor/lua/lib/lua/imlua_jp2.dll +0 -0
  54. data/vendor/lua/lib/lua/imlua_process.dll +0 -0
  55. data/vendor/lua/lib/lua/imlua_process_omp.dll +0 -0
  56. data/vendor/lua/lib/lua/io_ext.lua +115 -0
  57. data/vendor/lua/lib/lua/iuplua.dll +0 -0
  58. data/vendor/lua/lib/lua/iuplua_mglplot.dll +0 -0
  59. data/vendor/lua/lib/lua/iuplua_pplot.dll +0 -0
  60. data/vendor/lua/lib/lua/iupluacd.dll +0 -0
  61. data/vendor/lua/lib/lua/iupluacontrols.dll +0 -0
  62. data/vendor/lua/lib/lua/iupluagl.dll +0 -0
  63. data/vendor/lua/lib/lua/iupluaim.dll +0 -0
  64. data/vendor/lua/lib/lua/iupluaimglib.dll +0 -0
  65. data/vendor/lua/lib/lua/iupluatuio.dll +0 -0
  66. data/vendor/lua/lib/lua/lanes-keeper.lua +302 -0
  67. data/vendor/lua/lib/lua/lanes.lua +591 -0
  68. data/vendor/lua/lib/lua/lanes/core.dll +0 -0
  69. data/vendor/lua/lib/lua/lcs.lua +55 -0
  70. data/vendor/lua/lib/lua/lemock.lua +659 -0
  71. data/vendor/lua/lib/lua/lfs.dll +0 -0
  72. data/vendor/lua/lib/lua/list.lua +375 -0
  73. data/vendor/lua/lib/lua/logging.lua +189 -0
  74. data/vendor/lua/lib/lua/logging/console.lua +22 -0
  75. data/vendor/lua/lib/lua/logging/email.lua +44 -0
  76. data/vendor/lua/lib/lua/logging/file.lua +55 -0
  77. data/vendor/lua/lib/lua/logging/rolling_file.lua +81 -0
  78. data/vendor/lua/lib/lua/logging/socket.lua +35 -0
  79. data/vendor/lua/lib/lua/logging/sql.lua +64 -0
  80. data/vendor/lua/lib/lua/loop/base.lua +68 -0
  81. data/vendor/lua/lib/lua/loop/cached.lua +312 -0
  82. data/vendor/lua/lib/lua/loop/collection/MapWithArrayOfKeys.lua +64 -0
  83. data/vendor/lua/lib/lua/loop/collection/ObjectCache.lua +39 -0
  84. data/vendor/lua/lib/lua/loop/collection/OrderedSet.lua +164 -0
  85. data/vendor/lua/lib/lua/loop/collection/PriorityQueue.lua +86 -0
  86. data/vendor/lua/lib/lua/loop/collection/UnorderedArray.lua +32 -0
  87. data/vendor/lua/lib/lua/loop/collection/UnorderedArraySet.lua +56 -0
  88. data/vendor/lua/lib/lua/loop/compiler/Arguments.lua +108 -0
  89. data/vendor/lua/lib/lua/loop/compiler/Conditional.lua +50 -0
  90. data/vendor/lua/lib/lua/loop/compiler/Expression.lua +215 -0
  91. data/vendor/lua/lib/lua/loop/component/base.lua +221 -0
  92. data/vendor/lua/lib/lua/loop/component/contained.lua +71 -0
  93. data/vendor/lua/lib/lua/loop/component/dynamic.lua +223 -0
  94. data/vendor/lua/lib/lua/loop/component/intercepted.lua +354 -0
  95. data/vendor/lua/lib/lua/loop/component/wrapped.lua +195 -0
  96. data/vendor/lua/lib/lua/loop/debug/Inspector.lua +521 -0
  97. data/vendor/lua/lib/lua/loop/debug/Matcher.lua +192 -0
  98. data/vendor/lua/lib/lua/loop/debug/Verbose.lua +266 -0
  99. data/vendor/lua/lib/lua/loop/debug/Viewer.lua +200 -0
  100. data/vendor/lua/lib/lua/loop/multiple.lua +105 -0
  101. data/vendor/lua/lib/lua/loop/object/Exception.lua +57 -0
  102. data/vendor/lua/lib/lua/loop/object/Publisher.lua +43 -0
  103. data/vendor/lua/lib/lua/loop/object/Wrapper.lua +39 -0
  104. data/vendor/lua/lib/lua/loop/scoped.lua +585 -0
  105. data/vendor/lua/lib/lua/loop/serial/FileStream.lua +48 -0
  106. data/vendor/lua/lib/lua/loop/serial/Serializer.lua +291 -0
  107. data/vendor/lua/lib/lua/loop/serial/SocketStream.lua +51 -0
  108. data/vendor/lua/lib/lua/loop/serial/StringStream.lua +47 -0
  109. data/vendor/lua/lib/lua/loop/simple.lua +75 -0
  110. data/vendor/lua/lib/lua/loop/table.lua +71 -0
  111. data/vendor/lua/lib/lua/loop/thread/CoSocket.lua +416 -0
  112. data/vendor/lua/lib/lua/loop/thread/IOScheduler.lua +170 -0
  113. data/vendor/lua/lib/lua/loop/thread/Scheduler.lua +327 -0
  114. data/vendor/lua/lib/lua/loop/thread/SocketScheduler.lua +88 -0
  115. data/vendor/lua/lib/lua/loop/thread/Timer.lua +54 -0
  116. data/vendor/lua/lib/lua/lpeg.dll +0 -0
  117. data/vendor/lua/lib/lua/ltn12.lua +292 -0
  118. data/vendor/lua/lib/lua/luaXML_lib.dll +0 -0
  119. data/vendor/lua/lib/lua/luacurl.dll +0 -0
  120. data/vendor/lua/lib/lua/luadoc/config.lua +34 -0
  121. data/vendor/lua/lib/lua/luadoc/doclet/debug.lua +46 -0
  122. data/vendor/lua/lib/lua/luadoc/doclet/formatter.lua +84 -0
  123. data/vendor/lua/lib/lua/luadoc/doclet/html.lua +289 -0
  124. data/vendor/lua/lib/lua/luadoc/doclet/html/file.lp +113 -0
  125. data/vendor/lua/lib/lua/luadoc/doclet/html/function.lp +64 -0
  126. data/vendor/lua/lib/lua/luadoc/doclet/html/index.lp +70 -0
  127. data/vendor/lua/lib/lua/luadoc/doclet/html/luadoc.css +286 -0
  128. data/vendor/lua/lib/lua/luadoc/doclet/html/menu.lp +55 -0
  129. data/vendor/lua/lib/lua/luadoc/doclet/html/module.lp +109 -0
  130. data/vendor/lua/lib/lua/luadoc/doclet/html/table.lp +15 -0
  131. data/vendor/lua/lib/lua/luadoc/doclet/raw.lua +12 -0
  132. data/vendor/lua/lib/lua/luadoc/init.lua +58 -0
  133. data/vendor/lua/lib/lua/luadoc/lp.lua +130 -0
  134. data/vendor/lua/lib/lua/luadoc/taglet/standard.lua +495 -0
  135. data/vendor/lua/lib/lua/luadoc/taglet/standard/tags.lua +171 -0
  136. data/vendor/lua/lib/lua/luadoc/util.lua +233 -0
  137. data/vendor/lua/lib/lua/luagl.dll +0 -0
  138. data/vendor/lua/lib/lua/luaglu.dll +0 -0
  139. data/vendor/lua/lib/lua/luaidl.lua +113 -0
  140. data/vendor/lua/lib/lua/luaidl/lex.lua +793 -0
  141. data/vendor/lua/lib/lua/luaidl/pre.lua +149 -0
  142. data/vendor/lua/lib/lua/luaidl/sin.lua +3631 -0
  143. data/vendor/lua/lib/lua/luarocks/add.lua +108 -0
  144. data/vendor/lua/lib/lua/luarocks/admin_remove.lua +87 -0
  145. data/vendor/lua/lib/lua/luarocks/build.lua +330 -0
  146. data/vendor/lua/lib/lua/luarocks/build/builtin.lua +253 -0
  147. data/vendor/lua/lib/lua/luarocks/build/cmake.lua +54 -0
  148. data/vendor/lua/lib/lua/luarocks/build/command.lua +32 -0
  149. data/vendor/lua/lib/lua/luarocks/build/make.lua +92 -0
  150. data/vendor/lua/lib/lua/luarocks/cache.lua +85 -0
  151. data/vendor/lua/lib/lua/luarocks/cfg.lua +449 -0
  152. data/vendor/lua/lib/lua/luarocks/command_line.lua +163 -0
  153. data/vendor/lua/lib/lua/luarocks/deps.lua +654 -0
  154. data/vendor/lua/lib/lua/luarocks/dir.lua +69 -0
  155. data/vendor/lua/lib/lua/luarocks/download.lua +90 -0
  156. data/vendor/lua/lib/lua/luarocks/fetch.lua +321 -0
  157. data/vendor/lua/lib/lua/luarocks/fetch/cvs.lua +44 -0
  158. data/vendor/lua/lib/lua/luarocks/fetch/git.lua +81 -0
  159. data/vendor/lua/lib/lua/luarocks/fetch/git_file.lua +17 -0
  160. data/vendor/lua/lib/lua/luarocks/fetch/hg.lua +54 -0
  161. data/vendor/lua/lib/lua/luarocks/fetch/sscm.lua +42 -0
  162. data/vendor/lua/lib/lua/luarocks/fetch/svn.lua +53 -0
  163. data/vendor/lua/lib/lua/luarocks/fs.lua +40 -0
  164. data/vendor/lua/lib/lua/luarocks/fs/lua.lua +676 -0
  165. data/vendor/lua/lib/lua/luarocks/fs/unix.lua +88 -0
  166. data/vendor/lua/lib/lua/luarocks/fs/unix/tools.lua +325 -0
  167. data/vendor/lua/lib/lua/luarocks/fs/win32.lua +107 -0
  168. data/vendor/lua/lib/lua/luarocks/fs/win32/tools.lua +334 -0
  169. data/vendor/lua/lib/lua/luarocks/help.lua +101 -0
  170. data/vendor/lua/lib/lua/luarocks/index.lua +172 -0
  171. data/vendor/lua/lib/lua/luarocks/install.lua +151 -0
  172. data/vendor/lua/lib/lua/luarocks/list.lua +35 -0
  173. data/vendor/lua/lib/lua/luarocks/loader.lua +228 -0
  174. data/vendor/lua/lib/lua/luarocks/make.lua +71 -0
  175. data/vendor/lua/lib/lua/luarocks/make_manifest.lua +34 -0
  176. data/vendor/lua/lib/lua/luarocks/manif.lua +360 -0
  177. data/vendor/lua/lib/lua/luarocks/manif_core.lua +75 -0
  178. data/vendor/lua/lib/lua/luarocks/new_version.lua +141 -0
  179. data/vendor/lua/lib/lua/luarocks/pack.lua +205 -0
  180. data/vendor/lua/lib/lua/luarocks/path.lua +315 -0
  181. data/vendor/lua/lib/lua/luarocks/persist.lua +173 -0
  182. data/vendor/lua/lib/lua/luarocks/refresh_cache.lua +30 -0
  183. data/vendor/lua/lib/lua/luarocks/remove.lua +135 -0
  184. data/vendor/lua/lib/lua/luarocks/rep.lua +313 -0
  185. data/vendor/lua/lib/lua/luarocks/require.lua +6 -0
  186. data/vendor/lua/lib/lua/luarocks/search.lua +399 -0
  187. data/vendor/lua/lib/lua/luarocks/show.lua +138 -0
  188. data/vendor/lua/lib/lua/luarocks/site_config.lua +23 -0
  189. data/vendor/lua/lib/lua/luarocks/tools/patch.lua +712 -0
  190. data/vendor/lua/lib/lua/luarocks/tools/tar.lua +144 -0
  191. data/vendor/lua/lib/lua/luarocks/tools/zip.lua +245 -0
  192. data/vendor/lua/lib/lua/luarocks/type_check.lua +267 -0
  193. data/vendor/lua/lib/lua/luarocks/unpack.lua +151 -0
  194. data/vendor/lua/lib/lua/luarocks/util.lua +420 -0
  195. data/vendor/lua/lib/lua/luarocks/validate.lua +164 -0
  196. data/vendor/lua/lib/lua/luars232.dll +0 -0
  197. data/vendor/lua/lib/lua/luasql/mysql.dll +0 -0
  198. data/vendor/lua/lib/lua/luasql/postgres.dll +0 -0
  199. data/vendor/lua/lib/lua/luasql/sqlite3.dll +0 -0
  200. data/vendor/lua/lib/lua/luaunit.lua +601 -0
  201. data/vendor/lua/lib/lua/lxp.dll +0 -0
  202. data/vendor/lua/lib/lua/lxp/lom.lua +60 -0
  203. data/vendor/lua/lib/lua/math_ext.lua +27 -0
  204. data/vendor/lua/lib/lua/mbox.lua +53 -0
  205. data/vendor/lua/lib/lua/md5.lua +19 -0
  206. data/vendor/lua/lib/lua/md5/core.dll +0 -0
  207. data/vendor/lua/lib/lua/metalua.lua +0 -0
  208. data/vendor/lua/lib/lua/metalua/ast_to_string.mlua +553 -0
  209. data/vendor/lua/lib/lua/metalua/base.lua +104 -0
  210. data/vendor/lua/lib/lua/metalua/bytecode.lua +0 -0
  211. data/vendor/lua/lib/lua/metalua/clopts.mlua +204 -0
  212. data/vendor/lua/lib/lua/metalua/compiler.lua +3 -0
  213. data/vendor/lua/lib/lua/metalua/dollar.mlua +24 -0
  214. data/vendor/lua/lib/lua/metalua/extension/H-runtime.mlua +216 -0
  215. data/vendor/lua/lib/lua/metalua/extension/H.mlua +22 -0
  216. data/vendor/lua/lib/lua/metalua/extension/anaphoric.mlua +54 -0
  217. data/vendor/lua/lib/lua/metalua/extension/clist.mlua +149 -0
  218. data/vendor/lua/lib/lua/metalua/extension/continue.mlua +53 -0
  219. data/vendor/lua/lib/lua/metalua/extension/localin.mlua +2 -0
  220. data/vendor/lua/lib/lua/metalua/extension/log.mlua +39 -0
  221. data/vendor/lua/lib/lua/metalua/extension/match.mlua +374 -0
  222. data/vendor/lua/lib/lua/metalua/extension/ternary.mlua +10 -0
  223. data/vendor/lua/lib/lua/metalua/extension/trycatch.mlua +189 -0
  224. data/vendor/lua/lib/lua/metalua/extension/types-runtime.mlua +159 -0
  225. data/vendor/lua/lib/lua/metalua/extension/types.mlua +352 -0
  226. data/vendor/lua/lib/lua/metalua/extension/withdo.mlua +30 -0
  227. data/vendor/lua/lib/lua/metalua/extension/xglobal-runtime.lua +41 -0
  228. data/vendor/lua/lib/lua/metalua/extension/xglobal.mlua +20 -0
  229. data/vendor/lua/lib/lua/metalua/extension/xloop.mlua +100 -0
  230. data/vendor/lua/lib/lua/metalua/extension/xmatch.mlua +216 -0
  231. data/vendor/lua/lib/lua/metalua/metaloop.mlua +76 -0
  232. data/vendor/lua/lib/lua/metalua/mlc.lua +0 -0
  233. data/vendor/lua/lib/lua/metalua/mlc_xcall.lua +119 -0
  234. data/vendor/lua/lib/lua/metalua/mlp.lua +0 -0
  235. data/vendor/lua/lib/lua/metalua/package2.lua +101 -0
  236. data/vendor/lua/lib/lua/metalua/runtime.lua +3 -0
  237. data/vendor/lua/lib/lua/metalua/string2.lua +44 -0
  238. data/vendor/lua/lib/lua/metalua/table2.lua +372 -0
  239. data/vendor/lua/lib/lua/metalua/walk.mlua +304 -0
  240. data/vendor/lua/lib/lua/metalua/walk/bindings.mlua +41 -0
  241. data/vendor/lua/lib/lua/metalua/walk/id.mlua +186 -0
  242. data/vendor/lua/lib/lua/metalua/walk/scope.lua +54 -0
  243. data/vendor/lua/lib/lua/mime.lua +87 -0
  244. data/vendor/lua/lib/lua/mime/core.dll +0 -0
  245. data/vendor/lua/lib/lua/mobdebug.lua +1484 -0
  246. data/vendor/lua/lib/lua/modules.lua +16 -0
  247. data/vendor/lua/lib/lua/object.lua +56 -0
  248. data/vendor/lua/lib/lua/oil/Exception.lua +26 -0
  249. data/vendor/lua/lib/lua/oil/arch.lua +27 -0
  250. data/vendor/lua/lib/lua/oil/arch/basic/client.lua +29 -0
  251. data/vendor/lua/lib/lua/oil/arch/basic/common.lua +13 -0
  252. data/vendor/lua/lib/lua/oil/arch/basic/server.lua +27 -0
  253. data/vendor/lua/lib/lua/oil/arch/cooperative/common.lua +10 -0
  254. data/vendor/lua/lib/lua/oil/arch/cooperative/server.lua +16 -0
  255. data/vendor/lua/lib/lua/oil/arch/corba/client.lua +39 -0
  256. data/vendor/lua/lib/lua/oil/arch/corba/common.lua +58 -0
  257. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/client.lua +9 -0
  258. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/server.lua +9 -0
  259. data/vendor/lua/lib/lua/oil/arch/corba/server.lua +35 -0
  260. data/vendor/lua/lib/lua/oil/arch/ludo/byref.lua +18 -0
  261. data/vendor/lua/lib/lua/oil/arch/ludo/client.lua +19 -0
  262. data/vendor/lua/lib/lua/oil/arch/ludo/common.lua +18 -0
  263. data/vendor/lua/lib/lua/oil/arch/ludo/server.lua +19 -0
  264. data/vendor/lua/lib/lua/oil/arch/typed/client.lua +27 -0
  265. data/vendor/lua/lib/lua/oil/arch/typed/common.lua +9 -0
  266. data/vendor/lua/lib/lua/oil/arch/typed/server.lua +18 -0
  267. data/vendor/lua/lib/lua/oil/assert.lua +87 -0
  268. data/vendor/lua/lib/lua/oil/builder.lua +45 -0
  269. data/vendor/lua/lib/lua/oil/builder/basic/client.lua +31 -0
  270. data/vendor/lua/lib/lua/oil/builder/basic/common.lua +11 -0
  271. data/vendor/lua/lib/lua/oil/builder/basic/server.lua +13 -0
  272. data/vendor/lua/lib/lua/oil/builder/cooperative/common.lua +11 -0
  273. data/vendor/lua/lib/lua/oil/builder/cooperative/server.lua +11 -0
  274. data/vendor/lua/lib/lua/oil/builder/corba/client.lua +13 -0
  275. data/vendor/lua/lib/lua/oil/builder/corba/common.lua +24 -0
  276. data/vendor/lua/lib/lua/oil/builder/corba/gencode.lua +13 -0
  277. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/client.lua +11 -0
  278. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/server.lua +11 -0
  279. data/vendor/lua/lib/lua/oil/builder/corba/server.lua +13 -0
  280. data/vendor/lua/lib/lua/oil/builder/lua/client.lua +11 -0
  281. data/vendor/lua/lib/lua/oil/builder/lua/server.lua +12 -0
  282. data/vendor/lua/lib/lua/oil/builder/ludo/byref.lua +13 -0
  283. data/vendor/lua/lib/lua/oil/builder/ludo/client.lua +13 -0
  284. data/vendor/lua/lib/lua/oil/builder/ludo/common.lua +14 -0
  285. data/vendor/lua/lib/lua/oil/builder/ludo/server.lua +13 -0
  286. data/vendor/lua/lib/lua/oil/builder/typed/client.lua +16 -0
  287. data/vendor/lua/lib/lua/oil/builder/typed/server.lua +12 -0
  288. data/vendor/lua/lib/lua/oil/compat.lua +846 -0
  289. data/vendor/lua/lib/lua/oil/component.lua +1 -0
  290. data/vendor/lua/lib/lua/oil/corba/giop.lua +301 -0
  291. data/vendor/lua/lib/lua/oil/corba/giop/Codec.lua +1568 -0
  292. data/vendor/lua/lib/lua/oil/corba/giop/CodecGen.lua +589 -0
  293. data/vendor/lua/lib/lua/oil/corba/giop/Exception.lua +25 -0
  294. data/vendor/lua/lib/lua/oil/corba/giop/Indexer.lua +63 -0
  295. data/vendor/lua/lib/lua/oil/corba/giop/Listener.lua +343 -0
  296. data/vendor/lua/lib/lua/oil/corba/giop/Messenger.lua +228 -0
  297. data/vendor/lua/lib/lua/oil/corba/giop/Referrer.lua +180 -0
  298. data/vendor/lua/lib/lua/oil/corba/giop/Requester.lua +462 -0
  299. data/vendor/lua/lib/lua/oil/corba/idl.lua +597 -0
  300. data/vendor/lua/lib/lua/oil/corba/idl/Compiler.lua +133 -0
  301. data/vendor/lua/lib/lua/oil/corba/idl/Importer.lua +235 -0
  302. data/vendor/lua/lib/lua/oil/corba/idl/Indexer.lua +95 -0
  303. data/vendor/lua/lib/lua/oil/corba/idl/Registry.lua +1821 -0
  304. data/vendor/lua/lib/lua/oil/corba/idl/ir.lua +847 -0
  305. data/vendor/lua/lib/lua/oil/corba/idl/sysex.lua +21 -0
  306. data/vendor/lua/lib/lua/oil/corba/iiop/Profiler.lua +200 -0
  307. data/vendor/lua/lib/lua/oil/corba/intercepted/Listener.lua +158 -0
  308. data/vendor/lua/lib/lua/oil/corba/intercepted/Requester.lua +181 -0
  309. data/vendor/lua/lib/lua/oil/corba/services/event.lua +126 -0
  310. data/vendor/lua/lib/lua/oil/corba/services/event/ConsumerAdmin.lua +50 -0
  311. data/vendor/lua/lib/lua/oil/corba/services/event/EventFactory.lua +15 -0
  312. data/vendor/lua/lib/lua/oil/corba/services/event/EventQueue.lua +37 -0
  313. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushConsumer.lua +75 -0
  314. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushSupplier.lua +62 -0
  315. data/vendor/lua/lib/lua/oil/corba/services/event/SingleDeferredDispatcher.lua +60 -0
  316. data/vendor/lua/lib/lua/oil/corba/services/event/SingleSynchronousDispatcher.lua +39 -0
  317. data/vendor/lua/lib/lua/oil/corba/services/event/SupplierAdmin.lua +50 -0
  318. data/vendor/lua/lib/lua/oil/corba/services/naming.lua +436 -0
  319. data/vendor/lua/lib/lua/oil/kernel/base/Acceptor.lua +268 -0
  320. data/vendor/lua/lib/lua/oil/kernel/base/Channels.lua +121 -0
  321. data/vendor/lua/lib/lua/oil/kernel/base/Connector.lua +147 -0
  322. data/vendor/lua/lib/lua/oil/kernel/base/Dispatcher.lua +99 -0
  323. data/vendor/lua/lib/lua/oil/kernel/base/Proxies.lua +86 -0
  324. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/asynchronous.lua +56 -0
  325. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/protected.lua +17 -0
  326. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/synchronous.lua +17 -0
  327. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/utils.lua +29 -0
  328. data/vendor/lua/lib/lua/oil/kernel/base/Receiver.lua +110 -0
  329. data/vendor/lua/lib/lua/oil/kernel/base/Servants.lua +207 -0
  330. data/vendor/lua/lib/lua/oil/kernel/base/Sockets.lua +44 -0
  331. data/vendor/lua/lib/lua/oil/kernel/cooperative/Receiver.lua +139 -0
  332. data/vendor/lua/lib/lua/oil/kernel/intercepted/Listener.lua +47 -0
  333. data/vendor/lua/lib/lua/oil/kernel/intercepted/Requester.lua +58 -0
  334. data/vendor/lua/lib/lua/oil/kernel/lua/Dispatcher.lua +76 -0
  335. data/vendor/lua/lib/lua/oil/kernel/lua/Proxies.lua +69 -0
  336. data/vendor/lua/lib/lua/oil/kernel/typed/Dispatcher.lua +91 -0
  337. data/vendor/lua/lib/lua/oil/kernel/typed/Proxies.lua +153 -0
  338. data/vendor/lua/lib/lua/oil/kernel/typed/Servants.lua +137 -0
  339. data/vendor/lua/lib/lua/oil/ludo/Codec.lua +66 -0
  340. data/vendor/lua/lib/lua/oil/ludo/CodecByRef.lua +103 -0
  341. data/vendor/lua/lib/lua/oil/ludo/Listener.lua +151 -0
  342. data/vendor/lua/lib/lua/oil/ludo/Referrer.lua +72 -0
  343. data/vendor/lua/lib/lua/oil/ludo/Requester.lua +107 -0
  344. data/vendor/lua/lib/lua/oil/oo.lua +1 -0
  345. data/vendor/lua/lib/lua/oil/port.lua +1 -0
  346. data/vendor/lua/lib/lua/oil/properties.lua +57 -0
  347. data/vendor/lua/lib/lua/oil/verbose.lua +133 -0
  348. data/vendor/lua/lib/lua/package_ext.lua +15 -0
  349. data/vendor/lua/lib/lua/parser.lua +268 -0
  350. data/vendor/lua/lib/lua/pl/Date.lua +555 -0
  351. data/vendor/lua/lib/lua/pl/List.lua +613 -0
  352. data/vendor/lua/lib/lua/pl/Map.lua +113 -0
  353. data/vendor/lua/lib/lua/pl/MultiMap.lua +62 -0
  354. data/vendor/lua/lib/lua/pl/OrderedMap.lua +151 -0
  355. data/vendor/lua/lib/lua/pl/Set.lua +153 -0
  356. data/vendor/lua/lib/lua/pl/app.lua +165 -0
  357. data/vendor/lua/lib/lua/pl/array2d.lua +501 -0
  358. data/vendor/lua/lib/lua/pl/class.lua +180 -0
  359. data/vendor/lua/lib/lua/pl/comprehension.lua +286 -0
  360. data/vendor/lua/lib/lua/pl/config.lua +176 -0
  361. data/vendor/lua/lib/lua/pl/data.lua +606 -0
  362. data/vendor/lua/lib/lua/pl/dir.lua +475 -0
  363. data/vendor/lua/lib/lua/pl/file.lua +70 -0
  364. data/vendor/lua/lib/lua/pl/func.lua +376 -0
  365. data/vendor/lua/lib/lua/pl/init.lua +68 -0
  366. data/vendor/lua/lib/lua/pl/input.lua +173 -0
  367. data/vendor/lua/lib/lua/pl/lapp.lua +407 -0
  368. data/vendor/lua/lib/lua/pl/lexer.lua +456 -0
  369. data/vendor/lua/lib/lua/pl/luabalanced.lua +264 -0
  370. data/vendor/lua/lib/lua/pl/operator.lua +201 -0
  371. data/vendor/lua/lib/lua/pl/path.lua +398 -0
  372. data/vendor/lua/lib/lua/pl/permute.lua +63 -0
  373. data/vendor/lua/lib/lua/pl/platf/luajava.lua +101 -0
  374. data/vendor/lua/lib/lua/pl/pretty.lua +285 -0
  375. data/vendor/lua/lib/lua/pl/seq.lua +551 -0
  376. data/vendor/lua/lib/lua/pl/sip.lua +344 -0
  377. data/vendor/lua/lib/lua/pl/strict.lua +70 -0
  378. data/vendor/lua/lib/lua/pl/stringio.lua +158 -0
  379. data/vendor/lua/lib/lua/pl/stringx.lua +440 -0
  380. data/vendor/lua/lib/lua/pl/tablex.lua +817 -0
  381. data/vendor/lua/lib/lua/pl/template.lua +103 -0
  382. data/vendor/lua/lib/lua/pl/test.lua +135 -0
  383. data/vendor/lua/lib/lua/pl/text.lua +243 -0
  384. data/vendor/lua/lib/lua/pl/utils.lua +550 -0
  385. data/vendor/lua/lib/lua/pl/xml.lua +689 -0
  386. data/vendor/lua/lib/lua/profiler.dll +0 -0
  387. data/vendor/lua/lib/lua/re.lua +248 -0
  388. data/vendor/lua/lib/lua/rex_onig.dll +0 -0
  389. data/vendor/lua/lib/lua/rex_pcre.dll +0 -0
  390. data/vendor/lua/lib/lua/rex_posix.dll +0 -0
  391. data/vendor/lua/lib/lua/rings.dll +0 -0
  392. data/vendor/lua/lib/lua/serialize.lua +193 -0
  393. data/vendor/lua/lib/lua/set.lua +149 -0
  394. data/vendor/lua/lib/lua/socket.lua +133 -0
  395. data/vendor/lua/lib/lua/socket/core.dll +0 -0
  396. data/vendor/lua/lib/lua/socket/ftp.lua +281 -0
  397. data/vendor/lua/lib/lua/socket/http.lua +350 -0
  398. data/vendor/lua/lib/lua/socket/smtp.lua +251 -0
  399. data/vendor/lua/lib/lua/socket/tp.lua +123 -0
  400. data/vendor/lua/lib/lua/socket/url.lua +297 -0
  401. data/vendor/lua/lib/lua/ssl.dll +0 -0
  402. data/vendor/lua/lib/lua/ssl.lua +93 -0
  403. data/vendor/lua/lib/lua/ssl/https.lua +138 -0
  404. data/vendor/lua/lib/lua/stable.lua +28 -0
  405. data/vendor/lua/lib/lua/std.lua +16 -0
  406. data/vendor/lua/lib/lua/strbuf.lua +32 -0
  407. data/vendor/lua/lib/lua/strict.lua +45 -0
  408. data/vendor/lua/lib/lua/string_ext.lua +274 -0
  409. data/vendor/lua/lib/lua/table_ext.lua +117 -0
  410. data/vendor/lua/lib/lua/tar.lua +262 -0
  411. data/vendor/lua/lib/lua/task.dll +0 -0
  412. data/vendor/lua/lib/lua/tree.lua +81 -0
  413. data/vendor/lua/lib/lua/unicode.dll +0 -0
  414. data/vendor/lua/lib/lua/verbose_require.lua +11 -0
  415. data/vendor/lua/lib/lua/vstruct.lua +86 -0
  416. data/vendor/lua/lib/lua/vstruct/ast.lua +192 -0
  417. data/vendor/lua/lib/lua/vstruct/ast/Bitpack.lua +33 -0
  418. data/vendor/lua/lib/lua/vstruct/ast/Generator.lua +174 -0
  419. data/vendor/lua/lib/lua/vstruct/ast/IO.lua +45 -0
  420. data/vendor/lua/lib/lua/vstruct/ast/List.lua +56 -0
  421. data/vendor/lua/lib/lua/vstruct/ast/Name.lua +20 -0
  422. data/vendor/lua/lib/lua/vstruct/ast/Repeat.lua +23 -0
  423. data/vendor/lua/lib/lua/vstruct/ast/Root.lua +19 -0
  424. data/vendor/lua/lib/lua/vstruct/ast/Table.lua +65 -0
  425. data/vendor/lua/lib/lua/vstruct/cursor.lua +81 -0
  426. data/vendor/lua/lib/lua/vstruct/io.lua +45 -0
  427. data/vendor/lua/lib/lua/vstruct/io/a.lua +24 -0
  428. data/vendor/lua/lib/lua/vstruct/io/b.lua +28 -0
  429. data/vendor/lua/lib/lua/vstruct/io/bigendian.lua +21 -0
  430. data/vendor/lua/lib/lua/vstruct/io/c.lua +25 -0
  431. data/vendor/lua/lib/lua/vstruct/io/defaults.lua +24 -0
  432. data/vendor/lua/lib/lua/vstruct/io/endianness.lua +41 -0
  433. data/vendor/lua/lib/lua/vstruct/io/f.lua +129 -0
  434. data/vendor/lua/lib/lua/vstruct/io/hostendian.lua +21 -0
  435. data/vendor/lua/lib/lua/vstruct/io/i.lua +42 -0
  436. data/vendor/lua/lib/lua/vstruct/io/littleendian.lua +21 -0
  437. data/vendor/lua/lib/lua/vstruct/io/m.lua +62 -0
  438. data/vendor/lua/lib/lua/vstruct/io/p.lua +23 -0
  439. data/vendor/lua/lib/lua/vstruct/io/s.lua +27 -0
  440. data/vendor/lua/lib/lua/vstruct/io/seekb.lua +18 -0
  441. data/vendor/lua/lib/lua/vstruct/io/seekf.lua +18 -0
  442. data/vendor/lua/lib/lua/vstruct/io/seekto.lua +18 -0
  443. data/vendor/lua/lib/lua/vstruct/io/u.lua +54 -0
  444. data/vendor/lua/lib/lua/vstruct/io/x.lua +34 -0
  445. data/vendor/lua/lib/lua/vstruct/io/z.lua +63 -0
  446. data/vendor/lua/lib/lua/vstruct/lexer.lua +100 -0
  447. data/vendor/lua/lib/lua/vstruct/pack.lua +142 -0
  448. data/vendor/lua/lib/lua/vstruct/test.lua +47 -0
  449. data/vendor/lua/lib/lua/vstruct/test/basic.lua +73 -0
  450. data/vendor/lua/lib/lua/vstruct/test/common.lua +100 -0
  451. data/vendor/lua/lib/lua/vstruct/test/fp-bigendian.lua +56 -0
  452. data/vendor/lua/lib/lua/vstruct/test/fp-littleendian.lua +56 -0
  453. data/vendor/lua/lib/lua/vstruct/test/struct-test-gen.lua +1230 -0
  454. data/vendor/lua/lib/lua/vstruct/unpack.lua +126 -0
  455. data/vendor/lua/lib/lua/wx.dll +0 -0
  456. data/vendor/lua/lib/lua/xml.lua +75 -0
  457. data/vendor/lua/lib/lua/zip.dll +0 -0
  458. data/vendor/lua/lib/lua/zlib.dll +0 -0
  459. metadata +529 -0
@@ -0,0 +1,100 @@
1
+ local vstruct = require "vstruct"
2
+
3
+ local char,ord = string.char,string.byte
4
+
5
+ local test = { results = {} }
6
+
7
+ function test.x(str)
8
+ return (str:gsub("%X", ""):gsub("%x%x", function(b) return char(tonumber(b, 16)) end))
9
+ end
10
+
11
+ function test.od(str, sep)
12
+ local fmt = "%02X"..(sep or " ")
13
+ return (str:gsub('.', function(c) return fmt:format(c:byte()) end))
14
+ end
15
+
16
+ function test.eq(x, y)
17
+ if type(x) ~= type(y) then return false end
18
+
19
+ if type(x) == 'table' then
20
+ for k,v in pairs(x) do
21
+ if not test.eq(v, y[k]) then return false end
22
+ end
23
+ for k,v in pairs(y) do
24
+ if not test.eq(v, x[k]) then return false end
25
+ end
26
+ return true
27
+ end
28
+
29
+ return x == y
30
+ end
31
+
32
+ function test.group(name)
33
+ local group = { name=name }
34
+ table.insert(test.results, group)
35
+ test.current_group = group
36
+ end
37
+
38
+ -- record the results of the test
39
+ -- test is the name
40
+ -- result is the boolean pass/fail
41
+ -- message is an optional string, and will be displayed to the user as
42
+ -- "note" or "fail" depending on the value of result
43
+ function test.record(name, result, data)
44
+ table.insert(test.current_group, { name=name, result=result, message=message, data=data })
45
+ end
46
+
47
+ function test.autotest(name, format, buffer, data, output)
48
+ local eq = test.eq
49
+ local record = test.record
50
+
51
+ output = output or buffer
52
+
53
+ if type(data) ~= "table" then data = {data} end
54
+
55
+ local unpacked = vstruct.unpack(format, buffer)
56
+ local packed = vstruct.pack(format, unpacked)
57
+
58
+ record(name.." (U )", eq(unpacked, data), unpack(unpacked))
59
+ record(name.." (UP)", eq(packed, output), test.od(packed))
60
+
61
+ local packed = vstruct.pack(format, data)
62
+ local unpacked = vstruct.unpack(format, packed)
63
+
64
+ record(name.." (P )", eq(packed, output), test.od(packed))
65
+ record(name.." (PU)", eq(unpacked, data), unpack(unpacked))
66
+ end
67
+
68
+ function test.report()
69
+ local allfailed = 0
70
+ for _,group in ipairs(test.results) do
71
+ local failed = 0
72
+ print("\t=== "..group.name.." ===")
73
+
74
+ for _,test in ipairs(group) do
75
+ if not test.result then
76
+ failed = failed + 1
77
+ print("FAIL", test.name)
78
+ if type(test.data) == 'string' and test.data:match("%z") then
79
+ print("", (test.data:gsub("%z", ".")))
80
+ else
81
+ print("", test.data)
82
+ end
83
+ end
84
+ end
85
+
86
+ print("\tTotal: ", #group)
87
+ print("\tFailed:", failed)
88
+ print()
89
+ allfailed = allfailed + failed
90
+ end
91
+
92
+ return allfailed
93
+ end
94
+
95
+ -- determine host endianness - HACK HACK HACK
96
+ function test.bigendian()
97
+ return string.byte(string.dump(function() end)) == 0x00
98
+ end
99
+
100
+ return test
@@ -0,0 +1,56 @@
1
+ local vstruct = require "vstruct"
2
+ local test = require "vstruct.test.common"
3
+ local inf = math.huge
4
+
5
+ -- work around a bug in the Lua constant table optimizer
6
+ local z = 0
7
+ local nz = -z
8
+
9
+ local function T(n, buf)
10
+ return test.autotest(tostring(n), "> f8", buf, n)
11
+ end
12
+
13
+ test.group("big-endian ieee doubles")
14
+
15
+ T(0, "\000\000\000\000\000\000\000\000")
16
+ T(4.9406564584124654418e-324, "\000\000\000\000\000\000\000\001")
17
+ T(7.4169128616906696301e-309, "\000\005\085\085\085\085\085\085")
18
+ T(1.483382572338133926e-308, "\000\010\170\170\170\170\170\170")
19
+ T(2.225073858507200889e-308, "\000\015\255\255\255\255\255\255")
20
+ T(2.2250738585072013831e-308, "\000\016\000\000\000\000\000\000")
21
+ T(2.2250738585072018772e-308, "\000\016\000\000\000\000\000\001")
22
+ T(2.9667651446762683461e-308, "\000\021\085\085\085\085\085\085")
23
+ T(3.7084564308453353091e-308, "\000\026\170\170\170\170\170\170")
24
+ T(4.4501477170144022721e-308, "\000\031\255\255\255\255\255\255")
25
+ T(8.9884656743115795386e+307, "\127\224\000\000\000\000\000\000")
26
+ T(8.9884656743115815345e+307, "\127\224\000\000\000\000\000\001")
27
+ T(1.1984620899082105386e+308, "\127\229\085\085\085\085\085\085")
28
+ T(1.4980776123852631234e+308, "\127\234\170\170\170\170\170\170")
29
+ T(1.7976931348623157081e+308, "\127\239\255\255\255\255\255\255")
30
+ T(4.9406564584124654418e-324, "\000\000\000\000\000\000\000\001")
31
+ T(2.225073858507200889e-308, "\000\015\255\255\255\255\255\255")
32
+ T(2.2250738585072013831e-308, "\000\016\000\000\000\000\000\000")
33
+ T(1.7976931348623157081e+308, "\127\239\255\255\255\255\255\255")
34
+ T(inf, "\127\240\000\000\000\000\000\000")
35
+ T(0, "\000\000\000\000\000\000\000\000")
36
+ T(nz, "\128\000\000\000\000\000\000\000")
37
+ T(-4.9406564584124654418e-324, "\128\000\000\000\000\000\000\001")
38
+ T(-7.4169128616906696301e-309, "\128\005\085\085\085\085\085\085")
39
+ T(-1.483382572338133926e-308, "\128\010\170\170\170\170\170\170")
40
+ T(-2.225073858507200889e-308, "\128\015\255\255\255\255\255\255")
41
+ T(-2.2250738585072013831e-308, "\128\016\000\000\000\000\000\000")
42
+ T(-2.2250738585072018772e-308, "\128\016\000\000\000\000\000\001")
43
+ T(-2.9667651446762683461e-308, "\128\021\085\085\085\085\085\085")
44
+ T(-3.7084564308453353091e-308, "\128\026\170\170\170\170\170\170")
45
+ T(-4.4501477170144022721e-308, "\128\031\255\255\255\255\255\255")
46
+ T(-8.9884656743115795386e+307, "\255\224\000\000\000\000\000\000")
47
+ T(-8.9884656743115815345e+307, "\255\224\000\000\000\000\000\001")
48
+ T(-1.1984620899082105386e+308, "\255\229\085\085\085\085\085\085")
49
+ T(-1.4980776123852631234e+308, "\255\234\170\170\170\170\170\170")
50
+ T(-1.7976931348623157081e+308, "\255\239\255\255\255\255\255\255")
51
+ T(-4.9406564584124654418e-324, "\128\000\000\000\000\000\000\001")
52
+ T(-2.225073858507200889e-308, "\128\015\255\255\255\255\255\255")
53
+ T(-2.2250738585072013831e-308, "\128\016\000\000\000\000\000\000")
54
+ T(-1.7976931348623157081e+308, "\255\239\255\255\255\255\255\255")
55
+ T(-inf, "\255\240\000\000\000\000\000\000")
56
+ T(nz, "\128\000\000\000\000\000\000\000")
@@ -0,0 +1,56 @@
1
+ local vstruct = require "vstruct"
2
+ local test = require "vstruct.test.common"
3
+ local inf = math.huge
4
+
5
+ -- work around a bug in the Lua constant table optimizer
6
+ local z = 0
7
+ local nz = -z
8
+
9
+ local function T(n, buf)
10
+ return test.autotest(tostring(n), "< f8", buf, n)
11
+ end
12
+
13
+ test.group("little-endian ieee doubles")
14
+
15
+ T(0, "\000\000\000\000\000\000\000\000")
16
+ T(4.9406564584124654418e-324, "\001\000\000\000\000\000\000\000")
17
+ T(7.4169128616906696301e-309, "\085\085\085\085\085\085\005\000")
18
+ T(1.483382572338133926e-308, "\170\170\170\170\170\170\010\000")
19
+ T(2.225073858507200889e-308, "\255\255\255\255\255\255\015\000")
20
+ T(2.2250738585072013831e-308, "\000\000\000\000\000\000\016\000")
21
+ T(2.2250738585072018772e-308, "\001\000\000\000\000\000\016\000")
22
+ T(2.9667651446762683461e-308, "\085\085\085\085\085\085\021\000")
23
+ T(3.7084564308453353091e-308, "\170\170\170\170\170\170\026\000")
24
+ T(4.4501477170144022721e-308, "\255\255\255\255\255\255\031\000")
25
+ T(8.9884656743115795386e+307, "\000\000\000\000\000\000\224\127")
26
+ T(8.9884656743115815345e+307, "\001\000\000\000\000\000\224\127")
27
+ T(1.1984620899082105386e+308, "\085\085\085\085\085\085\229\127")
28
+ T(1.4980776123852631234e+308, "\170\170\170\170\170\170\234\127")
29
+ T(1.7976931348623157081e+308, "\255\255\255\255\255\255\239\127")
30
+ T(4.9406564584124654418e-324, "\001\000\000\000\000\000\000\000")
31
+ T(2.225073858507200889e-308, "\255\255\255\255\255\255\015\000")
32
+ T(2.2250738585072013831e-308, "\000\000\000\000\000\000\016\000")
33
+ T(1.7976931348623157081e+308, "\255\255\255\255\255\255\239\127")
34
+ T(inf, "\000\000\000\000\000\000\240\127")
35
+ T(0, "\000\000\000\000\000\000\000\000")
36
+ T(nz, "\000\000\000\000\000\000\000\128")
37
+ T(-4.9406564584124654418e-324, "\001\000\000\000\000\000\000\128")
38
+ T(-7.4169128616906696301e-309, "\085\085\085\085\085\085\005\128")
39
+ T(-1.483382572338133926e-308, "\170\170\170\170\170\170\010\128")
40
+ T(-2.225073858507200889e-308, "\255\255\255\255\255\255\015\128")
41
+ T(-2.2250738585072013831e-308, "\000\000\000\000\000\000\016\128")
42
+ T(-2.2250738585072018772e-308, "\001\000\000\000\000\000\016\128")
43
+ T(-2.9667651446762683461e-308, "\085\085\085\085\085\085\021\128")
44
+ T(-3.7084564308453353091e-308, "\170\170\170\170\170\170\026\128")
45
+ T(-4.4501477170144022721e-308, "\255\255\255\255\255\255\031\128")
46
+ T(-8.9884656743115795386e+307, "\000\000\000\000\000\000\224\255")
47
+ T(-8.9884656743115815345e+307, "\001\000\000\000\000\000\224\255")
48
+ T(-1.1984620899082105386e+308, "\085\085\085\085\085\085\229\255")
49
+ T(-1.4980776123852631234e+308, "\170\170\170\170\170\170\234\255")
50
+ T(-1.7976931348623157081e+308, "\255\255\255\255\255\255\239\255")
51
+ T(-4.9406564584124654418e-324, "\001\000\000\000\000\000\000\128")
52
+ T(-2.225073858507200889e-308, "\255\255\255\255\255\255\015\128")
53
+ T(-2.2250738585072013831e-308, "\000\000\000\000\000\000\016\128")
54
+ T(-1.7976931348623157081e+308, "\255\255\255\255\255\255\239\255")
55
+ T(-inf, "\000\000\000\000\000\000\240\255")
56
+ T(nz, "\000\000\000\000\000\000\000\128")
@@ -0,0 +1,1230 @@
1
+ -- Config
2
+ local CONF = {
3
+ VERBOSE = false, -- Spew verbosely while testing?
4
+
5
+ WIDTH = 32, -- Total width of numbers in bits.
6
+ PRECISION = 17, -- Fractional precision in bits.
7
+
8
+ MAX_DEPTH = 5, -- Limit on nesting depth of test formats.
9
+ COMPOUND_LENGTH = 2, -- # formats in a sequence.
10
+ SEED = false, -- Seed for generating tests.
11
+
12
+ NROF_TESTS = 2^10, -- number of random test cases to run
13
+ }
14
+
15
+ -- Features to use when making format strings to test.
16
+ local USE = {
17
+ LEFT_REPETITION = true, --n*fmt
18
+ GROUPING = true, --{ fmt }
19
+ NESTING = true, --( fmt )
20
+ NAMING = true, --id:fmt
21
+ ENDIAN = true, --><
22
+ EMPTY = true, --
23
+ COMPOUND = true --fmt fmt ... fmt
24
+ }
25
+
26
+
27
+ -- Non-config
28
+ local PROTECT_STRUCT = true -- If set, wrap calls to struct with pcall.
29
+ local TEST_KIND = nil --"read"|"write"
30
+
31
+ -- Should every format string explicitly set the endianness at the start?
32
+ -- Setting this to true mask(s|ed?) a bug where the endianness controls leak
33
+ -- between calls to struct.pack().
34
+ local PREFIX_ENDIAN = true
35
+ local PREFIX_ENDIAN_SEP = " " --"" gives format string parse errors
36
+
37
+ local TOKEN_SEP = "" -- Separator between tokens.
38
+ local MAX_BITS = 52 -- Maximum bit width we care about.
39
+ local MACHINE_ENDIAN = "<" -- Native endianness.
40
+
41
+ local COMPOUND_SEP = " "
42
+
43
+ -- Parse arguments and sort then out into USE vs. CONF options.
44
+ for _,given_arg in ipairs(arg) do
45
+ local k,v = given_arg:match("^([^=]+)=(.+)")
46
+ k = k or given_arg
47
+ k = k:upper():gsub("-", "_")
48
+ v = v or true
49
+
50
+ if nil ~= CONF[k] then
51
+ CONF[k] = assert(loadstring("return "..tostring(v)))()
52
+ elseif nil ~= USE[k] then
53
+ USE[k] = v ~= "FALSE" and true or false
54
+ elseif k == "NONE" then
55
+ for feature,_ in pairs(USE) do USE[feature] = false end
56
+ elseif given_arg == "read" or given_arg == "write" then
57
+ TEST_KIND = given_arg
58
+ else
59
+ io.stderr:write(("unknown argument %q\n"):format(given_arg))
60
+ os.exit(1)
61
+ end
62
+ end
63
+
64
+ -- Imports
65
+ local io, math, os, string, table =
66
+ io, math, os, string, table
67
+
68
+ local assert, ipairs, pairs, loadstring, pcall =
69
+ assert, ipairs, pairs, loadstring, pcall
70
+ local require, setmetatable, tonumber, tostring, type =
71
+ require, setmetatable, tonumber, tostring, type
72
+
73
+ local struct = require "vstruct"; struct.cache = nil
74
+ local test = require "vstruct.test.common"
75
+ local record = test.record
76
+ local __EOG__ = __EOG__
77
+
78
+ local ceil,floor,fmod = math.ceil, math.floor, math.fmod
79
+ local char_ = string.char
80
+
81
+ local function char(x) return char_(x % 256) end
82
+
83
+ -- Structural equality (no cycles please)
84
+ local function eq(a,b)
85
+ if a == b then return true end
86
+ local t = type(a)
87
+ if t ~= type(b) then return false end
88
+ if t ~= "table" then return false end
89
+
90
+ for k,av in pairs(a) do
91
+ local bv = b[k]
92
+ if not eq(av,bv) then
93
+ return false
94
+ end
95
+ end
96
+ for k,bv in pairs(b) do
97
+ local av = a[k]
98
+ if not eq(av,bv) then
99
+ return false
100
+ end
101
+ end
102
+ return true
103
+ end
104
+
105
+ -- str = dump(value)
106
+ local dump = {}
107
+ setmetatable(dump,
108
+ {
109
+ __call =
110
+ function (self, value)
111
+ local t = type(value)
112
+ local f = dump[t]
113
+ assert(f, "don't know how to dump "..
114
+ "values of type "..t)
115
+ return f(value)
116
+ end
117
+ })
118
+
119
+ dump["nil"] = function() return "nil" end
120
+
121
+ function dump.string(s) return ("%q"):format(s) end
122
+
123
+ function dump.boolean(b) return tostring(b) end
124
+
125
+ function dump.number(x)
126
+ local m, e = math.frexp(x) --0.5 <= m <= 1, e an int
127
+ for i=1,53 do --scale m to an integer
128
+ if floor(m) == m then break end
129
+ m = m*2
130
+ e = e - 1
131
+ end
132
+
133
+ if e == 0 then return ("%.0f"):format(m) end
134
+
135
+ local op = e < 0 and "/" or "*"
136
+ e = math.abs(e)
137
+ local exp = e > 1 and "2^"..e or "2"
138
+ return ("%.0f%s%s"):format(m, op, exp)
139
+ end
140
+
141
+ function dump.table(t)
142
+ local dumped = {}
143
+
144
+ local pieces = {}
145
+ local function push(x) table.insert(pieces, x) end
146
+
147
+ push("{")
148
+
149
+ for i, v in ipairs(t) do
150
+ if #pieces > 1 then push(", ") end
151
+ push(dump(v))
152
+ dumped[i] = true
153
+ end
154
+
155
+ for k,v in pairs(t) do
156
+ if not dumped[k] then
157
+ if #pieces > 1 then push(", ") end
158
+ if type(k) == "string" and k:match("^%a[a-zA-Z0-9_]*$") then
159
+ push(k)
160
+ else
161
+ push("[")
162
+ push(dump(k))
163
+ push("]")
164
+ end
165
+ push("=")
166
+ push(dump(v))
167
+ end
168
+ end
169
+
170
+ push("}")
171
+ return table.concat(pieces)
172
+ end
173
+
174
+ -- List module
175
+ local list
176
+ list = {
177
+ reverse =
178
+ function (t)
179
+ local out = {}
180
+ local n = #t
181
+ for i=1,n do
182
+ local j = n-i+1
183
+ out[j] = t[i]
184
+ end
185
+ return out
186
+ end,
187
+
188
+ iter =
189
+ function (t, f)
190
+ for i,v in ipairs(t) do f(v) end
191
+ return t
192
+ end,
193
+
194
+ map =
195
+ function (t, f)
196
+ local out = {}
197
+ for i,v in ipairs(t) do out[i] = f(v) end
198
+ return out
199
+ end,
200
+
201
+ foldl =
202
+ function (t, f, accu)
203
+ for i,v in ipairs(t) do accu = f(v, accu) end
204
+ return accu
205
+ end,
206
+
207
+ merge =
208
+ function (dst, src)
209
+ local merged = {}
210
+ for k,v in ipairs(src) do --append the array part
211
+ table.insert(dst, v)
212
+ merged[k] = true
213
+ end
214
+ for k,v in pairs(src) do --overwrite the hash part
215
+ if not merged[k] then
216
+ dst[k] = v
217
+ end
218
+ end
219
+ return dst
220
+ end,
221
+
222
+ zeros =
223
+ function (n)
224
+ local t={}
225
+ for i=1,n do t[i] = 0 end
226
+ return t
227
+ end,
228
+
229
+ range =
230
+ function (first, last, step)
231
+ local t = {}
232
+ if nil == last then
233
+ first,last,step = 1,first,step
234
+ end
235
+ step = step or 1
236
+ for i=first,last,step do t[#t+1] = i end
237
+ return t
238
+ end,
239
+
240
+ cat =
241
+ function (...)
242
+ local accu = {}
243
+ local function loop(t,...)
244
+ if nil == t then return accu end
245
+ list.merge(accu, t)
246
+ return loop(...)
247
+ end
248
+ return loop(...)
249
+ end,
250
+
251
+ rep =
252
+ function (t, count)
253
+ count = count or 0
254
+ local accu = {}
255
+ for i=1,count do list.merge(accu, t) end
256
+ return accu
257
+ end
258
+ }
259
+
260
+ -- MRG32k3a random number generator.
261
+ -- Returns numbers which are random for the full range of the IEEE
262
+ -- double mantissa.
263
+ local function make_rand(seed)
264
+
265
+ local s10, s11, s12 = 12345,12345,12345
266
+ local s20, s21, s22 = 12345,12345,12345
267
+
268
+ local function rand()
269
+ -- Return the next random number in the range [0,4294967087).
270
+ local p1 = (1403580*s11 - 810728*s10) % 4294967087
271
+ local p2 = (527612*s22 - 1370589*s20) % 4294944443
272
+ s10,s11,s12 = s11,s12,p1
273
+ s20,s21,s22 = s21,s22,p2
274
+ return (p1 - p2) % 4294967087
275
+ end
276
+
277
+ if seed then
278
+ seed = tonumber(seed) or 12345
279
+ local m = 4294967087
280
+ local a = seed % 4294967087
281
+ a = a==a and a or 12345
282
+ s10,s11,s12,s20,s21,s22 = a,a+1,a+2,a+3,a+4,a+5 -- not all zero
283
+ rand(); rand(); rand(); -- pump out the seed.
284
+ end
285
+
286
+ local frexp = math.frexp
287
+
288
+ local function rand52()
289
+ local hi,lo = rand(), rand()
290
+ local m,e = frexp(hi * 4294967087 + lo) -- 0.5 <= m < 1
291
+ local t = m*2^53 - 2^52 -- map mantissa to 0 <= t < 2^52 range
292
+ return t
293
+ end
294
+
295
+ return rand52
296
+ end
297
+
298
+ local function byte_rand(rand)
299
+ return function () return rand() % 256 end
300
+ end
301
+
302
+ local function bool_rand(rand)
303
+ return function () return rand() % 2 == 0 end
304
+ end
305
+
306
+ local function char_rand(rand)
307
+ return function () return char(rand()) end
308
+ end
309
+
310
+ local function clamped_rand(rand, lo, hi)
311
+ local wid = hi - lo + 1
312
+ return function () return lo + (rand() % wid) end
313
+ end
314
+
315
+ local function string_rand(rand, minlen, maxlen)
316
+ minlen = minlen or 0
317
+ maxlen = maxlen or 512
318
+ local gen_len = clamped_rand(rand, minlen, maxlen)
319
+ local gen_char = char_rand(clamped_rand(rand, 66, 90))
320
+ return function (len)
321
+ len = len or gen_len()
322
+ return table.concat(list.map(list.range(len), gen_char))
323
+ end
324
+ end
325
+
326
+ -- Return an array of width representing value in two's
327
+ -- complement in little-endian format.
328
+ local function int_to_bytes_le(value, nbytes)
329
+ local t = {}
330
+ for i=1,nbytes do
331
+ local r = value % 256
332
+ t[i] = r
333
+ value = (value - r) / 256
334
+ end
335
+ return t
336
+ end
337
+
338
+ local function keys(tab)
339
+ local ks = {}
340
+ for k,_ in pairs(tab) do table.insert(ks, k) end
341
+ return ks
342
+ end
343
+
344
+ local function bless(obj, class) --make obj an instance of class
345
+ return setmetatable(obj, {__index = class})
346
+ end
347
+
348
+ -- Test case interface.
349
+ local Test = {
350
+ new =
351
+ function (class, self)
352
+ return bless(self or {}, class)
353
+ end,
354
+
355
+ get_naked = nil, --pack/unpack format string w/o endian control
356
+ get_data = nil, --data byte string
357
+ get_values = nil, --value list
358
+ get_length = nil, --# top level entities in the format
359
+ get_endian = nil, --before/after endian; nil=don't care
360
+
361
+ get_format =
362
+ function (self, endian, fmt)
363
+ local fmt = fmt or self:get_naked()
364
+ local before, after = self:get_endian()
365
+ endian = endian or before
366
+ before = before or endian
367
+ after = after or before
368
+ if before ~= endian then
369
+ fmt = before..fmt
370
+ end
371
+ return fmt, after
372
+ end
373
+ }
374
+
375
+ local function as_hex(str)
376
+ if not str then return nil end
377
+ return str:gsub('.', function(c)
378
+ return string.format("%02X ", c:byte())
379
+ end)
380
+ end
381
+
382
+ local function perform_write_test(test, endian)
383
+ endian = endian or MACHINE_ENDIAN
384
+
385
+ local format = test:get_format(endian)
386
+ local want_data = test:get_data()
387
+ local values = test:get_values()
388
+
389
+ if PREFIX_ENDIAN then
390
+ format = "=" .. PREFIX_ENDIAN_SEP .. format
391
+ end
392
+
393
+ local pcall = pcall
394
+ if not PROTECT_STRUCT then
395
+ pcall = function (f,...) return true, f(...) end
396
+ end
397
+
398
+ local errmsg = nil
399
+
400
+ local success, got_data = pcall(struct.pack, format, values)
401
+ if not success then
402
+ errmsg = got_data
403
+ got_data = nil
404
+ end
405
+
406
+ success = success and eq(got_data, want_data)
407
+
408
+ record("random write test", success, dump {
409
+ got_data = got_data and as_hex(got_data) or nil,
410
+ want_data = as_hex(want_data),
411
+ format = format,
412
+ values = values,
413
+ error = errmsg,
414
+ ok = success
415
+ })
416
+ end
417
+
418
+ local function perform_read_test(test, endian)
419
+ endian = endian or MACHINE_ENDIAN
420
+
421
+ local format = test:get_format(endian)
422
+ local from_data = test:get_data()
423
+ local want_values = test:get_values()
424
+
425
+ if PREFIX_ENDIAN then
426
+ format = "=" .. PREFIX_ENDIAN_SEP .. format
427
+ end
428
+
429
+ local pcall = pcall
430
+ if not PROTECT_STRUCT then
431
+ pcall = function (f,...) return true, f(...) end
432
+ end
433
+
434
+ local errmsg = nil
435
+
436
+ local success, got_values = pcall(struct.unpack, format, from_data)
437
+ if not success then
438
+ errmsg = got_values
439
+ got_values = nil
440
+ end
441
+
442
+ success = success and eq(got_values, want_values)
443
+
444
+ record("random read test", success, dump {
445
+ got_values = got_values,
446
+ want_values = want_values,
447
+ from_data = as_hex(from_data),
448
+ format = format,
449
+ error = errmsg,
450
+ ok = success
451
+ })
452
+ end
453
+
454
+ local ScalarTest = Test:new{
455
+ new = function (class, self)
456
+ self = Test.new(class, self)
457
+ self.is_scalar = true
458
+ return self
459
+ end,
460
+ get_naked = function (self, endian) return self.format end,
461
+ get_values = function (self) return { self.value } end,
462
+ get_data = function (self) return self.data end,
463
+ get_length = function (self) return self.length or 1 end,
464
+ get_endian = function (self) return self.endian, self.endian end,
465
+ }
466
+
467
+ local EmptyTest = ScalarTest:new{
468
+ format = "",
469
+ value = nil,
470
+ data = "",
471
+ length = 0,
472
+ endian = nil
473
+ }
474
+
475
+ -- A compound test models a sequence of unnested or ungrouped formats.
476
+ local CompoundTest = Test:new{
477
+ new =
478
+ function (class, self)
479
+ self = Test.new(class, self)
480
+ self.tests = {}
481
+ return self
482
+ end,
483
+
484
+ add_test =
485
+ function (self, t)
486
+ table.insert(self.tests, t)
487
+ return self
488
+ end,
489
+
490
+ get_data =
491
+ function (self)
492
+ return table.concat(list.map(self.tests,
493
+ function (t) return t:get_data() end))
494
+ end,
495
+
496
+ get_format =
497
+ function (self, endian)
498
+ return table.concat(list.map(self.tests,
499
+ function (t) local fmt
500
+ fmt,endian = t:get_format(endian)
501
+ return fmt
502
+ end),
503
+ COMPOUND_SEP), endian
504
+ end,
505
+
506
+ get_endian =
507
+ function (self)
508
+ local n = #(self.tests)
509
+ if n == 0 then return nil,nil end
510
+ local before, after
511
+ for i=1,n do
512
+ local b,a = self.tests[i]:get_endian()
513
+ before = before or b
514
+ after = a or after
515
+ end
516
+ return before, after
517
+ end,
518
+
519
+ get_values =
520
+ function (self)
521
+ local accu = {}
522
+ list.iter(self.tests,
523
+ function (t)
524
+ list.merge(accu, t:get_values())
525
+ end)
526
+ return accu
527
+ end,
528
+
529
+ get_length =
530
+ function (self)
531
+ return #(self.tests)
532
+ end,
533
+ }
534
+
535
+ -- A ProxyTest just resends its messages to a test named in self.body.
536
+ local ProxyTest = Test:new{
537
+ new =
538
+ function (class, self, body)
539
+ local self = Test.new(class, self)
540
+ self.body = self.body or body
541
+ return self
542
+ end,
543
+
544
+ get_naked =
545
+ function (self)
546
+ return self.body:get_naked()
547
+ end,
548
+
549
+ get_data =
550
+ function (self)
551
+ return self.body:get_data()
552
+ end,
553
+
554
+ get_values =
555
+ function (self)
556
+ return self.body:get_values()
557
+ end,
558
+
559
+ get_length =
560
+ function (self)
561
+ return self.body:get_length()
562
+ end,
563
+
564
+ get_endian =
565
+ function (self)
566
+ return self.body:get_endian()
567
+ end
568
+ }
569
+
570
+ -- Gives the self.body test a self.name.
571
+ local NamedTest = ProxyTest:new{
572
+ new =
573
+ function (class, self)
574
+ self = ProxyTest.new(class, self)
575
+ assert(self.name, "NamedTest unnamed")
576
+ return self
577
+ end,
578
+
579
+ get_naked =
580
+ function (self)
581
+ return self.name ..":" .. self.body:get_naked()
582
+ end,
583
+
584
+ get_values =
585
+ function (self)
586
+ local values = self.body:get_values()
587
+ local key, value
588
+ for k,v in ipairs(values) do
589
+ assert(nil == value,
590
+ "NamedTest bound to multiple values")
591
+ value = v
592
+ key = k
593
+ end
594
+ for k,v in pairs(values) do
595
+ assert(nil == value or key == k,
596
+ "NamedTest bound to multiple values")
597
+ value = v
598
+ end
599
+ assert(nil ~= value, "NamedTest unbound to a value")
600
+ return { [self.name] = value }
601
+ end
602
+ }
603
+
604
+ -- Models a test group nested in curlies.
605
+ local GroupedTest = ProxyTest:new{
606
+ get_format =
607
+ function (self, endian)
608
+ local fmt,after = self.body:get_format(endian)
609
+ return "{"..fmt.."}", after
610
+ end,
611
+
612
+ get_values =
613
+ function (self)
614
+ return { self.body:get_values() }
615
+ end,
616
+
617
+ get_length =
618
+ function (self)
619
+ return 1
620
+ end
621
+ }
622
+
623
+ -- Models a test nested within parens.
624
+ local NestedTest = ProxyTest:new{
625
+ get_format =
626
+ function (self, endian)
627
+ local fmt,after = self.body:get_format(endian)
628
+ return "("..fmt..")", after
629
+ end,
630
+
631
+ get_length =
632
+ function (self)
633
+ return 1
634
+ end
635
+ }
636
+
637
+ local LeftRepetitionTest = ProxyTest:new{
638
+ new =
639
+ function (class, self)
640
+ self = ProxyTest.new(class, self)
641
+ self.count = self.count or 1
642
+ return self
643
+ end,
644
+
645
+ get_format =
646
+ function (self, endian)
647
+ local before = self.body:get_endian()
648
+ local fmt, after = self.body:get_format(endian)
649
+ before = before or endian
650
+ after = after or before
651
+ after = self.count > 0 and after or endian
652
+
653
+ assert(after == before or self.count == 0,
654
+ ("Non-idempotent left repetition for format '%s'"):format(fmt))
655
+ fmt = "("..fmt..")"
656
+ return self.count..TOKEN_SEP.."*"..TOKEN_SEP..fmt, after
657
+ end,
658
+
659
+ get_data =
660
+ function (self)
661
+ return self.body:get_data():rep(self.count)
662
+ end,
663
+
664
+ get_values =
665
+ function (self)
666
+ return list.rep(self.body:get_values(), self.count)
667
+ end,
668
+
669
+ get_length =
670
+ function (self)
671
+ return 1
672
+ end,
673
+
674
+ get_endian =
675
+ function (self)
676
+ if self.count > 0 then
677
+ return self.body:get_endian()
678
+ end
679
+ end,
680
+ }
681
+
682
+ -- Test generation state.
683
+ local State = {
684
+ new =
685
+ function (class, seed)
686
+ local self = {
687
+ rand = make_rand(seed), --data source
688
+ endian = nil, --nil|">"|"<"
689
+ width = 56,
690
+ precision = 16,
691
+ depth = 0, --recursion depth
692
+ uniq = 0 --unique name seq
693
+ }
694
+ return bless(self, class)
695
+ end,
696
+
697
+ is_big_endian =
698
+ function (self)
699
+ return self.endian == ">" --XXX: should test vs. native also?
700
+ end,
701
+
702
+ raw_of_list = --byte list, endian -> byte string
703
+ function (self, t, reverse)
704
+ if nil == reverse then reverse = self:is_big_endian() end
705
+
706
+ local chars = list.map(t, char)
707
+ if reverse then
708
+ chars = list.reverse(chars)
709
+ end
710
+ return table.concat(chars)
711
+ end,
712
+
713
+ raw_of_int = --int, width, endian -> byte string
714
+ function (self, val, W, reverse)
715
+ return self:raw_of_list(int_to_bytes_le(val, W), reverse)
716
+ end
717
+ }
718
+
719
+ local function zero_pad_to_length(s, len)
720
+ local pad_len = len - #s
721
+ if pad_len <= 0 then
722
+ return s
723
+ end
724
+ return s .. ("\0"):rep(pad_len)
725
+ end
726
+
727
+ local function cruft_pad_to_length(s, len)
728
+ local cruft = "cruft"
729
+ while #s < len do
730
+ local ix = 1 + #s % #cruft
731
+ s = s .. cruft:sub(ix,ix)
732
+ end
733
+ return s
734
+ end
735
+
736
+ -- Scalar test generators
737
+ -- TODO: fW
738
+ -- manually tested: @A +A -A
739
+ local ScalarGen
740
+ ScalarGen = {
741
+
742
+ bitmask =
743
+ function (state, w)
744
+ local W = ceil(w/8)
745
+ w = w < MAX_BITS and w or MAX_BITS
746
+ local value = state.rand()
747
+ local value = fmod(value,2^w)
748
+
749
+ local write_bits = {}
750
+ local read_bits = {}
751
+ local n = 0
752
+ local v = value
753
+
754
+ while n < 8*W do
755
+ local r = v % 2
756
+
757
+ table.insert(read_bits, r == 1)
758
+ if v > 0 then
759
+ table.insert(write_bits, r == 1)
760
+ end
761
+
762
+ v = (v - r) / 2
763
+ n = n+1
764
+ end
765
+
766
+ local write_test = ScalarTest:new{
767
+ endian = state.endian,
768
+ format = ("m%d"):format(W),
769
+ value = write_bits,
770
+ data = state:raw_of_int(value, W)
771
+ }
772
+ local read_test = ScalarTest:new{
773
+ endian = state.endian,
774
+ format = ("m%d"):format(W),
775
+ value = read_bits,
776
+ data = state:raw_of_int(value, W)
777
+ }
778
+ return write_test, read_test
779
+ end,
780
+
781
+ skip_pad =
782
+ function (state, w)
783
+ local W = ceil(w/8)
784
+ return ScalarTest:new{
785
+ format = "x"..W,
786
+ value = nil, --?
787
+ data = zero_pad_to_length("", W)
788
+ },
789
+ ScalarTest:new{
790
+ format = "x"..W,
791
+ value = nil, --?
792
+ data = cruft_pad_to_length("", W)
793
+ }
794
+ end,
795
+
796
+ cstring_implicit =
797
+ function (state, w)
798
+ local W = ceil(w/8)
799
+ local len = W-1
800
+ local s = string_rand(state.rand)(len)
801
+
802
+ local write_test = ScalarTest:new{
803
+ endian = state.endian,
804
+ format = "z",
805
+ value = s,
806
+ data = s.."\0"
807
+ }
808
+ local read_test = ScalarTest:new{
809
+ endian = state.endian,
810
+ format = ("z%d"):format(W),
811
+ value = s,
812
+ data = write_test.data
813
+ }
814
+ return write_test, read_test
815
+ end,
816
+
817
+ cstring_short =
818
+ function (state, w)
819
+ local W = ceil(w/8) -->0
820
+ local len = state.rand() % (W) -- must be < W
821
+ local s = string_rand(state.rand)(len)
822
+
823
+ local data = s.."\0"
824
+ local write_data = zero_pad_to_length(data, W)
825
+ local read_data = cruft_pad_to_length(data, W)
826
+
827
+ local write_test = ScalarTest:new{
828
+ endian = state.endian,
829
+ format = ("z%d"):format(W),
830
+ value = s,
831
+ data = write_data:sub(1,W)
832
+ }
833
+ local read_test = ScalarTest:new{
834
+ endian = state.endian,
835
+ format = ("z%d"):format(W),
836
+ value = s,
837
+ data = read_data:sub(1,W)
838
+ }
839
+ return write_test, read_test
840
+ end,
841
+
842
+ cstring_long =
843
+ function (state, w)
844
+ local W = ceil(w/8) -->0
845
+ local s = string_rand(state.rand)(W-1)
846
+ local cruft = string_rand(state.rand,1,W)()
847
+
848
+ local write_test = ScalarTest:new{
849
+ endian = state.endian,
850
+ format = ("z%d"):format(W),
851
+ value = s .. cruft,
852
+ data = s.."\0"
853
+ }
854
+ local read_test = ScalarTest:new{
855
+ endian = state.endian,
856
+ format = ("z%d"):format(W),
857
+ value = s,
858
+ data = write_test.data
859
+ }
860
+ return write_test, read_test
861
+ end,
862
+
863
+ boolean =
864
+ function (state, w)
865
+ local W = ceil(w/8)
866
+ local value = fmod((state.rand() % 2) * state.rand(), 2^8)
867
+ local flag = value ~= 0 and w > 0
868
+ if not flag then value = 0 end
869
+
870
+ local write_test = ScalarTest:new{
871
+ endian = state.endian,
872
+ format = ("b%d"):format(W),
873
+ value = flag,
874
+ data = state:raw_of_int(flag and 1 or 0, W)
875
+ }
876
+ local read_test = ScalarTest:new{
877
+ endian = state.endian,
878
+ format = ("b%d"):format(W),
879
+ value = flag,
880
+ data = state:raw_of_int(value, W)
881
+ }
882
+ return write_test, read_test
883
+ end,
884
+
885
+ unsigned_int =
886
+ function (state, w)
887
+ local W = ceil(w/8)
888
+ w = w < MAX_BITS and w or MAX_BITS
889
+ local value = state.rand()
890
+ local value = fmod(value,2^w)
891
+ return ScalarTest:new{
892
+ endian = state.endian,
893
+ format = ("u%d"):format(W),
894
+ value = value,
895
+ data = state:raw_of_int(value, W)
896
+ }
897
+ end,
898
+
899
+ signed_int =
900
+ function (state, w)
901
+ local W = ceil(w/8)
902
+ w = w < MAX_BITS and w or MAX_BITS
903
+ local bias = 2^(w-1)
904
+ local value = (fmod(state.rand(), 2^w) - bias)
905
+ if w == 0 then value = 0 end
906
+ return ScalarTest:new{
907
+ endian = state.endian,
908
+ format = ("i%d"):format(W),
909
+ value = value,
910
+ data = state:raw_of_int(value, W)
911
+ }
912
+ end,
913
+
914
+ --[[
915
+ fixed_rational_bit =
916
+ function (state, w, f)
917
+ local W = ceil(w/8)
918
+ local test = ScalarGen.signed_int(state, w)
919
+ test.format = ("P%d.%d"):format(8*W - f, f)
920
+ test.value = test.value / 2^f
921
+ return test
922
+ end,
923
+
924
+ fixed_rational_byte =
925
+ function (state, w, f)
926
+ local W = ceil(w/8)
927
+ local F = ceil(f/8)
928
+ local test = ScalarGen.signed_int(state, w)
929
+ test.format = ("p%d.%d"):format(W - F, F)
930
+ test.value = test.value / 2^(8*F)
931
+ return test
932
+ end,
933
+
934
+ --]]
935
+ string_implicit =
936
+ function (state, w)
937
+ local W = ceil(w/8)
938
+ local len = W
939
+ local s = string_rand(state.rand)(len)
940
+
941
+ local write_test = ScalarTest:new{
942
+ endian = state.endian,
943
+ format = "s",
944
+ value = s,
945
+ data = s
946
+ }
947
+ local read_test = ScalarTest:new{
948
+ endian = state.endian,
949
+ format = ("s%d"):format(W),
950
+ value = s,
951
+ data = write_test.data
952
+ }
953
+ return write_test, read_test
954
+ end,
955
+
956
+ string_short =
957
+ function (state, w)
958
+ local W = ceil(w/8)
959
+ local len = state.rand() % (W+1)
960
+ local s = string_rand(state.rand)(len)
961
+ local pad = ("\0"):rep(W - #s)
962
+
963
+ local write_test = ScalarTest:new{
964
+ endian = state.endian,
965
+ format = ("s%d"):format(W),
966
+ value = s,
967
+ data = s .. pad
968
+ }
969
+ local read_test = ScalarTest:new{
970
+ endian = state.endian,
971
+ format = ("s%d"):format(W),
972
+ value = s .. pad,
973
+ data = write_test.data
974
+ }
975
+ return write_test, read_test
976
+ end,
977
+
978
+ string_long =
979
+ function (state, w)
980
+ local W = ceil(w/8)
981
+ local s = string_rand(state.rand)(W)
982
+ local cruft = string_rand(state.rand,0,W)()
983
+
984
+ local write_test = ScalarTest:new{
985
+ endian = state.endian,
986
+ format = ("s%d"):format(W),
987
+ value = s .. cruft,
988
+ data = s
989
+ }
990
+ local read_test = ScalarTest:new{
991
+ endian = state.endian,
992
+ format = ("s%d"):format(W),
993
+ value = s,
994
+ data = write_test.data
995
+ }
996
+ return write_test, read_test
997
+ end,
998
+
999
+ counted_string =
1000
+ function (state, w)
1001
+ local W = ceil(w/8)
1002
+ w = w > 4 and 4 or w
1003
+ local count = fmod(state.rand(), 2^w)
1004
+ local count_data = state:raw_of_int(count, W)
1005
+ local s = string_rand(state.rand)(count)
1006
+ return ScalarTest:new{
1007
+ endian = state.endian,
1008
+ format = ("c%d"):format(W),
1009
+ value = s,
1010
+ data = count_data..s
1011
+ }
1012
+ end,
1013
+ }
1014
+
1015
+ local EmptyGen = {}
1016
+
1017
+ if USE.EMPTY then
1018
+ function EmptyGen.empty(state) return EmptyTest:new() end
1019
+ function EmptyGen.space(state) return EmptyTest:new{ format = " " } end
1020
+ function EmptyGen.tab(state) return EmptyTest:new{ format = "\t" } end
1021
+ function EmptyGen.nl(state) return EmptyTest:new{ format = "\n" } end
1022
+ --function EmptyGen.cr(state) return EmptyTest:new{ format = "\r" } end
1023
+ end
1024
+
1025
+ if USE.ENDIAN then
1026
+ function EmptyGen.big_endian(state)
1027
+ state.endian = ">"
1028
+ local self = EmptyTest:new()
1029
+ self.endian = state.endian
1030
+ return self
1031
+ end
1032
+
1033
+ function EmptyGen.little_endian(state)
1034
+ state.endian = "<"
1035
+ local self = EmptyTest:new()
1036
+ self.endian = state.endian
1037
+ return self
1038
+ end
1039
+ end
1040
+
1041
+ -- Leaf tests don't recurse.
1042
+ local LeafGen = {}
1043
+ for _,f in pairs(EmptyGen) do table.insert(LeafGen, f) end
1044
+ for _,f in pairs(ScalarGen) do table.insert(LeafGen, f) end
1045
+
1046
+ local gen_random_leaf
1047
+
1048
+ local function gen_random_leaf_for_write(state, w, f)
1049
+ local i = 1 + state.rand() % #LeafGen
1050
+ local gen = LeafGen[i]
1051
+ return gen(state, w or state.width, f or state.precision)
1052
+ end
1053
+
1054
+ local function gen_random_leaf_for_read(state, w, f)
1055
+ local write,read = gen_random_leaf_for_write(state, w, f)
1056
+ read = read or write
1057
+ return read
1058
+ end
1059
+
1060
+ -- List of all test generators (populated below)
1061
+ local TestGen = {}
1062
+
1063
+ local function gen_random_test(state, w, f)
1064
+ if state.depth >= CONF.MAX_DEPTH then
1065
+ return gen_random_leaf(state, w, f)
1066
+ end
1067
+ state.depth = state.depth + 1
1068
+ local i = 1 + state.rand() % #TestGen
1069
+ local gen = TestGen[i]
1070
+ local t = gen(state, w, f)
1071
+ state.depth = state.depth - 1
1072
+ return t
1073
+ end
1074
+
1075
+ -- Populate the test generators.
1076
+ table.insert(TestGen,
1077
+ function (...)
1078
+ return gen_random_leaf(...)
1079
+ end)
1080
+
1081
+ if USE.COMPOUND then
1082
+ table.insert(TestGen,
1083
+ function (state,w,f)
1084
+ local n = CONF.COMPOUND_LENGTH
1085
+ local t = CompoundTest:new()
1086
+ for i=1,n do
1087
+ t:add_test(gen_random_test(state, w, f))
1088
+ end
1089
+ return t
1090
+ end)
1091
+ end
1092
+
1093
+ if USE.NESTING then
1094
+ table.insert(TestGen,
1095
+ function (state,w,f)
1096
+ local t = gen_random_test(state, w, f)
1097
+ return NestedTest:new{body = t}
1098
+ end)
1099
+ end
1100
+
1101
+ if USE.GROUPING then
1102
+ table.insert(TestGen,
1103
+ function (state,w,f)
1104
+ local t = gen_random_test(state, w, f)
1105
+ return GroupedTest:new{body = t}
1106
+ end)
1107
+ end
1108
+
1109
+ if USE.NAMING then
1110
+ table.insert(TestGen,
1111
+ function (state,w,f)
1112
+ local t = gen_random_test(state, w, f)
1113
+ local vs = t:get_values()
1114
+ if #vs == 1 and t.is_scalar then
1115
+ state.uniq = state.uniq + 1
1116
+ t = NamedTest:new{body = t, name="u"..state.uniq}
1117
+ end
1118
+ return t
1119
+ end)
1120
+ end
1121
+
1122
+ if USE.LEFT_REPETITION then
1123
+ table.insert(TestGen,
1124
+ function (state,w,f)
1125
+ local t = gen_random_test(state, w, f)
1126
+ local before, after = t:get_endian()
1127
+ if before == after then
1128
+ t = LeftRepetitionTest:new{
1129
+ body = t,
1130
+ count = state.rand() % 5
1131
+ }
1132
+ end
1133
+ return t
1134
+ end)
1135
+ end
1136
+
1137
+ local function main_write()
1138
+ test.group "randomly generated write tests"
1139
+ local state = State:new(CONF.SEED or os.time())
1140
+ state.width = CONF.WIDTH
1141
+ state.precision = CONF.PRECISION
1142
+
1143
+ gen_random_leaf = gen_random_leaf_for_write
1144
+
1145
+ for k,gen in pairs(EmptyGen) do
1146
+ for _,e in ipairs{"<",">"} do
1147
+ state.endian = e
1148
+ local t = gen(state, state.width, state.precision)
1149
+ perform_write_test(t, "=")
1150
+ end
1151
+ end
1152
+
1153
+ for k,gen in pairs(ScalarGen) do
1154
+ for _,e in ipairs{"<",">"} do
1155
+ state.endian = e
1156
+ local t = gen(state, state.width, state.precision)
1157
+ perform_write_test(t, "=")
1158
+ end
1159
+ end
1160
+
1161
+ for i=1,CONF.NROF_TESTS do
1162
+ for _,e in ipairs{"<",">"} do
1163
+ state.endian = e
1164
+ local t = gen_random_test(state, state.width, state.precision)
1165
+ perform_write_test(t)
1166
+ end
1167
+ end
1168
+ end
1169
+
1170
+ local function main_read()
1171
+ test.group "randomly generated read tests"
1172
+ local state = State:new(CONF.SEED or os.time())
1173
+ state.width = CONF.WIDTH
1174
+ state.precision = CONF.PRECISION
1175
+
1176
+ gen_random_leaf = gen_random_leaf_for_read
1177
+
1178
+ for k,gen in pairs(EmptyGen) do
1179
+ for _,e in ipairs{"<",">"} do
1180
+ state.endian = e
1181
+ local w,r = gen(state, state.width, state.precision)
1182
+ local t = r or w
1183
+ perform_read_test(t, "=")
1184
+ end
1185
+ end
1186
+
1187
+ for k,gen in pairs(ScalarGen) do
1188
+ for _,e in ipairs{"<",">"} do
1189
+ state.endian = e
1190
+ local w,r = gen(state, state.width, state.precision)
1191
+ local t = r or w
1192
+ perform_read_test(t, "=")
1193
+ end
1194
+ end
1195
+
1196
+ for i=1,CONF.NROF_TESTS do
1197
+ for _,e in ipairs{"<",">"} do
1198
+ state.endian = e
1199
+ local t = gen_random_test(state, state.width, state.precision)
1200
+ perform_read_test(t)
1201
+ end
1202
+ end
1203
+ end
1204
+
1205
+ if TEST_KIND == "read" then
1206
+ main_read()
1207
+ elseif TEST_KIND == "write" then
1208
+ main_write()
1209
+ else
1210
+ local function opt_of_keyword(k)
1211
+ local o = k:lower():gsub("_", "-")
1212
+ return o
1213
+ end
1214
+
1215
+ io.write"usage: <features...> <opts..> read|write\n\n"
1216
+
1217
+ io.write"Features:\n"
1218
+ io.write("\tnone")
1219
+ for i,k in ipairs(keys(USE)) do
1220
+ io.write", "
1221
+ if i % 5 == 0 then io.write"\n\t" end
1222
+ io.write(opt_of_keyword(k))
1223
+ end
1224
+ io.write"\n"
1225
+
1226
+ io.write"Options:\n"
1227
+ for k, v in pairs(CONF) do
1228
+ io.write("\t",opt_of_keyword(k),"=",tostring(v),"\n")
1229
+ end
1230
+ end