Merge pull request #18681 from bfredl/uitest

fix(tests): fix some screen.lua warnings
This commit is contained in:
bfredl 2022-05-22 14:32:38 +02:00 committed by GitHub
commit e7b3fd8ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 25 deletions

View File

@ -23,7 +23,7 @@ describe('prompt buffer', function()
close close
else else
call append(line("$") - 1, 'Command: "' . a:text . '"') call append(line("$") - 1, 'Command: "' . a:text . '"')
set nomodfied set nomodified
call timer_start(20, {id -> TimerFunc(a:text)}) call timer_start(20, {id -> TimerFunc(a:text)})
endif endif
endfunc endfunc
@ -33,7 +33,7 @@ describe('prompt buffer', function()
endfunc endfunc
func SwitchWindows() func SwitchWindows()
call timer_start(0, {-> execute("wincmd p|wincmd p", "")}) call timer_start(0, {-> execute("wincmd p", "")})
endfunc endfunc
]]) ]])
feed_command("set noshowmode | set laststatus=0") feed_command("set noshowmode | set laststatus=0")
@ -187,7 +187,19 @@ describe('prompt buffer', function()
-- INSERT -- | -- INSERT -- |
]]) ]])
feed("<C-O>:call SwitchWindows()<CR>") feed("<C-O>:call SwitchWindows()<CR>")
poke_eventloop() screen:expect{grid=[[
cmd: |
~ |
~ |
~ |
[Prompt] [+] |
^other buffer |
~ |
~ |
~ |
|
]]}
feed("<C-O>:call SwitchWindows()<CR>")
screen:expect([[ screen:expect([[
cmd: ^ | cmd: ^ |
~ | ~ |
@ -201,7 +213,6 @@ describe('prompt buffer', function()
-- INSERT -- | -- INSERT -- |
]]) ]])
feed("<Esc>") feed("<Esc>")
poke_eventloop()
screen:expect([[ screen:expect([[
cmd:^ | cmd:^ |
~ | ~ |

View File

@ -564,6 +564,16 @@ describe('Buffer highlighting', function()
]] ]]
clear_namespace(id, 0, -1) clear_namespace(id, 0, -1)
screen:expect{grid=[[
fooba^r |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]]}
set_extmark(id, 0, 0, { set_extmark(id, 0, 0, {
end_line = 0, end_line = 0,

View File

@ -1227,7 +1227,6 @@ describe('ui/ext_messages', function()
it('supports global statusline', function() it('supports global statusline', function()
feed(":set laststatus=3<cr>") feed(":set laststatus=3<cr>")
feed(":sp<cr>") feed(":sp<cr>")
feed("<c-l>")
feed(":set cmdheight<cr>") feed(":set cmdheight<cr>")
screen:expect({grid=[[ screen:expect({grid=[[
^ | ^ |
@ -1259,8 +1258,7 @@ describe('ui/ext_messages', function()
}}) }})
feed("<c-w>+") feed("<c-w>+")
feed("<c-l>") feed(":set laststatus<cr>")
feed(":set cmdheight<cr>")
screen:expect({grid=[[ screen:expect({grid=[[
^ | ^ |
{1:~ }| {1:~ }|
@ -1287,7 +1285,7 @@ describe('ui/ext_messages', function()
{1:~ }| {1:~ }|
{7:[No Name] }| {7:[No Name] }|
]], messages={ ]], messages={
{content = { { " cmdheight=0" } }, kind = "" } {content = { { " laststatus=3" } }, kind = "" }
}}) }})
feed(":set mouse=a<cr>") feed(":set mouse=a<cr>")

View File

@ -43,7 +43,7 @@ describe('search highlighting', function()
insert("some text\nmore text") insert("some text\nmore text")
feed_command('1,2fold') feed_command('1,2fold')
feed("gg/text") feed("gg/text")
screen:expect([[ screen:expect{grid=[[
{6:+-- 2 lines: some text·················}| {6:+-- 2 lines: some text·················}|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
@ -51,7 +51,9 @@ describe('search highlighting', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
/text^ | /text^ |
]]) ]], win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 9, linecount = 2};
}}
end) end)
it('works', function() it('works', function()
@ -579,19 +581,20 @@ describe('search highlighting', function()
end) end)
it('works with matchadd and syntax', function() it('works with matchadd and syntax', function()
screen:set_default_attr_ids( { screen:set_default_attr_ids {
[1] = {bold=true, foreground=Screen.colors.Blue}, [1] = {bold=true, foreground=Screen.colors.Blue};
[2] = {background = colors.Yellow}, [2] = {background = colors.Yellow};
[3] = {reverse = true}, [3] = {reverse = true};
[4] = {foreground = colors.Red}, [4] = {foreground = colors.Red};
[5] = {bold = true, background = colors.Green}, [5] = {bold = true, background = colors.Green};
[6] = {italic = true, background = colors.Magenta}, [6] = {italic = true, background = colors.Magenta};
[7] = {bold = true, background = colors.Yellow}, [7] = {bold = true, background = colors.Yellow};
} ) [8] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGray};
}
feed_command('set hlsearch') feed_command('set hlsearch')
insert([[ insert [[
very special text very special text
]]) ]]
feed_command("syntax on") feed_command("syntax on")
feed_command("highlight MyGroup guibg=Green gui=bold") feed_command("highlight MyGroup guibg=Green gui=bold")
feed_command("highlight MyGroup2 guibg=Magenta gui=italic") feed_command("highlight MyGroup2 guibg=Magenta gui=italic")
@ -601,7 +604,7 @@ describe('search highlighting', function()
-- searchhl and matchadd matches are exclusive, only the highest priority -- searchhl and matchadd matches are exclusive, only the highest priority
-- is used (and matches with lower priorities are not combined) -- is used (and matches with lower priorities are not combined)
feed_command("/ial te") feed_command("/ial te")
screen:expect([[ screen:expect{grid=[[
very {5:spec^ial}{2: te}{6:xt} | very {5:spec^ial}{2: te}{6:xt} |
| |
{1:~ }| {1:~ }|
@ -609,10 +612,21 @@ describe('search highlighting', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{4:search hit BOTTOM, continuing at TOP} | {4:search hit BOTTOM, continuing at TOP} |
]]) ]], win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 11, linecount = 2};
}}
-- check highlights work also in folds -- check highlights work also in folds
feed("zf4j") feed("zf4j")
screen:expect{grid=[[
{8:^+-- 2 lines: very special text·········}|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{4:search hit BOTTOM, continuing at TOP} |
]]}
command("%foldopen") command("%foldopen")
screen:expect([[ screen:expect([[
very {5:spec^ial}{2: te}{6:xt} | very {5:spec^ial}{2: te}{6:xt} |

View File

@ -153,7 +153,7 @@ describe('execute()', function()
function! Test3() function! Test3()
echo 1234 echo 1234
let x = execute('echoerr "abcdef"', 'silent!') let x = execute('echoerr "abcdef"', 'silent!')
echon 'ABCD' echon 'ABCDXZYZ'
endfunction endfunction
" test 4: silenced echoerr goes as usual " test 4: silenced echoerr goes as usual
@ -214,7 +214,7 @@ describe('execute()', function()
~ | ~ |
~ | ~ |
~ | ~ |
1234ABCD | 1234ABCDXZYZ |
]]) ]])
feed([[:call Test4()<cr>]]) feed([[:call Test4()<cr>]])