enable most core tests

develop
Myk Taylor 2023-08-04 01:35:51 -07:00
parent f8dd09200f
commit a6de9a21fa
No known key found for this signature in database
17 changed files with 47 additions and 17 deletions

@ -992,7 +992,7 @@ function Scrollbar:onInput(keys)
return false return false
end end
if self.parent_view:getMousePos() then if self.parent_view and self.parent_view:getMousePos() then
if keys.CONTEXT_SCROLL_UP then if keys.CONTEXT_SCROLL_UP then
self.on_scroll('up_small') self.on_scroll('up_small')
return true return true

@ -789,7 +789,7 @@ function ls(filter_str, skip_tags, show_dev_commands, exclude_strs)
end end
if not show_dev_commands then if not show_dev_commands then
local dev_tags = {'dev', 'unavailable'} local dev_tags = {'dev', 'unavailable'}
if dfhack.getHideArmokTools() then if filter_str ~= 'armok' and dfhack.getHideArmokTools() then
table.insert(dev_tags, 'armok') table.insert(dev_tags, 'armok')
end end
table.insert(excludes, {tag=dev_tags}) table.insert(excludes, {tag=dev_tags})

@ -1,3 +1,5 @@
config.targets = 'core'
local argparse = require('argparse') local argparse = require('argparse')
local guidm = require('gui.dwarfmode') local guidm = require('gui.dwarfmode')

