diff options
Diffstat (limited to 'test/functional')
| -rw-r--r-- | test/functional/api/tabpage_spec.lua | 16 | ||||
| -rw-r--r-- | test/functional/api/window_spec.lua | 24 | ||||
| -rw-r--r-- | test/functional/eval/execute_spec.lua | 12 | ||||
| -rw-r--r-- | test/functional/eval/system_spec.lua (renamed from test/functional/shell/viml_system_spec.lua) | 14 | ||||
| -rw-r--r-- | test/functional/eval/timer_spec.lua | 68 | ||||
| -rw-r--r-- | test/functional/ex_cmds/bang_filter_spec.lua (renamed from test/functional/shell/bang_filter_spec.lua) | 0 | ||||
| -rw-r--r-- | test/functional/ex_cmds/dict_notifications_spec.lua (renamed from test/functional/dict_notifications_spec.lua) | 0 | ||||
| -rw-r--r-- | test/functional/terminal/api_spec.lua | 12 |
8 files changed, 130 insertions, 16 deletions
diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua index 47dede8b44..90940e9577 100644 --- a/test/functional/api/tabpage_spec.lua +++ b/test/functional/api/tabpage_spec.lua @@ -51,6 +51,22 @@ describe('tabpage_* functions', function() end) end) + describe('get_number', function() + it('works', function() + local tabs = nvim('list_tabpages') + eq(1, tabpage('get_number', tabs[1])) + + nvim('command', 'tabnew') + local tab1, tab2 = unpack(nvim('list_tabpages')) + eq(1, tabpage('get_number', tab1)) + eq(2, tabpage('get_number', tab2)) + + nvim('command', '-tabmove') + eq(2, tabpage('get_number', tab1)) + eq(1, tabpage('get_number', tab2)) + end) + end) + describe('is_valid', function() it('works', function() nvim('command', 'tabnew') diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 2c43e4db2c..bf2bf55fb3 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -200,6 +200,30 @@ describe('window_* functions', function() end) end) + describe('get_number', function() + it('works', function() + local wins = nvim('list_wins') + eq(1, window('get_number', wins[1])) + + nvim('command', 'split') + local win1, win2 = unpack(nvim('list_wins')) + eq(1, window('get_number', win1)) + eq(2, window('get_number', win2)) + + nvim('command', 'wincmd J') + eq(2, window('get_number', win1)) + eq(1, window('get_number', win2)) + + nvim('command', 'tabnew') + local win3 = nvim('list_wins')[3] + -- First tab page + eq(2, window('get_number', win1)) + eq(1, window('get_number', win2)) + -- Second tab page + eq(1, window('get_number', win3)) + end) + end) + describe('is_valid', function() it('works', function() nvim('command', 'split') diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua index 10a6de6eb4..b5b481435a 100644 --- a/test/functional/eval/execute_spec.lua +++ b/test/functional/eval/execute_spec.lua @@ -70,16 +70,16 @@ describe('execute()', function() end) it('silences command run inside', function() - local screen = Screen.new(20, 5) + local screen = Screen.new(40, 5) screen:attach() screen:set_default_attr_ids( {[0] = {bold=true, foreground=255}} ) feed(':let g:mes = execute("echon 42")<CR>') screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - | + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + :let g:mes = execute("echon 42") | ]]) eq('42', eval('g:mes')) end) diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/eval/system_spec.lua index b8de7cc86f..b8f1f87f30 100644 --- a/test/functional/shell/viml_system_spec.lua +++ b/test/functional/eval/system_spec.lua @@ -1,7 +1,3 @@ --- Specs for --- - `system()` --- - `systemlist()` - local helpers = require('test.functional.helpers')(after_each) local eq, clear, eval, feed, nvim = helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim @@ -120,12 +116,22 @@ describe('system()', function() it('returns the program output', function() eq("echoed", eval('system("echo -n echoed")')) end) + it('to backgrounded command does not crash', function() + -- This is indeterminate, just exercise the codepath. + eval('system("echo -n echoed &")') + eq(2, eval("1+1")) -- Still alive? + end) end) describe('passing input', function() it('returns the program output', function() eq("input", eval('system("cat -", "input")')) end) + it('to backgrounded command does not crash', function() + -- This is indeterminate, just exercise the codepath. + eval('system("cat - &", "input")') + eq(2, eval("1+1")) -- Still alive? + end) end) describe('passing a lot of input', function() diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index 295c763d74..fba9466b78 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local ok, feed, eq, eval = helpers.ok, helpers.feed, helpers.eq, helpers.eval local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run local clear, execute, funcs = helpers.clear, helpers.execute, helpers.funcs +local curbufmeths = helpers.curbufmeths describe('timers', function() before_each(function() @@ -62,19 +63,76 @@ describe('timers', function() end) it('are paused when event processing is disabled', function() - -- this is not the intended behavior, but at least there will - -- not be a burst of queued up callbacks - execute("call timer_start(50, 'MyHandler', {'repeat': 2})") + execute("call timer_start(50, 'MyHandler', {'repeat': -1})") run(nil, nil, nil, 100) local count = eval("g:val") + -- shows two line error message and thus invokes the return prompt. + -- if we start to allow event processing here, we need to change this test. + execute("throw 'fatal error'") + run(nil, nil, nil, 300) + feed("<cr>") + local diff = eval("g:val") - count + ok(0 <= diff and diff <= 4) + end) + + it('are triggered in blocking getchar() call', function() + execute("call timer_start(50, 'MyHandler', {'repeat': -1})") nvim_async("command", "let g:c = getchar()") run(nil, nil, nil, 300) feed("c") - local diff = eval("g:val") - count - ok(0 <= diff and diff <= 2) + local count = eval("g:val") + ok(count >= 5) eq(99, eval("g:c")) end) + it('can invoke redraw in blocking getchar() call', function() + local screen = Screen.new(40, 6) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold=true, foreground=Screen.colors.Blue}, + }) + + curbufmeths.set_lines(0, -1, true, {"ITEM 1", "ITEM 2"}) + source([[ + func! AddItem(timer) + call nvim_buf_set_lines(0, 2, 2, v:true, ['ITEM 3']) + redraw + endfunc + call timer_start(200, 'AddItem') + ]]) + nvim_async("command", "let g:c2 = getchar()") + + screen:expect([[ + ITEM 1 | + ITEM 2 | + {1:~ }| + {1:~ }| + {1:~ }| + ^ | + ]]) + + screen:sleep(200) + screen:expect([[ + ITEM 1 | + ITEM 2 | + ITEM 3 | + {1:~ }| + {1:~ }| + ^ | + ]]) + + feed("3") + eq(51, eval("g:c2")) + screen:expect([[ + ^ITEM 1 | + ITEM 2 | + ITEM 3 | + {1:~ }| + {1:~ }| + | + ]]) + end) + it('can be stopped', function() local t = eval("timer_start(50, 'MyHandler', {'repeat': -1})") eq(0,eval("g:val")) diff --git a/test/functional/shell/bang_filter_spec.lua b/test/functional/ex_cmds/bang_filter_spec.lua index a320e6d018..a320e6d018 100644 --- a/test/functional/shell/bang_filter_spec.lua +++ b/test/functional/ex_cmds/bang_filter_spec.lua diff --git a/test/functional/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua index dc87312911..dc87312911 100644 --- a/test/functional/dict_notifications_spec.lua +++ b/test/functional/ex_cmds/dict_notifications_spec.lua diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua index 58d6c75940..045bdb0749 100644 --- a/test/functional/terminal/api_spec.lua +++ b/test/functional/terminal/api_spec.lua @@ -22,7 +22,7 @@ describe('api', function() -- Start the socket from the child nvim. child_session.feed_data(":echo serverstart('"..socket_name.."')\n") - -- Wait for socket creation by abusing expect(). + -- Wait for socket creation. screen:expect([[ {1: } | {4:~ }| @@ -37,6 +37,16 @@ describe('api', function() local socket_session2 = helpers.connect(socket_name) child_session.feed_data("i[tui] insert-mode") + -- Wait for stdin to be processed. + screen:expect([[ + [tui] insert-mode{1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | + ]]) ok(socket_session1:request("nvim_ui_attach", 42, 6, {rgb=true})) ok(socket_session2:request("nvim_ui_attach", 25, 30, {rgb=true})) |