fix constructor of version with a string argument
[liba.git] / lua / test / tf.lua
blobe937f31a997920a80315064cda76cda37996df13
1 #!/usr/bin/env lua
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.tf))
9 local num = { 6.59492796e-05, 6.54019884e-05 }
10 local den = { -1.97530991, 0.97530991 }
12 local ctx = a.tf.new(num, den)
13 test.dir(getmetatable(ctx))
14 assert(type(a.tf.iter(ctx, 1)) == "number")
15 assert(type(a.tf.zero(ctx)) == "userdata")
16 assert(type(ctx.iter(ctx, 1)) == "number")
17 assert(type(ctx.zero(ctx)) == "userdata")
18 assert(type(ctx:iter(1)) == "number")
19 assert(type(ctx:zero()) == "userdata")
20 test.dir(ctx.num)
21 test.dir(ctx.den)
22 test.dir(ctx.input)
23 test.dir(ctx.output)
24 ctx.num = { 1, 2 }
25 assert(type(ctx.num) == "table")
26 ctx.den = { 3, 4 }
27 assert(type(ctx.den) == "table")
28 ctx.__name = nil
29 assert(ctx.__name)
30 ctx.__call = nil
31 assert(ctx.__call)
32 ctx.__index = nil
33 assert(ctx.__index)
34 ctx.__newindex = nil
35 assert(ctx.__newindex)
36 ---@class a.tf
37 ---@field __name string
38 ---@field __call function
39 ---@field __index table
40 ---@field __newindex table