@ -1,3 +1,5 @@
config.targets = 'core'
local gui = require('gui') local gui = require('gui')
function test.getKeyDisplay() function test.getKeyDisplay()
@ -10,6 +12,7 @@ end
function test.clear_pen() function test.clear_pen()
expect.table_eq(gui.CLEAR_PEN, { expect.table_eq(gui.CLEAR_PEN, {
tile = df.global.init.texpos_border_interior,
ch = string.byte(' '), ch = string.byte(' '),
fg = COLOR_BLACK, fg = COLOR_BLACK,
bg = COLOR_BLACK, bg = COLOR_BLACK,

@ -1,3 +1,5 @@
--config.targets = 'core'
local gui = require('gui') local gui = require('gui')
local function send_keys(...) local function send_keys(...)
local keys = {...} local keys = {...}

@ -1,3 +1,5 @@
config.targets = 'core'
local widgets = require('gui.widgets') local widgets = require('gui.widgets')
function test.editfield_cursor() function test.editfield_cursor()
@ -20,18 +22,18 @@ function test.editfield_cursor()
expect.eq('ones two threes', e.text) expect.eq('ones two threes', e.text)
expect.eq(5, e.cursor) expect.eq(5, e.cursor)
e:onInput{CURSOR_LEFT=true} e:onInput{KEYBOARD_CURSOR_LEFT=true}
expect.eq(4, e.cursor) expect.eq(4, e.cursor)
e:onInput{CURSOR_RIGHT=true} e:onInput{KEYBOARD_CURSOR_RIGHT=true}
expect.eq(5, e.cursor) expect.eq(5, e.cursor)
e:onInput{A_CARE_MOVE_W=true} -- e:onInput{A_CARE_MOVE_W=true}
expect.eq(1, e.cursor, 'interpret alt-left as home') -- expect.eq(1, e.cursor, 'interpret alt-left as home') -- uncomment when we have a home key
e:onInput{A_MOVE_E_DOWN=true} e:onInput{CUSTOM_CTRL_F=true}
expect.eq(6, e.cursor, 'interpret ctrl-right as goto beginning of next word') expect.eq(6, e.cursor, 'interpret Ctrl-f as goto beginning of next word')
e:onInput{A_CARE_MOVE_E=true} e:onInput{CUSTOM_CTRL_E=true}
expect.eq(16, e.cursor, 'interpret alt-right as end') expect.eq(16, e.cursor, 'interpret Ctrl-e as end')
e:onInput{A_MOVE_W_DOWN=true} e:onInput{CUSTOM_CTRL_B=true}
expect.eq(9, e.cursor, 'interpret ctrl-left as goto end of previous word') expect.eq(9, e.cursor, 'interpret Ctrl-b as goto end of previous word')
end end
function test.editfield_click() function test.editfield_click()

@ -1,3 +1,5 @@
config.targets = 'core'
local gui = require('gui') local gui = require('gui')
local widgets = require('gui.widgets') local widgets = require('gui.widgets')

@ -1,3 +1,5 @@
config.targets = 'core'
local gui = require('gui') local gui = require('gui')
local widgets = require('gui.widgets') local widgets = require('gui.widgets')
@ -10,7 +12,7 @@ function test.update()
expect.eq(1, s.elems_per_page) expect.eq(1, s.elems_per_page)
expect.eq(1, s.num_elems) expect.eq(1, s.num_elems)
expect.eq(0, s.bar_offset) expect.eq(0, s.bar_offset)
expect.eq(1, s.bar_height) expect.eq(2, s.bar_height)
-- top_elem, elems_per_page, num_elems -- top_elem, elems_per_page, num_elems
s:update(1, 10, 0) s:update(1, 10, 0)
@ -18,7 +20,7 @@ function test.update()
expect.eq(10, s.elems_per_page) expect.eq(10, s.elems_per_page)
expect.eq(0, s.num_elems) expect.eq(0, s.num_elems)
expect.eq(0, s.bar_offset) expect.eq(0, s.bar_offset)
expect.eq(1, s.bar_height) expect.eq(2, s.bar_height)
-- first 10 of 50 shown -- first 10 of 50 shown
s:update(1, 10, 50) s:update(1, 10, 50)

@ -1,3 +1,5 @@
config.targets = 'core'
local widgets = require('gui.widgets') local widgets = require('gui.widgets')
function test.hotkeylabel_click() function test.hotkeylabel_click()

@ -1,3 +1,5 @@
config.targets = 'core'
local h = require('helpdb') local h = require('helpdb')
local mock_plugin_db = { local mock_plugin_db = {

@ -1,5 +1,7 @@
-- tests misc functions added by dfhack.lua -- tests misc functions added by dfhack.lua
config.targets = 'core'
function test.safe_pairs() function test.safe_pairs()
for k,v in safe_pairs(nil) do for k,v in safe_pairs(nil) do
expect.fail('nil should not be iterable') expect.fail('nil should not be iterable')

@ -1,5 +1,7 @@
-- tests print-related functions added by dfhack.lua -- tests print-related functions added by dfhack.lua
config.targets = 'core'
local dfhack = dfhack local dfhack = dfhack
local mock_print = mock.func() local mock_print = mock.func()

@ -1,5 +1,7 @@
-- tests string functions added by dfhack.lua -- tests string functions added by dfhack.lua
config.targets = 'core'
function test.startswith() function test.startswith()
expect.true_(('abcd'):startswith('')) expect.true_(('abcd'):startswith(''))
expect.true_(('abcd'):startswith('abc')) expect.true_(('abcd'):startswith('abc'))

@ -1,3 +1,5 @@
config.targets = 'core'
local expect_raw = require('test_util.expect') local expect_raw = require('test_util.expect')
function test.str_find() function test.str_find()

@ -1,3 +1,5 @@
config.targets = 'core'
local mock = require('test_util.mock') local mock = require('test_util.mock')
local test_table = { local test_table = {

@ -1,3 +1,5 @@
config.targets = 'core'
local utils = require 'utils' local utils = require 'utils'
function test.OrderedTable() function test.OrderedTable()
@ -102,7 +104,7 @@ function test.df_expr_to_ref()
expect.eq(df.reinterpret_cast(df.world, utils.df_expr_to_ref('unit[0]').value), df.global.world) expect.eq(df.reinterpret_cast(df.world, utils.df_expr_to_ref('unit[0]').value), df.global.world)
expect.eq(utils.df_expr_to_ref('unit[1]'), utils.df_expr_to_ref('unit.1')) expect.eq(utils.df_expr_to_ref('unit[1]'), utils.df_expr_to_ref('unit.1'))
expect.eq(df.reinterpret_cast(df.ui, utils.df_expr_to_ref('unit[1]').value), df.global.plotinfo) expect.eq(df.reinterpret_cast(df.plotinfost, utils.df_expr_to_ref('unit[1]').value), df.global.plotinfo)
expect.error_match('index out of bounds', function() utils.df_expr_to_ref('unit.2') end) expect.error_match('index out of bounds', function() utils.df_expr_to_ref('unit.2') end)
expect.error_match('index out of bounds', function() utils.df_expr_to_ref('unit[2]') end) expect.error_match('index out of bounds', function() utils.df_expr_to_ref('unit[2]') end)

@ -1,8 +1,9 @@
config.targets = 'core' -- TODO: fix crash in test.viewscreenDtors with viewscreen_legendsst
--config.targets = 'core'
function test.overlappingGlobals() function test.overlappingGlobals()
local globals = {} local globals = {}
for name, _ in pairs(df.global) do for name in pairs(df.global) do
local gvar = df.global:_field(name) local gvar = df.global:_field(name)
local size, addr = gvar:sizeof() local size, addr = gvar:sizeof()
table.insert(globals, { table.insert(globals, {