forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobals.lua
More file actions
32 lines (26 loc) · 1.13 KB
/
Copy pathglobals.lua
File metadata and controls
32 lines (26 loc) · 1.13 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
config.target = 'core'
local function with_temp_global_address(name, addr, callback, ...)
dfhack.call_with_finalizer(2, true,
dfhack.internal.setAddress, name, dfhack.internal.getAddress(name),
function(...)
dfhack.internal.setAddress(name, addr)
callback(...)
end, ...)
end
function test.unknown_global_address()
expect.ne(dfhack.internal.getAddress('army_next_id'), 0)
local old_id = df.global.army_next_id
with_temp_global_address('army_next_id', 0, function()
expect.error_match('Cannot read field global.army_next_id: global address not known.', function()
local _ = df.global.army_next_id
end)
expect.error_match('Cannot write field global.army_next_id: global address not known.', function()
df.global.army_next_id = old_id
end)
expect.error_match('Cannot reference field global.army_next_id: global address not known.', function()
local _ = df.global:_field('army_next_id')
end)
end)
expect.gt(dfhack.internal.getAddress('army_next_id'), 0)
expect.eq(df.global.army_next_id, old_id)
end