forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.lua
More file actions
62 lines (54 loc) · 1.73 KB
/
Copy pathmisc.lua
File metadata and controls
62 lines (54 loc) · 1.73 KB
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
config.target = 'core'
function test.overlappingGlobals()
local globals = {}
for name in pairs(df.global) do
local gvar = df.global:_field(name)
local size, addr = gvar:sizeof()
table.insert(globals, {
name = name,
first = addr,
last = addr + size - 1
})
end
table.sort(globals, function(a, b)
return a.first < b.first
end)
for i = 2, #globals do
local prev = globals[i - 1]
local cur = globals[i]
expect.lt(prev.last, cur.first, "global variable " .. prev.name .. " overlaps global variable " .. cur.name)
end
end
local known_bad_types = {
-- renderer base class has non-destructible padding declared
renderer_2d_base=true,
renderer_2d=true,
renderer_offscreen=true,
-- abstract base classes that aren't instantiable
active_script_varst=true,
widget_sheet_button=true,
}
if dfhack.getOSType() == 'linux' then
-- empty destructors are declared inline for these types,
-- and gcc appears to optimize them out
known_bad_types.mental_picture_propertyst = true
known_bad_types.region_block_eventst = true
end
function test.destructors()
local count = 1
for name, type in pairs(df) do
if known_bad_types[name] then
goto continue
end
print(('testing constructor %5d: %s'):format(count, name))
local ok, v = pcall(function() return type:new() end)
if not ok then
print(' constructor failed; skipping destructor test')
else
print(' destructor ok')
expect.true_(v:delete(), "destructor returned false: " .. name)
end
count = count + 1
::continue::
end
end