From 1037ce2e461034a20e35ad59969fd05d5ad68b91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Dec 2023 20:42:00 +0800 Subject: 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 --- test/functional/ui/input_spec.lua | 44 +++++++-------------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 05d55b94fb..a3ab1a4ab6 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -273,9 +273,7 @@ it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2 feed_command('ls') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2: }| :ls | 1 %a "[No Name]" line 1 | @@ -284,12 +282,7 @@ it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2 feed('') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 hit ctrl-6 | ]]) end) @@ -333,12 +326,7 @@ describe('input non-printable chars', function() feed_command("e Xtest-overwrite") screen:expect([[ ^foobar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 "Xtest-overwrite" [noeol] 1L, 6B | ]]) @@ -348,9 +336,7 @@ describe('input non-printable chars', function() feed_command("w") screen:expect([[ foobar | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | @@ -360,8 +346,7 @@ describe('input non-printable chars', function() feed("u") screen:expect([[ foobar | - {1:~ }| - {1:~ }| + {1:~ }|*2 {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | @@ -396,12 +381,7 @@ describe('input non-printable chars', function() feed("") screen:expect([[ ^foobar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end) @@ -449,11 +429,7 @@ describe('display is updated', function() screen:expect([[ abc | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) end) @@ -465,11 +441,7 @@ describe('display is updated', function() screen:expect([[ abc | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) end) -- cgit From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/ui/input_spec.lua | 178 ++++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 85 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index a3ab1a4ab6..92bc6a7f76 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -15,14 +15,17 @@ before_each(clear) describe('mappings', function() local add_mapping = function(mapping, send) - local cmd = "nnoremap "..mapping.." :call rpcnotify(1, 'mapped', '" - ..send:gsub('<', '').."')" + local cmd = 'nnoremap ' + .. mapping + .. " :call rpcnotify(1, 'mapped', '" + .. send:gsub('<', '') + .. "')" feed_command(cmd) end local check_mapping = function(mapping, expected) feed(mapping) - eq({'notification', 'mapped', {expected}}, next_msg()) + eq({ 'notification', 'mapped', { expected } }, next_msg()) end before_each(function() @@ -35,26 +38,26 @@ describe('mappings', function() add_mapping('', '') add_mapping('', '') add_mapping('', '') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') - add_mapping('','') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') end) it('ok', function() @@ -75,44 +78,44 @@ describe('mappings', function() check_mapping('', '') check_mapping('', '') check_mapping('', '') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') - check_mapping('','') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') end) it('support meta + multibyte char mapping', function() @@ -262,11 +265,11 @@ it('c_CTRL-R_CTRL-R, i_CTRL-R_CTRL-R, i_CTRL-G_CTRL-K work properly vim-patch:8. end) it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function() - local screen = Screen.new(60,8) + local screen = Screen.new(60, 8) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [2] = {bold = true, reverse = true}, -- MsgSeparator - [3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [2] = { bold = true, reverse = true }, -- MsgSeparator + [3] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg }) screen:attach() command([[nnoremap echo 'hit ctrl-6']]) @@ -312,18 +315,18 @@ describe('input non-printable chars', function() end) it("doesn't crash when echoing them back", function() - write_file("Xtest-overwrite", [[foobar]]) - local screen = Screen.new(60,8) + write_file('Xtest-overwrite', [[foobar]]) + local screen = Screen.new(60, 8) screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}; - [3] = {bold = true, foreground = Screen.colors.SeaGreen4}; - [4] = {bold = true, reverse = true}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [4] = { bold = true, reverse = true }, } screen:attach() - command("set shortmess-=F") + command('set shortmess-=F') - feed_command("e Xtest-overwrite") + feed_command('e Xtest-overwrite') screen:expect([[ ^foobar | {1:~ }|*6 @@ -332,8 +335,8 @@ describe('input non-printable chars', function() -- The timestamp is in second resolution, wait two seconds to be sure. screen:sleep(2000) - write_file("Xtest-overwrite", [[smurf]]) - feed_command("w") + write_file('Xtest-overwrite', [[smurf]]) + feed_command('w') screen:expect([[ foobar | {1:~ }|*3 @@ -343,7 +346,7 @@ describe('input non-printable chars', function() {3:Do you really want to write to it (y/n)?}^ | ]]) - feed("u") + feed('u') screen:expect([[ foobar | {1:~ }|*2 @@ -354,7 +357,7 @@ describe('input non-printable chars', function() {3:Do you really want to write to it (y/n)?}^ | ]]) - feed("\005") + feed('\005') screen:expect([[ foobar | {1:~ }| @@ -366,7 +369,7 @@ describe('input non-printable chars', function() {3:Do you really want to write to it (y/n)?}^ | ]]) - feed("n") + feed('n') screen:expect([[ foobar | {4: }| @@ -378,7 +381,7 @@ describe('input non-printable chars', function() {3:Press ENTER or type command to continue}^ | ]]) - feed("") + feed('') screen:expect([[ ^foobar | {1:~ }|*6 @@ -387,9 +390,14 @@ describe('input non-printable chars', function() end) end) -describe("event processing and input", function() +describe('event processing and input', function() it('not blocked by event bursts', function() - meths.set_keymap('', '', "lua vim.rpcnotify(1, 'stop') winning = true ", {noremap=true}) + meths.set_keymap( + '', + '', + "lua vim.rpcnotify(1, 'stop') winning = true ", + { noremap = true } + ) exec_lua [[ winning = false @@ -405,9 +413,9 @@ describe("event processing and input", function() burst(true) ]] - eq({'notification', 'start', {}}, next_msg()) + eq({ 'notification', 'start', {} }, next_msg()) feed '' - eq({'notification', 'stop', {}}, next_msg()) + eq({ 'notification', 'stop', {} }, next_msg()) end) end) @@ -416,8 +424,8 @@ describe('display is updated', function() before_each(function() screen = Screen.new(60, 8) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText - [2] = {bold = true}, -- ModeMsg + [1] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText + [2] = { bold = true }, -- ModeMsg }) screen:attach() end) -- cgit From 7a259d01aed52134a1675e47d9054ccad7ef7cbb Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 11:41:09 +0000 Subject: test: remove helpers.sleep() --- test/functional/ui/input_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 92bc6a7f76..7cb8d4622d 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -154,7 +154,7 @@ describe('input split utf sequences', function() it('ok', function() local str = '►' feed('i' .. str:sub(1, 1)) - helpers.sleep(10) + vim.uv.sleep(10) feed(str:sub(2, 3)) expect('►') end) @@ -163,7 +163,7 @@ describe('input split utf sequences', function() command('inoremap ► E296BA') local str = '►' feed('i' .. str:sub(1, 1)) - helpers.sleep(10) + vim.uv.sleep(10) feed(str:sub(2, 3)) expect('E296BA') end) -- cgit From c30f2e3182e3b50e7c03932027ac55edfc8ada4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 12:44:54 +0000 Subject: test: typing for helpers.meths --- test/functional/ui/input_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 7cb8d4622d..8a08d459c4 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -392,7 +392,7 @@ end) describe('event processing and input', function() it('not blocked by event bursts', function() - meths.set_keymap( + meths.nvim_set_keymap( '', '', "lua vim.rpcnotify(1, 'stop') winning = true ", -- cgit From 795f896a5772d5e0795f86642bdf90c82efac45c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 17:59:57 +0000 Subject: test: rename (meths, funcs) -> (api, fn) --- test/functional/ui/input_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 8a08d459c4..80862b668f 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -4,10 +4,10 @@ local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq local command = helpers.command local expect = helpers.expect local curbuf_contents = helpers.curbuf_contents -local meths = helpers.meths +local api = helpers.api local exec_lua = helpers.exec_lua local write_file = helpers.write_file -local funcs = helpers.funcs +local fn = helpers.fn local eval = helpers.eval local Screen = require('test.functional.ui.screen') @@ -244,7 +244,7 @@ it('Ctrl-6 is Ctrl-^ vim-patch:8.1.2333', function() command('split aaa') command('edit bbb') feed('') - eq('aaa', funcs.bufname()) + eq('aaa', fn.bufname()) end) it('c_CTRL-R_CTRL-R, i_CTRL-R_CTRL-R, i_CTRL-G_CTRL-K work properly vim-patch:8.1.2346', function() @@ -303,7 +303,7 @@ it('unsimplified mapping works when there was a partial match vim-patch:8.2.4504 command('nnoremap a') command('nnoremap x') command('nnoremap x ') - funcs.setline(1, 'x') + fn.setline(1, 'x') -- CTRL-J b should have trigger the mapping and then insert "b" feed('b') expect('xb') @@ -392,7 +392,7 @@ end) describe('event processing and input', function() it('not blocked by event bursts', function() - meths.nvim_set_keymap( + api.nvim_set_keymap( '', '', "lua vim.rpcnotify(1, 'stop') winning = true ", -- cgit From 6709f7f8f130377f44c36b2150a167a2afcbdff9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 3 Feb 2024 11:05:38 +0800 Subject: fix(keycodes): simplify S- properly when D- is present (#27316) --- test/functional/ui/input_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 80862b668f..b2899bf82d 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -29,6 +29,10 @@ describe('mappings', function() end before_each(function() + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') + add_mapping('', '') add_mapping('', '') add_mapping('', '') add_mapping('', '') @@ -61,7 +65,17 @@ describe('mappings', function() end) it('ok', function() + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') + check_mapping('', '') check_mapping('', '') + check_mapping('', '') check_mapping('', '') check_mapping('', '') check_mapping('', '') -- cgit