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/thread_spec.lua | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) (limited to 'test/functional/lua/thread_spec.lua') diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua index e79d26a641..23c0c42f07 100644 --- a/test/functional/lua/thread_spec.lua +++ b/test/functional/lua/thread_spec.lua @@ -35,11 +35,7 @@ describe('thread', function() screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2: }| {3:Error in luv thread:} | {3:[string ""]:2: Error in thread entry func} | @@ -66,11 +62,7 @@ describe('thread', function() screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2: }| {3:Error in luv callback, thread:} | {3:[string ""]:6: Error in thread callback} | @@ -91,14 +83,7 @@ describe('thread', function() screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 print in thread | ]]) end) @@ -113,14 +98,7 @@ describe('thread', function() screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 { 1, 2 } | ]]) end) @@ -294,11 +272,7 @@ describe('threadpool', function() screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2: }| {3:Error in luv thread:} | {3:Error: thread arg not support type 'table' at 1} | -- 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/thread_spec.lua | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) (limited to 'test/functional/lua/thread_spec.lua') diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua index 23c0c42f07..0a7a7f0448 100644 --- a/test/functional/lua/thread_spec.lua +++ b/test/functional/lua/thread_spec.lua @@ -17,11 +17,11 @@ describe('thread', function() screen = Screen.new(50, 10) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {bold = true, reverse = true}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {bold = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { bold = true, reverse = true }, + [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { bold = true }, }) end) @@ -150,7 +150,7 @@ describe('thread', function() thread_test:do_test() ]] - eq({'notification', 'result', {true}}, next_msg()) + eq({ 'notification', 'result', { true } }, next_msg()) end) it('uv', function() @@ -182,7 +182,7 @@ describe('thread', function() thread_test:do_test() ]] - eq({'notification', 'result', {{33, NIL, 'text'}}}, next_msg()) + eq({ 'notification', 'result', { { 33, NIL, 'text' } } }, next_msg()) end) it('json', function() @@ -197,7 +197,7 @@ describe('thread', function() thread_test:do_test() ]] - eq({'notification', 'result', {{33, NIL, 'text'}}}, next_msg()) + eq({ 'notification', 'result', { { 33, NIL, 'text' } } }, next_msg()) end) it('diff', function() @@ -212,14 +212,18 @@ describe('thread', function() thread_test:do_test() ]] - eq({'notification', 'result', - {table.concat({ + eq({ + 'notification', + 'result', + { + table.concat({ '@@ -1 +1 @@', '-Hello', '+Helli', - '' - }, '\n')}}, - next_msg()) + '', + }, '\n'), + }, + }, next_msg()) end) end) end) @@ -241,28 +245,30 @@ describe('threadpool', function() work:queue() ]] - eq({'notification', 'result', {true}}, next_msg()) + eq({ 'notification', 'result', { true } }, next_msg()) end) it('with invalid argument', function() - local status = pcall_err(exec_lua, [[ + local status = pcall_err( + exec_lua, + [[ local work = vim.uv.new_thread(function() end, function() end) work:queue({}) - ]]) + ]] + ) - eq([[Error: thread arg not support type 'function' at 1]], - status) + eq([[Error: thread arg not support type 'function' at 1]], status) end) it('with invalid return value', function() local screen = Screen.new(50, 10) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {bold = true, reverse = true}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {bold = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { bold = true, reverse = true }, + [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { bold = true }, }) exec_lua [[ @@ -338,7 +344,7 @@ describe('threadpool', function() threadpool_test:do_test() ]] - eq({'notification', 'result', {{33, NIL, 'text'}}}, next_msg()) + eq({ 'notification', 'result', { { 33, NIL, 'text' } } }, next_msg()) end) it('json', function() @@ -354,7 +360,7 @@ describe('threadpool', function() threadpool_test:do_test() ]] - eq({'notification', 'result', {{33, NIL, 'text'}}}, next_msg()) + eq({ 'notification', 'result', { { 33, NIL, 'text' } } }, next_msg()) end) it('work', function() @@ -369,14 +375,18 @@ describe('threadpool', function() threadpool_test:do_test() ]] - eq({'notification', 'result', - {table.concat({ + eq({ + 'notification', + 'result', + { + table.concat({ '@@ -1 +1 @@', '-Hello', '+Helli', - '' - }, '\n')}}, - next_msg()) + '', + }, '\n'), + }, + }, next_msg()) end) end) end) -- cgit From d33e1da9b7f7e886219cfdd20b9bbfaccdc43be9 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 11:28:20 +0000 Subject: test: do not inject vim module into global helpers --- test/functional/lua/thread_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/lua/thread_spec.lua') diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua index 0a7a7f0448..c1981e19d4 100644 --- a/test/functional/lua/thread_spec.lua +++ b/test/functional/lua/thread_spec.lua @@ -6,7 +6,7 @@ local feed = helpers.feed local eq = helpers.eq local exec_lua = helpers.exec_lua local next_msg = helpers.next_msg -local NIL = helpers.NIL +local NIL = vim.NIL local pcall_err = helpers.pcall_err describe('thread', function() -- cgit