aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-09 20:42:00 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-12-09 22:15:02 +0800
commit1037ce2e461034a20e35ad59969fd05d5ad68b91 (patch)
tree5cc490afac4607008bacf24d132015b63adfd1d0 /test/functional/api
parent5e43630a260e49ed494539d41cb832b1ee6d03c8 (diff)
downloadrneovim-1037ce2e461034a20e35ad59969fd05d5ad68b91.tar.gz
rneovim-1037ce2e461034a20e35ad59969fd05d5ad68b91.tar.bz2
rneovim-1037ce2e461034a20e35ad59969fd05d5ad68b91.zip
test: avoid repeated screen lines in expected states
This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/buffer_spec.lua70
-rw-r--r--test/functional/api/extmark_spec.lua42
-rw-r--r--test/functional/api/vim_spec.lua137
-rw-r--r--test/functional/api/window_spec.lua56
4 files changed, 66 insertions, 239 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index 6ed9aa574a..db910545ef 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -170,10 +170,7 @@ describe('api/buf', function()
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
www |
xxx |
@@ -186,10 +183,7 @@ describe('api/buf', function()
meths.buf_set_lines(buf, 0, 2, true, {"aaabbb"})
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
www |
xxx |
@@ -203,10 +197,7 @@ describe('api/buf', function()
meths.buf_set_lines(buf, 3, 4, true, {"wwweeee"})
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
wwweeee |
xxx |
@@ -220,10 +211,7 @@ describe('api/buf', function()
meths.buf_set_lines(buf, 3, 3, true, {"mmm"})
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
wwweeee |
xxx |
@@ -236,10 +224,7 @@ describe('api/buf', function()
meths.win_set_cursor(0, {7, 0})
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
wwweeee |
xxx |
@@ -252,10 +237,7 @@ describe('api/buf', function()
meths.buf_set_lines(buf, 4, 4, true, {"mmmeeeee"})
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
mmmeeeee |
wwweeee |
@@ -275,10 +257,7 @@ describe('api/buf', function()
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{2:[No Name] }|
www |
xxx |
@@ -291,10 +270,7 @@ describe('api/buf', function()
meths.buf_set_lines(buf, 0, 2, true, {"aaabbb"})
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{2:[No Name] }|
www |
xxx |
@@ -308,10 +284,7 @@ describe('api/buf', function()
meths.buf_set_lines(buf, 3, 4, true, {"wwweeee"})
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{2:[No Name] }|
wwweeee |
xxx |
@@ -325,10 +298,7 @@ describe('api/buf', function()
meths.buf_set_lines(buf, 3, 3, true, {"mmm"})
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{2:[No Name] }|
mmm |
wwweeee |
@@ -1690,10 +1660,7 @@ describe('api/buf', function()
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
www |
xxx |
@@ -1706,10 +1673,7 @@ describe('api/buf', function()
screen:expect{grid=[[
|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{3:[No Name] }|
www |
xxx |
@@ -1729,10 +1693,7 @@ describe('api/buf', function()
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{2:[No Name] }|
www |
xxx |
@@ -1745,10 +1706,7 @@ describe('api/buf', function()
meths.buf_set_text(buf, 0,3, 1,0, {"X"})
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*4
{2:[No Name] }|
www |
xxx |
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 8bfb0effba..facabee7a4 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -435,14 +435,7 @@ describe('API/extmarks', function()
-- This shouldn't seg fault
screen:expect([[
12345^ 1 |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
+ ~ |*8
|
]])
end)
@@ -495,14 +488,7 @@ describe('API/extmarks', function()
insert('abc')
screen:expect([[
ab^c12345 |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
+ ~ |*8
|
]])
local rv = get_extmark_by_id(ns, marks[1])
@@ -1635,11 +1621,8 @@ describe('API/extmarks', function()
command('d2')
screen:expect([[
S2^aaa bbb ccc |
- aaa bbb ccc |
- aaa bbb ccc |
- aaa bbb ccc |
- |
- |
+ aaa bbb ccc |*3
+ |*2
]])
-- mark is restored with undo_restore == true
command('silent undo')
@@ -1647,8 +1630,7 @@ describe('API/extmarks', function()
S1 ^aaa bbb ccc |
S1S2aaa bbb ccc |
S2 aaa bbb ccc |
- aaa bbb ccc |
- aaa bbb ccc |
+ aaa bbb ccc |*2
|
]])
-- mark is deleted with undo_restore == false
@@ -1923,12 +1905,9 @@ describe('API/win_extmark', function()
screen:expect({
grid = [[
## grid 1
- [4:--------------------]|
- [4:--------------------]|
- [4:--------------------]|
+ [4:--------------------]|*3
[No Name] [+] |
- [2:--------------------]|
- [2:--------------------]|
+ [2:--------------------]|*2
[No Name] [+] |
[3:--------------------]|
## grid 2
@@ -1959,12 +1938,9 @@ describe('API/win_extmark', function()
screen:expect({
grid = [[
## grid 1
- [4:--------------------]|
- [4:--------------------]|
- [4:--------------------]|
+ [4:--------------------]|*3
[No Name] [+] |
- [2:--------------------]|
- [2:--------------------]|
+ [2:--------------------]|*2
[No Name] [+] |
[3:--------------------]|
## grid 2
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 7a3116cba5..3d3b478d66 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -285,12 +285,7 @@ describe('API', function()
meths.exec2("echo 'hello'", { output = false })
screen:expect{grid=[[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*6
hello |
]]}
end)
@@ -304,10 +299,7 @@ describe('API', function()
meths.exec2("echo 'hello'", { output = true })
screen:expect{grid=[[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*4
|
]]}
exec([[
@@ -318,10 +310,7 @@ describe('API', function()
feed([[:echon 1 | call Print() | echon 5<CR>]])
screen:expect{grid=[[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*4
15 |
]]}
end)
@@ -1140,8 +1129,7 @@ describe('API', function()
nvim('paste', '', true, 3)
screen:expect([[
|
- ~ |
- ~ |
+ ~ |*2
:Foo^ |
]])
end)
@@ -1152,8 +1140,7 @@ describe('API', function()
nvim('paste', 'normal! \023\022\006\027', true, -1)
screen:expect([[
|
- ~ |
- ~ |
+ ~ |*2
:normal! ^W^V^F^[^ |
]])
end)
@@ -2106,9 +2093,7 @@ describe('API', function()
feed([[:call nvim_out_write("\na\n")<CR>]])
screen:expect{grid=[[
|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*3
{2: }|
|
a |
@@ -2118,8 +2103,7 @@ describe('API', function()
feed([[:call nvim_out_write("b\n\nc\n")<CR>]])
screen:expect{grid=[[
|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
{2: }|
b |
|
@@ -2132,9 +2116,7 @@ describe('API', function()
feed([[:lua vim.api.nvim_out_write('aaa\0bbb\0\0ccc\nddd\0\0\0eee\n')<CR>]])
screen:expect{grid=[[
|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*3
{2: }|
aaa{3:^@}bbb{3:^@^@}ccc |
ddd{3:^@^@^@}eee |
@@ -2161,12 +2143,7 @@ describe('API', function()
nvim_async('err_write', 'has bork\n')
screen:expect([[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*6
{1:has bork} |
]])
end)
@@ -2175,9 +2152,7 @@ describe('API', function()
nvim_async('err_write', 'something happened\nvery bad\n')
screen:expect([[
|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*3
{3: }|
{1:something happened} |
{1:very bad} |
@@ -2205,12 +2180,7 @@ describe('API', function()
nvim_async('err_write', 'fail\n')
screen:expect([[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*6
{1:very fail} |
]])
helpers.poke_eventloop()
@@ -2219,9 +2189,7 @@ describe('API', function()
nvim_async('err_write', 'more fail\ntoo fail\n')
screen:expect([[
|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*3
{3: }|
{1:more fail} |
{1:too fail} |
@@ -2234,9 +2202,7 @@ describe('API', function()
nvim_async('err_write', 'aaa\0bbb\0\0ccc\nddd\0\0\0eee\n')
screen:expect{grid=[[
|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*3
{3: }|
{1:aaa^@bbb^@^@ccc} |
{1:ddd^@^@^@eee} |
@@ -2274,12 +2240,7 @@ describe('API', function()
feed('<CR>')
screen:expect([[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*6
|
]])
end)
@@ -2859,8 +2820,7 @@ describe('API', function()
meths.set_current_buf(2)
screen:expect([[
^some text |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
]], {
[1] = {bold = true, foreground = Screen.colors.Blue1},
@@ -2937,8 +2897,7 @@ describe('API', function()
meths.set_current_buf(edited_buf)
screen:expect([[
^some text |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
]])
eq('nofile', meths.get_option_value('buftype', {buf=edited_buf}))
@@ -2950,8 +2909,7 @@ describe('API', function()
command('bwipe')
screen:expect([[
^ |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
]])
end)
@@ -3229,12 +3187,7 @@ describe('API', function()
feed(':call nvim_echo([["msg"]], v:false, {})<CR>')
screen:expect{grid=[[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*6
msg |
]]}
end)
@@ -3243,12 +3196,7 @@ describe('API', function()
nvim_async("echo", {{"msg_a"}, {"msg_b", "Statement"}, {"msg_c", "Special"}}, true, {})
screen:expect{grid=[[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*6
msg_a{3:msg_b}{4:msg_c} |
]]}
end)
@@ -3257,9 +3205,7 @@ describe('API', function()
nvim_async("echo", {{"msg_a\nmsg_a", "Statement"}, {"msg_b", "Special"}}, true, {})
screen:expect{grid=[[
|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*3
{2: }|
{3:msg_a} |
{3:msg_a}{4:msg_b} |
@@ -3338,8 +3284,7 @@ describe('API', function()
{0:~}{3:Press ENTER or type command to continue}{1: }{0: }|
{0:~}{4:term://~/config2/docs/pres//32693:vim --clean +smile 29,39 All}{0: }|
{0:~}{1::call nvim__screenshot("smile2.cat") }{0: }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
|
]]}
end)
@@ -3367,13 +3312,8 @@ describe('API', function()
screen:expect{grid=[[
|
{0:~}{1:^ }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~}{1: }{0: }|*4
+ {0:~ }|*3
|
]]}
@@ -3381,13 +3321,8 @@ describe('API', function()
screen:expect{grid=[[
|
{0:~}{7: }{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~}{1: }{0: }|*4
+ {0:~ }|*3
{6:-- TERMINAL --} |
]]}
@@ -3400,13 +3335,8 @@ describe('API', function()
screen:expect{grid=[[
|
{0:~}{1:herrejösses!}{7: }{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~}{1: }{0: }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~}{1: }{0: }|*4
+ {0:~ }|*3
{6:-- TERMINAL --} |
]]}
eq('ba\024blaherrejösses!', exec_lua [[ return stream ]])
@@ -4159,8 +4089,7 @@ describe('API', function()
screen:expect([[
foo |
bar |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
{1: }|
Entering Ex mode. Type "visual" to go to Normal mode. |
:1^ |
@@ -4518,10 +4447,7 @@ describe('API', function()
meths.cmd({cmd = 'echo', args = {[['hello']]}}, {output = true})
screen:expect{grid=[[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*4
|
]]}
exec([[
@@ -4532,10 +4458,7 @@ describe('API', function()
feed([[:echon 1 | call Print() | echon 5<CR>]])
screen:expect{grid=[[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*4
15 |
]]}
end)
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 6737c2d15b..67284c01e0 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -96,14 +96,7 @@ describe('API/win', function()
screen:expect{grid=[[
^prologue |
- |
- |
- |
- |
- |
- |
- |
- |
+ |*8
]]}
-- cursor position is at beginning
eq({1, 0}, window('get_cursor', win))
@@ -111,13 +104,7 @@ describe('API/win', function()
-- move cursor to end
window('set_cursor', win, {101, 0})
screen:expect{grid=[[
- |
- |
- |
- |
- |
- |
- |
+ |*7
^epilogue |
|
]]}
@@ -126,14 +113,7 @@ describe('API/win', function()
window('set_cursor', win, {1, 0})
screen:expect{grid=[[
^prologue |
- |
- |
- |
- |
- |
- |
- |
- |
+ |*8
]]}
-- move focus to new window
@@ -144,12 +124,10 @@ describe('API/win', function()
eq({1, 0}, window('get_cursor', win))
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
{2:[No Name] }|
prologue |
- |
- |
+ |*2
{3:[No Name] [+] }|
|
]]}
@@ -158,11 +136,9 @@ describe('API/win', function()
window('set_cursor', win, {101, 0})
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
{2:[No Name] }|
- |
- |
+ |*2
epilogue |
{3:[No Name] [+] }|
|
@@ -172,12 +148,10 @@ describe('API/win', function()
window('set_cursor', win, {1, 0})
screen:expect{grid=[[
^ |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
{2:[No Name] }|
prologue |
- |
- |
+ |*2
{3:[No Name] [+] }|
|
]]}
@@ -232,8 +206,7 @@ describe('API/win', function()
bbb │bbb |
ccc │ccc |
{2:dd^d }│{2:ddd }|
- {1:~ }│{1:~ }|
- {1:~ }│{1:~ }|
+ {1:~ }│{1:~ }|*2
{3:[No Name] [+] 4,3 All }{4:[No Name] [+] 4,3 All}|
|
]])
@@ -243,8 +216,7 @@ describe('API/win', function()
bbb │bbb |
ccc │ccc |
{2:dd^d }│ddd |
- {1:~ }│{1:~ }|
- {1:~ }│{1:~ }|
+ {1:~ }│{1:~ }|*2
{3:[No Name] [+] 4,3 All }{4:[No Name] [+] 1,1 All}|
|
]])
@@ -272,8 +244,7 @@ describe('API/win', function()
bb{2:b} │bb{2:b} |
cc{2:c} │cc{2:c} |
dd^d │ddd |
- {1:~ }│{1:~ }|
- {1:~ }│{1:~ }|
+ {1:~ }│{1:~ }|*2
{3:[No Name] [+] }{4:[No Name] [+] }|
|
]])
@@ -283,8 +254,7 @@ describe('API/win', function()
bb{2:b} │bbb |
cc{2:c} │{2:c}cc |
dd^d │{2:d}dd |
- {1:~ }│{1:~ }|
- {1:~ }│{1:~ }|
+ {1:~ }│{1:~ }|*2
{3:[No Name] [+] }{4:[No Name] [+] }|
|
]])