mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
test(screen): adjust screen state per stylua #31441
Before: screen:expect({ | screen:expect({ grid = [[ | grid = [[ {10:>!}a | | line ^1 | {7: }b | | {1:~ }|*4 {10:>>}c | | ]], messages={ { {7: }^ | | content = { { "\ntest\n[O]k: ", 6, 11 } }, {1:~ }|*9 | kind = "confirm" | | } } ]] | }) }) After: screen:expect([[ | screen:expect({ {10:>!}a | | grid = [[ {7: }b | | line ^1 | {10:>>}c | | {1:~ }|*4 {7: }^ | | ]], {1:~ }|*9 | messages = { { | | content = { { "\ntest\n[O]k: ", 6, 11 } }, ]]) | kind = "confirm" | } }, | })
This commit is contained in:
parent
6551e30630
commit
e2a91876ac
@ -404,7 +404,7 @@ describe('treesitter highlighting (C)', function()
|
||||
]],
|
||||
})
|
||||
|
||||
feed 'u'
|
||||
feed 'u:<esc>'
|
||||
|
||||
screen:expect({
|
||||
grid = [[
|
||||
@ -425,7 +425,7 @@ describe('treesitter highlighting (C)', function()
|
||||
} |
|
||||
} |
|
||||
^} |
|
||||
19 changes; before #2 0 seconds ago |
|
||||
|
|
||||
]],
|
||||
})
|
||||
end)
|
||||
|
@ -37,10 +37,10 @@
|
||||
-- Tests will often share a group of extra attribute sets to expect(). Those can be
|
||||
-- defined at the beginning of a test:
|
||||
--
|
||||
-- screen:add_extra_attr_ids {
|
||||
-- screen:add_extra_attr_ids({
|
||||
-- [100] = { background = Screen.colors.Plum1, underline = true },
|
||||
-- [101] = { background = Screen.colors.Red1, bold = true, underline = true },
|
||||
-- }
|
||||
-- })
|
||||
--
|
||||
-- To help write screen tests, see Screen:snapshot_util().
|
||||
-- To debug screen tests, see Screen:redraw_debug().
|
||||
@ -454,7 +454,7 @@ end
|
||||
--- screen:expect(grid, [attr_ids])
|
||||
--- screen:expect(condition)
|
||||
--- or keyword args (supports more options):
|
||||
--- screen:expect{grid=[[...]], cmdline={...}, condition=function() ... end}
|
||||
--- screen:expect({ grid=[[...]], cmdline={...}, condition=function() ... end })
|
||||
---
|
||||
--- @param expected string|function|test.function.ui.screen.Expect
|
||||
--- @param attr_ids? table<integer,table<string,any>>
|
||||
@ -1713,21 +1713,24 @@ function Screen:_print_snapshot()
|
||||
end
|
||||
end
|
||||
local fn_name = modify_attrs and 'add_extra_attr_ids' or 'set_default_attr_ids'
|
||||
attrstr = ('screen:' .. fn_name .. ' {\n' .. table.concat(attrstrs, '\n') .. '\n}\n\n')
|
||||
attrstr = ('screen:' .. fn_name .. '({\n' .. table.concat(attrstrs, '\n') .. '\n})\n\n')
|
||||
end
|
||||
|
||||
local result = ('%sscreen:expect({\n grid = [[\n %s\n ]]'):format(
|
||||
attrstr,
|
||||
kwargs.grid:gsub('\n', '\n ')
|
||||
)
|
||||
local extstr = ''
|
||||
for _, k in ipairs(ext_keys) do
|
||||
if ext_state[k] ~= nil and not (k == 'win_viewport' and not self.options.ext_multigrid) then
|
||||
result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k])
|
||||
extstr = extstr .. '\n ' .. k .. ' = ' .. fmt_ext_state(k, ext_state[k]) .. ','
|
||||
end
|
||||
end
|
||||
result = result .. '\n})'
|
||||
|
||||
return result
|
||||
return ('%sscreen:expect(%s%s%s%s%s'):format(
|
||||
attrstr,
|
||||
#extstr > 0 and '{\n grid = [[\n ' or '[[\n',
|
||||
#extstr > 0 and kwargs.grid:gsub('\n', '\n ') or kwargs.grid,
|
||||
#extstr > 0 and '\n ]],' or '\n]]',
|
||||
extstr,
|
||||
#extstr > 0 and '\n})' or ')'
|
||||
)
|
||||
end
|
||||
|
||||
function Screen:print_snapshot()
|
||||
|
Loading…
Reference in New Issue
Block a user