Skip to content

Commit 5f791a6

Browse files
authored
Merge branch 'develop' into sdl_console
2 parents 6e7ed2a + e1ae82d commit 5f791a6

4 files changed

Lines changed: 51 additions & 2 deletions

File tree

library/xml

scripts

test/modules/job.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local utils = require('utils')
2+
13
config.target = 'core'
24
config.mode = 'title' -- alters world state, not safe when a world is loaded
35

@@ -17,3 +19,28 @@ function test.removeJob()
1719
expect.true_(dfhack.job.removeJob(job))
1820
expect.nil_(df.global.world.jobs.list.next, 'job list is not empty after removeJob()')
1921
end
22+
23+
-- EventManager job completion handling expects sorted order
24+
function test.jobIDsAreSortedAfterAdd()
25+
local job1 = df.job:new()
26+
dfhack.job.linkIntoWorld(job1)
27+
28+
local job2 = df.job:new()
29+
dfhack.job.linkIntoWorld(job2)
30+
31+
local is_sorted = true
32+
local prev_id = nil
33+
34+
for _, job in utils.listpairs(df.global.world.jobs.list) do
35+
if prev_id and job.id < prev_id then
36+
is_sorted = false
37+
break
38+
end
39+
prev_id = job.id
40+
end
41+
42+
dfhack.job.removeJob(job1)
43+
dfhack.job.removeJob(job2)
44+
45+
expect.true_(is_sorted)
46+
end

test/modules/job_fortress.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
local utils = require('utils')
2+
3+
config.target = 'core'
4+
config.mode = 'fortress'
5+
6+
-- EventManager job completion handling expects sorted order
7+
function test.jobIDsAreSorted()
8+
local is_sorted = true
9+
local prev_id = nil
10+
11+
-- assumes there are at least some "naturally added" jobs currently in the list
12+
-- but this should always be true for CI test saves
13+
for _, job in utils.listpairs(df.global.world.jobs.list) do
14+
if prev_id and job.id < prev_id then
15+
is_sorted = false
16+
break
17+
end
18+
prev_id = job.id
19+
end
20+
21+
expect.true_(is_sorted)
22+
end

0 commit comments

Comments
 (0)