forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulticmd.lua
More file actions
47 lines (38 loc) · 1.26 KB
/
multicmd.lua
File metadata and controls
47 lines (38 loc) · 1.26 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
-- use the quickfort script as a guinnea pig so we can easily intercept
-- its output and detect how many times it was run
local quickfort = reqscript('quickfort')
local mock_print
local function test_wrapper(test_fn)
mock_print = mock.func()
mock.patch(quickfort, 'print', mock_print, test_fn)
end
config.wrapper = test_wrapper
function test.empty()
dfhack.run_script('multicmd')
expect.eq(0, mock_print.call_count)
end
function test.single()
dfhack.run_script('multicmd', 'quickfort')
expect.eq(1, mock_print.call_count)
end
function test.double_no_spaces()
dfhack.run_script('multicmd', 'quickfort;quickfort')
expect.eq(2, mock_print.call_count)
end
function test.double_space_after()
dfhack.run_script('multicmd', 'quickfort; quickfort')
expect.eq(2, mock_print.call_count)
end
function test.double_space_before_and_after()
dfhack.run_script('multicmd', 'quickfort ; quickfort')
expect.eq(2, mock_print.call_count)
end
function test.adjacent_semicolons()
dfhack.run_script('multicmd', 'quickfort;;;quickfort')
expect.eq(2, mock_print.call_count)
end
function test.long_chain()
dfhack.run_script('multicmd',
'quickfort;quickfort;quickfort;quickfort')
expect.eq(4, mock_print.call_count)
end