remove gcc for MacOS in conan.yml
[liba.git] / lua / test / pid_neuro.lua
blob328bb1653b5ecd6d90b03fdf42ce44eb5adcf752
1 #!/usr/bin/env lua
3 package.path = arg[0]:sub(0, -arg[0]:match("([^/\\]*)$"):len() - 1) .. "?.lua;" .. package.path
4 local test = require("test")
5 local a = require("liba")
6 test.dir(getmetatable(a.pid_neuro))
7 local ctx = a.pid_neuro.new()
8 assert(ctx)
9 test.dir(getmetatable(ctx))
10 assert(type(a.pid_neuro.set_kpid(ctx, 4, 3, 2, 1)) == "userdata")
11 assert(type(a.pid_neuro.set_wpid(ctx, 3, 2, 1)) == "userdata")
12 assert(type(a.pid_neuro.run(ctx, 1, 0)) == "number")
13 assert(type(a.pid_neuro.inc(ctx, 1, 0)) == "number")
14 assert(type(a.pid_neuro.zero(ctx)) == "userdata")
15 ctx:set_kpid(4, 3, 2, 1):set_wpid(3, 2, 1):zero()
16 assert(type(ctx:run(1, 0)) == "number")
17 assert(type(ctx:inc(1, 0)) == "number")
18 assert(type(ctx.k) == "number")
19 assert(type(ctx.kp) == "number")
20 assert(type(ctx.ki) == "number")
21 assert(type(ctx.kd) == "number")
22 assert(type(ctx.wp) == "number")
23 assert(type(ctx.wi) == "number")
24 assert(type(ctx.wd) == "number")
25 assert(type(ctx.outmax) == "number")
26 assert(type(ctx.outmin) == "number")
27 assert(type(ctx.out) == "number")
28 assert(type(ctx.fdb) == "number")
29 assert(type(ctx.err) == "number")
30 assert(type(ctx.ec) == "number")
31 ctx.outmin = -10
32 ctx.outmax = 10
33 ctx.kp = 3
34 ctx.ki = 2
35 ctx.kd = 1
36 ctx.wp = 3
37 ctx.wi = 2
38 ctx.wd = 1
39 ctx.k = 0
40 ctx.__name = nil
41 assert(ctx.__name)
42 ctx.__index = nil
43 assert(ctx.__index)
44 ctx.__newindex = nil
45 assert(ctx.__newindex)
46 ---@class a.pid_neuro
47 ---@field __name string
48 ---@field __index table
49 ---@field __newindex table