From 3bb5d2f2192b63e368a4f573f66406eba3ee66b3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 8 Dec 2023 08:00:27 +0800 Subject: test: use termopen() instead of :terminal more (#26462) --- test/functional/lua/ui_event_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/lua/ui_event_spec.lua') diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index 373d45da61..2d1ee54506 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -101,7 +101,7 @@ describe('vim.ui_attach', function() end) it('does not crash on exit', function() - helpers.funcs.system({ + funcs.system({ helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', -- cgit 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/lua/ui_event_spec.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'test/functional/lua/ui_event_spec.lua') diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index 2d1ee54506..04ffeddc87 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -46,18 +46,14 @@ describe('vim.ui_attach', function() feed('ifo') screen:expect{grid=[[ fo^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- INSERT --} | ]]} funcs.complete(1, {'food', 'foobar', 'foo'}) screen:expect{grid=[[ food^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- INSERT --} | ]]} expect_events { @@ -67,9 +63,7 @@ describe('vim.ui_attach', function() feed '' screen:expect{grid=[[ foobar^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- INSERT --} | ]]} expect_events { -- 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/lua/ui_event_spec.lua | 70 ++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 26 deletions(-) (limited to 'test/functional/lua/ui_event_spec.lua') diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index 04ffeddc87..c0a0b3e762 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -5,7 +5,7 @@ local exec_lua = helpers.exec_lua local clear = helpers.clear local feed = helpers.feed local funcs = helpers.funcs -local inspect = require'vim.inspect' +local inspect = require 'vim.inspect' describe('vim.ui_attach', function() local screen @@ -26,54 +26,67 @@ describe('vim.ui_attach', function() end ]] - screen = Screen.new(40,5) + screen = Screen.new(40, 5) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {bold = true}; - [3] = {background = Screen.colors.Grey}; - [4] = {background = Screen.colors.LightMagenta}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { bold = true }, + [3] = { background = Screen.colors.Grey }, + [4] = { background = Screen.colors.LightMagenta }, }) screen:attach() end) local function expect_events(expected) - local evs = exec_lua "return get_events(...)" + local evs = exec_lua 'return get_events(...)' eq(expected, evs, inspect(evs)) end it('can receive popupmenu events', function() exec_lua [[ vim.ui_attach(ns, {ext_popupmenu=true}, on_event) ]] feed('ifo') - screen:expect{grid=[[ + screen:expect { + grid = [[ fo^ | {1:~ }|*3 {2:-- INSERT --} | - ]]} + ]], + } - funcs.complete(1, {'food', 'foobar', 'foo'}) - screen:expect{grid=[[ + funcs.complete(1, { 'food', 'foobar', 'foo' }) + screen:expect { + grid = [[ food^ | {1:~ }|*3 {2:-- INSERT --} | - ]]} + ]], + } expect_events { - { "popupmenu_show", { { "food", "", "", "" }, { "foobar", "", "", "" }, { "foo", "", "", "" } }, 0, 0, 0, 1 }; + { + 'popupmenu_show', + { { 'food', '', '', '' }, { 'foobar', '', '', '' }, { 'foo', '', '', '' } }, + 0, + 0, + 0, + 1, + }, } feed '' - screen:expect{grid=[[ + screen:expect { + grid = [[ foobar^ | {1:~ }|*3 {2:-- INSERT --} | - ]]} + ]], + } expect_events { - { "popupmenu_select", 1 }; + { 'popupmenu_select', 1 }, } feed '' screen:expect_unchanged() expect_events { - { "popupmenu_hide" }; + { 'popupmenu_hide' }, } -- vim.ui_detach() stops events, and reenables builtin pum immediately @@ -82,26 +95,31 @@ describe('vim.ui_attach', function() vim.fn.complete(1, {'food', 'foobar', 'foo'}) ]] - screen:expect{grid=[[ + screen:expect { + grid = [[ food^ | {3:food }{1: }| {4:foobar }{1: }| {4:foo }{1: }| {2:-- INSERT --} | - ]]} - expect_events { + ]], } - + expect_events {} end) it('does not crash on exit', function() funcs.system({ helpers.nvim_prog, - '-u', 'NONE', - '-i', 'NONE', - '--cmd', [[ lua ns = vim.api.nvim_create_namespace 'testspace' ]], - '--cmd', [[ lua vim.ui_attach(ns, {ext_popupmenu=true}, function() end) ]], - '--cmd', 'quitall!', + '-u', + 'NONE', + '-i', + 'NONE', + '--cmd', + [[ lua ns = vim.api.nvim_create_namespace 'testspace' ]], + '--cmd', + [[ lua vim.ui_attach(ns, {ext_popupmenu=true}, function() end) ]], + '--cmd', + 'quitall!', }) eq(0, helpers.eval('v:shell_error')) end) -- cgit From 56a2ec5c79d49421758319f1a8822cf30f1f8a5e Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 11:51:31 +0000 Subject: test: use vim.inspect directly --- test/functional/lua/ui_event_spec.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/functional/lua/ui_event_spec.lua') diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index c0a0b3e762..9f9e5271de 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -5,7 +5,6 @@ local exec_lua = helpers.exec_lua local clear = helpers.clear local feed = helpers.feed local funcs = helpers.funcs -local inspect = require 'vim.inspect' describe('vim.ui_attach', function() local screen @@ -38,7 +37,7 @@ describe('vim.ui_attach', function() local function expect_events(expected) local evs = exec_lua 'return get_events(...)' - eq(expected, evs, inspect(evs)) + eq(expected, evs, vim.inspect(evs)) end it('can receive popupmenu events', function() @@ -148,6 +147,6 @@ describe('vim.ui_attach', function() { 'echomsg', { { 0, 'message3' } } }, }, }, - }, actual, inspect(actual)) + }, actual, vim.inspect(actual)) end) end) -- 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/lua/ui_event_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/lua/ui_event_spec.lua') diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index 9f9e5271de..3e46018682 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -4,7 +4,7 @@ local eq = helpers.eq local exec_lua = helpers.exec_lua local clear = helpers.clear local feed = helpers.feed -local funcs = helpers.funcs +local fn = helpers.fn describe('vim.ui_attach', function() local screen @@ -51,7 +51,7 @@ describe('vim.ui_attach', function() ]], } - funcs.complete(1, { 'food', 'foobar', 'foo' }) + fn.complete(1, { 'food', 'foobar', 'foo' }) screen:expect { grid = [[ food^ | @@ -107,7 +107,7 @@ describe('vim.ui_attach', function() end) it('does not crash on exit', function() - funcs.system({ + fn.system({ helpers.nvim_prog, '-u', 'NONE', -- cgit