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
.version
))
7 local v000
= a
.version
.new()
8 local v100
= a
.version
.new(1)
9 local v010
= a
.version
.new(0, 1)
10 local v001
= a
.version
.new(0, 0, 1)
11 local vctx
= a
.version
.new(a
.VERSION
)
12 assert(type(vctx
.major
) == "number")
13 assert(type(vctx
.minor
) == "number")
14 assert(type(vctx
.third
) == "number")
15 assert(type(vctx
.extra
) == "number")
16 assert(type(vctx
.alpha
) == "string")
17 assert(a
.version
.eq(v000
, v000
))
18 assert(a
.version
.ne(v000
, v010
))
19 assert(a
.version
.lt(v000
, v010
))
20 assert(not a
.version
.lt(v000
, v000
))
21 assert(a
.version
.gt(v010
, v000
))
22 assert(not a
.version
.gt(v000
, v000
))
23 assert(a
.version
.le(v000
, v010
))
24 assert(not a
.version
.le(v010
, v000
))
25 assert(a
.version
.ge(v010
, v000
))
26 assert(not a
.version
.ge(v000
, v010
))
27 assert(a
.version
.cmp(v000
, v100
) < 0)
28 assert(a
.version
.cmp(v000
, v010
) < 0)
29 assert(a
.version
.cmp(v000
, v001
) < 0)
30 assert(a
.version
.cmp(v100
, v000
) > 0)
31 assert(a
.version
.cmp(v010
, v000
) > 0)
32 assert(a
.version
.cmp(v001
, v000
) > 0)
33 assert(a
.version
.cmp(v000
, v000
) == 0)
37 assert(not (v000
< v000
))
39 assert(not (v000
> v000
))
41 assert(not (v010
<= v000
))
43 assert(not (v000
>= v010
))
44 test
.dir(vctx
.__index
)
58 assert(vctx
.__newindex
)
60 assert(vctx
.__tostring
)
61 test
.log("version", a
.VERSION
)
62 test
.log("major", a
.version
.MAJOR
)
63 test
.log("minor", a
.version
.MINOR
)
64 test
.log("patch", a
.version
.PATCH
)
65 test
.log("tweak", a
.version
.TWEAK
)
66 test
.log(vctx(), "0.0.0", a
.version
.check())
68 ---@field __lt function
69 ---@field __le function
70 ---@field __eq function
71 ---@field __name string
72 ---@field __call function
73 ---@field __index table
74 ---@field __newindex table
75 ---@field __tostring function