|
|
@ -153,20 +153,43 @@ function test.numberList()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function test.coords()
|
|
|
|
function test.coords()
|
|
|
|
expect.table_eq({x=0, y=4, z=3}, argparse.coords('0,4 , 3'), 'happy path')
|
|
|
|
mock.patch(dfhack.maps, "isValidTilePos", mock.func(true),
|
|
|
|
|
|
|
|
|
|
|
|
expect.error_match('expected non%-negative integer',
|
|
|
|
|
|
|
|
function() argparse.coords('1,-2,3') end,
|
|
|
|
|
|
|
|
'negative coordinate')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mock.patch(guidm, 'getCursorPos', mock.func({x=1, y=2, z=3}),
|
|
|
|
|
|
|
|
function()
|
|
|
|
function()
|
|
|
|
expect.table_eq({x=1, y=2, z=3}, argparse.coords('here'))
|
|
|
|
expect.table_eq({x=0, y=4, z=3}, argparse.coords('0,4 , 3'),
|
|
|
|
|
|
|
|
'happy path')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect.error_match('expected non%-negative integer',
|
|
|
|
|
|
|
|
function() argparse.coords('1,-2,3') end,
|
|
|
|
|
|
|
|
'negative coordinate')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mock.patch(guidm, 'getCursorPos', mock.func({x=1, y=2, z=3}),
|
|
|
|
|
|
|
|
function()
|
|
|
|
|
|
|
|
expect.table_eq({x=1, y=2, z=3}, argparse.coords('here'))
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
mock.patch(guidm, 'getCursorPos', mock.func(),
|
|
|
|
|
|
|
|
function()
|
|
|
|
|
|
|
|
expect.error_match('cursor is not active',
|
|
|
|
|
|
|
|
function() argparse.coords('here') end,
|
|
|
|
|
|
|
|
'inactive cursor')
|
|
|
|
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
mock.patch(guidm, 'getCursorPos', mock.func(),
|
|
|
|
|
|
|
|
|
|
|
|
mock.patch(dfhack.maps, "isValidTilePos", mock.func(false),
|
|
|
|
function()
|
|
|
|
function()
|
|
|
|
expect.error_match('cursor is not active',
|
|
|
|
expect.error_match('not on current map',
|
|
|
|
function() argparse.coords('here') end,
|
|
|
|
function() argparse.coords('0,4,300') end)
|
|
|
|
'inactive cursor')
|
|
|
|
expect.table_eq({x=0, y=4, z=300},
|
|
|
|
|
|
|
|
argparse.coords('0,4,300', nil, true))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mock.patch(guidm, 'getCursorPos', mock.func({x=1, y=2, z=300}),
|
|
|
|
|
|
|
|
function()
|
|
|
|
|
|
|
|
expect.error_match('not on current map',
|
|
|
|
|
|
|
|
function() argparse.coords('here') end)
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
mock.patch(guidm, 'getCursorPos', mock.func({x=1, y=2, z=300}),
|
|
|
|
|
|
|
|
function()
|
|
|
|
|
|
|
|
expect.table_eq({x=1, y=2, z=300},
|
|
|
|
|
|
|
|
argparse.coords('here', nil, true))
|
|
|
|
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|