diff options
Diffstat (limited to 'test/functional/lua/thread_spec.lua')
-rw-r--r-- | test/functional/lua/thread_spec.lua | 108 |
1 files changed, 46 insertions, 62 deletions
diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua index e79d26a641..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() @@ -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) @@ -35,11 +35,7 @@ describe('thread', function() screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2: }| {3:Error in luv thread:} | {3:[string "<nvim>"]: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 "<nvim>"]: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) @@ -172,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() @@ -204,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() @@ -219,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() @@ -234,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) @@ -263,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 [[ @@ -294,11 +278,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} | @@ -364,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() @@ -380,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() @@ -395,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) |