3 ---@diagnostic disable: redefined-local
4 package
.path
= arg
[0]:sub(0, -arg
[0]:match("([^/\\]*)$"):len() - 1) .. "?.lua;" .. package
.path
5 local test
= require("test")
6 local a
= require("liba")
7 test
.dir(getmetatable(a
.crc64
))
8 local ctx
= a
.crc64
.new("0x000000000000001B")
10 local ctx
= a
.crc64
.new("0x42F0E1EBA9EA3693", true)
12 assert(type(ctx
.table) == "table")
13 test
.dir(getmetatable(ctx
))
14 local text
= "0123456789"
15 ctx
:gen("0x000000000000001B")
16 assert(a
.crc64
.eval(ctx
, text
) == "0xE4FFBEA588AFC790")
17 assert(tonumber(a
.crc64
.eval(ctx
, a
.crc64
.pack(ctx
, text
))) == 0)
18 ctx
:gen("0x42F0E1EBA9EA3693", true)
19 assert(ctx
:eval(text
) == "0xDA60676A5CDE0008")
20 assert(tonumber(ctx
:eval(ctx
:pack(text
))) == 0)
28 assert(ctx
.__newindex
)
30 ---@field __name string
31 ---@field __call function
32 ---@field __index table
33 ---@field __newindex table