-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathptusa_main.lua
73 lines (60 loc) · 2.16 KB
/
ptusa_main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'busted.runner'()
expose("ptusa", function()
ptusa = require ( 'ptusa_main' )
it("load", function()
assert.is_truthy(package.loaded.ptusa_main) --module is not loaded
assert.is_truthy( ptusa )
if no_print_stack_traceback then
ptusa.no_print_stack_traceback()
end
end)
it("init", function()
local res = ptusa.init(
"main (Lua)",
main_script or "main.plua",
"--path", path or "",
"--sys_path", sys_path or "./sys/" )
assert.are.equal(res, 0)
end)
it("eval() function", function()
assert.are.equal( ptusa.eval(), 0 )
end)
it("objects operations", function()
if OBJECTS then
for idx, obj in pairs(OBJECTS) do
local name = obj.name
print( idx, name, obj.n )
local operations_cnt = obj:get_modes_count()
for i = 1, operations_cnt do
print( " ", i )
obj:set_mode( i, 1 )
assert.are.equal( ptusa.eval(), 0 )
obj:set_mode( i, 0 )
assert.are.equal( ptusa.eval(), 0 )
end
end
end
end)
it("objects number and type", function()
if OBJECTS then
for idx, obj in pairs(OBJECTS) do
print( idx, obj.name, obj.n, "("..obj.tech_type..")" )
end
local err_str = ""
for _, obj in pairs(OBJECTS) do
local n = obj.n
local tech_type = obj.tech_type
for _, obj2 in pairs(OBJECTS) do
if obj ~= obj2 then
if n == obj2.n and tech_type == obj2.tech_type then
err_str = err_str.."\n '"..obj2.name..
"' has the same number ("..n..") and type ("..tech_type..
") as '"..obj.name.."'."
end
end
end
end
if err_str ~= "" then error( "Not correct objects description:"..err_str ) end
end
end)
end)