diff options
Diffstat (limited to 'test/functional/legacy')
-rw-r--r-- | test/functional/legacy/075_maparg_spec.lua | 59 | ||||
-rw-r--r-- | test/functional/legacy/arglist_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/legacy/cmdline_spec.lua | 29 | ||||
-rw-r--r-- | test/functional/legacy/ex_mode_spec.lua | 51 | ||||
-rw-r--r-- | test/functional/legacy/excmd_spec.lua | 619 | ||||
-rw-r--r-- | test/functional/legacy/global_spec.lua | 51 | ||||
-rw-r--r-- | test/functional/legacy/messages_spec.lua | 25 | ||||
-rw-r--r-- | test/functional/legacy/syn_attr_spec.lua | 60 |
8 files changed, 691 insertions, 206 deletions
diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua deleted file mode 100644 index ad6c190104..0000000000 --- a/test/functional/legacy/075_maparg_spec.lua +++ /dev/null @@ -1,59 +0,0 @@ --- Tests for maparg(). --- Also test utf8 map with a 0x80 byte. - -local helpers = require('test.functional.helpers')(after_each) -local clear, feed = helpers.clear, helpers.feed -local command, expect = helpers.command, helpers.expect -local poke_eventloop = helpers.poke_eventloop - -describe('maparg()', function() - setup(clear) - - it('is working', function() - command('set cpo-=<') - - -- Test maparg() with a string result - command('map foo<C-V> is<F4>foo') - command('vnoremap <script> <buffer> <expr> <silent> bar isbar') - command([[call append('$', maparg('foo<C-V>'))]]) - command([[call append('$', string(maparg('foo<C-V>', '', 0, 1)))]]) - command([[call append('$', string(maparg('bar', '', 0, 1)))]]) - command('map <buffer> <nowait> foo bar') - command([[call append('$', string(maparg('foo', '', 0, 1)))]]) - command('map abc x<char-114>x') - command([[call append('$', maparg('abc'))]]) - command('map abc y<S-char-114>y') - command([[call append('$', maparg('abc'))]]) - feed('Go<esc>:<cr>') - poke_eventloop() - - -- Outside of the range, minimum - command('inoremap <Char-0x1040> a') - command([[execute "normal a\u1040\<Esc>"]]) - - -- Inside of the range, minimum - command('inoremap <Char-0x103f> b') - command([[execute "normal a\u103f\<Esc>"]]) - - -- Inside of the range, maximum - command('inoremap <Char-0xf03f> c') - command([[execute "normal a\uf03f\<Esc>"]]) - - -- Outside of the range, maximum - command('inoremap <Char-0xf040> d') - command([[execute "normal a\uf040\<Esc>"]]) - - -- Remove empty line - command('1d') - - -- Assert buffer contents. - expect([[ - is<F4>foo - {'lnum': 0, 'script': 0, 'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0} - {'lnum': 0, 'script': 1, 'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1} - {'lnum': 0, 'script': 0, 'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1} - xrx - yRy - abcd]]) - end) -end) diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index 8379e426e0..f90da16d7b 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -4,6 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, command, eq = helpers.clear, helpers.command, helpers.eq local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq +local expect_exit = helpers.expect_exit local feed = helpers.feed local pcall_err = helpers.pcall_err @@ -275,6 +276,6 @@ describe('argument list commands', function() 2 more files to edit. Quit anyway? | [Y]es, (N)o: ^ | ]]) - feed('Y') + expect_exit(100, feed, 'Y') end) end) diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index d8d849271b..cf02636890 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -3,11 +3,12 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local feed = helpers.feed local feed_command = helpers.feed_command -local source = helpers.source +local exec = helpers.exec describe('cmdline', function() before_each(clear) + -- oldtest: Test_cmdlineclear_tabenter() it('is cleared when switching tabs', function() local screen = Screen.new(30, 10) screen:attach() @@ -91,10 +92,11 @@ describe('cmdline', function() ]]) end) + -- oldtest: Test_verbose_option() it('prints every executed Ex command if verbose >= 16', function() local screen = Screen.new(60, 12) screen:attach() - source([[ + exec([[ command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v call feedkeys("\r", 't') " for the hit-enter prompt set verbose=20 @@ -115,4 +117,27 @@ describe('cmdline', function() Press ENTER or type command to continue^ | ]]) end) + + -- oldtest: Test_cmdline_redraw_tabline() + it('tabline is redrawn on entering cmdline', function() + local screen = Screen.new(30, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {reverse = true}, -- TabLineFill + }) + screen:attach() + exec([[ + set showtabline=2 + autocmd CmdlineEnter * set tabline=foo + ]]) + feed(':') + screen:expect([[ + {1:foo }| + | + {0:~ }| + {0:~ }| + {0:~ }| + :^ | + ]]) + end) end) diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua index 98f113bbd0..a8f54c6939 100644 --- a/test/functional/legacy/ex_mode_spec.lua +++ b/test/functional/legacy/ex_mode_spec.lua @@ -6,6 +6,7 @@ local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed local meths = helpers.meths +local sleep = helpers.sleep before_each(clear) @@ -122,4 +123,54 @@ describe('Ex mode', function() | ]]) end) + + it('pressing Ctrl-C in :append inside a loop in Ex mode does not hang', function() + local screen = Screen.new(60, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, reverse = true}, -- MsgSeparator + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + }) + screen:attach() + feed('gQ') + feed('for i in range(1)<CR>') + feed('append<CR>') + screen:expect([[ + {0: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :for i in range(1) | + | + : append | + ^ | + ]]) + feed('<C-C>') + sleep(10) -- Wait for input to be flushed + feed('foo<CR>') + screen:expect([[ + Entering Ex mode. Type "visual" to go to Normal mode. | + :for i in range(1) | + | + : append | + foo | + ^ | + ]]) + feed('.<CR>') + screen:expect([[ + :for i in range(1) | + | + : append | + foo | + . | + : ^ | + ]]) + feed('endfor<CR>') + feed('vi<CR>') + screen:expect([[ + ^foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) end) diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua index 6b3b265579..65957d85de 100644 --- a/test/functional/legacy/excmd_spec.lua +++ b/test/functional/legacy/excmd_spec.lua @@ -2,10 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command +local exec = helpers.exec local exec_lua = helpers.exec_lua +local expect_exit = helpers.expect_exit local feed = helpers.feed +local funcs = helpers.funcs +local iswin = helpers.iswin local meths = helpers.meths -local poke_eventloop = helpers.poke_eventloop local read_file = helpers.read_file local source = helpers.source local eq = helpers.eq @@ -37,152 +40,484 @@ describe('Ex command', function() end) end) -it(':confirm command dialog', function() +describe(':confirm command dialog', function() local screen local function start_new() clear() - screen = Screen.new(60, 20) + screen = Screen.new(75, 20) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- StatusLine, MsgSeparator + [2] = {reverse = true}, -- StatusLineNC + [3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + }) screen:attach() end - write_file('foo', 'foo1\n') - write_file('bar', 'bar1\n') - - -- Test for saving all the modified buffers - start_new() - command("set nomore") - command("new foo") - command("call setline(1, 'foo2')") - command("new bar") - command("call setline(1, 'bar2')") - command("wincmd b") - feed(':confirm qall\n') - screen:expect([[ - bar2 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo2 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - ~ | - ~ | - | - :confirm qall | - Save changes to "bar"? | - [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | - ]]) - feed('A') - poke_eventloop() - - eq('foo2\n', read_file('foo')) - eq('bar2\n', read_file('bar')) - - -- Test for discarding all the changes to modified buffers - start_new() - command("set nomore") - command("new foo") - command("call setline(1, 'foo3')") - command("new bar") - command("call setline(1, 'bar3')") - command("wincmd b") - feed(':confirm qall\n') - screen:expect([[ - bar3 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo3 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - ~ | - ~ | - | - :confirm qall | - Save changes to "bar"? | - [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | - ]]) - feed('D') - poke_eventloop() - - eq('foo2\n', read_file('foo')) - eq('bar2\n', read_file('bar')) - - -- Test for saving and discarding changes to some buffers - start_new() - command("set nomore") - command("new foo") - command("call setline(1, 'foo4')") - command("new bar") - command("call setline(1, 'bar4')") - command("wincmd b") - feed(':confirm qall\n') - screen:expect([[ - bar4 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo4 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - ~ | - ~ | - | - :confirm qall | - Save changes to "bar"? | - [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | - ]]) - feed('N') - screen:expect([[ - bar4 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo4 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - | - :confirm qall | - Save changes to "bar"? | - | - Save changes to "foo"? | - [Y]es, (N)o, (C)ancel: ^ | - ]]) - feed('Y') - poke_eventloop() - - eq('foo4\n', read_file('foo')) - eq('bar2\n', read_file('bar')) - - os.remove('foo') - os.remove('bar') + -- Test for the :confirm command dialog + -- oldtest: Test_confirm_cmd() + it('works', function() + write_file('Xfoo', 'foo1\n') + write_file('Xbar', 'bar1\n') + + -- Test for saving all the modified buffers + start_new() + exec([[ + set nomore + new Xfoo + call setline(1, 'foo2') + new Xbar + call setline(1, 'bar2') + wincmd b + ]]) + feed(':confirm qall\n') + screen:expect([[ + bar2 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo2 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {0:~ }| + {0:~ }| + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + ]]) + expect_exit(100, feed, 'A') + + eq('foo2\n', read_file('Xfoo')) + eq('bar2\n', read_file('Xbar')) + + -- Test for discarding all the changes to modified buffers + start_new() + exec([[ + set nomore + new Xfoo + call setline(1, 'foo3') + new Xbar + call setline(1, 'bar3') + wincmd b + ]]) + feed(':confirm qall\n') + screen:expect([[ + bar3 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo3 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {0:~ }| + {0:~ }| + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + ]]) + expect_exit(100, feed, 'D') + + eq('foo2\n', read_file('Xfoo')) + eq('bar2\n', read_file('Xbar')) + + -- Test for saving and discarding changes to some buffers + start_new() + exec([[ + set nomore + new Xfoo + call setline(1, 'foo4') + new Xbar + call setline(1, 'bar4') + wincmd b + ]]) + feed(':confirm qall\n') + screen:expect([[ + bar4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {0:~ }| + {0:~ }| + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + ]]) + feed('N') + screen:expect([[ + bar4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + | + {3:Save changes to "Xfoo"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + expect_exit(100, feed, 'Y') + + eq('foo4\n', read_file('Xfoo')) + eq('bar2\n', read_file('Xbar')) + + os.remove('Xfoo') + os.remove('Xbar') + end) + + -- oldtest: Test_confirm_cmd_cancel() + it('can be cancelled', function() + -- Test for closing a window with a modified buffer + start_new() + screen:try_resize(75, 10) + exec([[ + set nohidden nomore + new + call setline(1, 'abc') + ]]) + feed(':confirm close\n') + screen:expect([[ + abc | + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] [+] }| + | + {1: }| + :confirm close | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('C') + screen:expect([[ + ^abc | + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] [+] }| + | + {0:~ }| + {0:~ }| + {2:[No Name] }| + | + ]]) + feed(':confirm close\n') + screen:expect([[ + abc | + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] [+] }| + | + {1: }| + :confirm close | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('N') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + + -- oldtest: Test_confirm_q_wq() + it('works with :q and :wq', function() + write_file('Xfoo', 'foo') + start_new() + screen:try_resize(75, 8) + exec([[ + set hidden nomore + call setline(1, 'abc') + edit Xfoo + set nofixendofline + ]]) + feed(':confirm q\n') + screen:expect([[ + foo | + {0:~ }| + {0:~ }| + {0:~ }| + {1: }| + :confirm q | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('C') + screen:expect([[ + ^abc | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + command('edit Xfoo') + feed(':confirm wq\n') + screen:expect([[ + foo | + {0:~ }| + {0:~ }| + {0:~ }| + {1: }| + "Xfoo" [noeol] 1L, 3B written | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('C') + screen:expect([[ + ^abc | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + "Xfoo" [noeol] 1L, 3B written | + ]]) + + os.remove('Xfoo') + end) + + -- oldtest: Test_confirm_write_ro() + it('works when writing a read-only file', function() + write_file('Xconfirm_write_ro', 'foo\n') + start_new() + screen:try_resize(75, 8) + exec([[ + set ruler + set nobackup ff=unix cmdheight=2 + edit Xconfirm_write_ro + norm Abar + ]]) + + -- Try to write with 'ro' option. + feed(':set ro | confirm w\n') + screen:expect([[ + foobar | + {0:~ }| + {0:~ }| + {1: }| + :set ro | confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('N') + screen:expect([[ + fooba^r | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + 1,6 All | + ]]) + eq('foo\n', read_file('Xconfirm_write_ro')) + + feed(':confirm w\n') + screen:expect([[ + foobar | + {0:~ }| + {0:~ }| + {1: }| + :confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('Y') + if iswin() then + screen:expect([[ + foobar | + {0:~ }| + {1: }| + :confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + "Xconfirm_write_ro" [unix] 1L, 7B written | + {3:Press ENTER or type command to continue}^ | + ]]) + else + screen:expect([[ + foobar | + {0:~ }| + {1: }| + :confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + "Xconfirm_write_ro" 1L, 7B written | + {3:Press ENTER or type command to continue}^ | + ]]) + end + eq('foobar\n', read_file('Xconfirm_write_ro')) + feed('<CR>') -- suppress hit-enter prompt + + -- Try to write with read-only file permissions. + funcs.setfperm('Xconfirm_write_ro', 'r--r--r--') + feed(':set noro | silent undo | confirm w\n') + screen:expect([[ + foobar | + {0:~ }| + {1: }| + :set noro | silent undo | confirm w | + {3:File permissions of "Xconfirm_write_ro" are read-only.} | + {3:It may still be possible to write it.} | + {3:Do you wish to try?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('Y') + if iswin() then + screen:expect([[ + foobar | + {1: }| + :set noro | silent undo | confirm w | + {3:File permissions of "Xconfirm_write_ro" are read-only.} | + {3:It may still be possible to write it.} | + {3:Do you wish to try?} | + "Xconfirm_write_ro" [unix] 1L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + else + screen:expect([[ + foobar | + {1: }| + :set noro | silent undo | confirm w | + {3:File permissions of "Xconfirm_write_ro" are read-only.} | + {3:It may still be possible to write it.} | + {3:Do you wish to try?} | + "Xconfirm_write_ro" 1L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + end + eq('foo\n', read_file('Xconfirm_write_ro')) + feed('<CR>') -- suppress hit-enter prompt + + os.remove('Xconfirm_write_ro') + end) + + -- oldtest: Test_confirm_write_partial_file() + it('works when writing a partial file', function() + write_file('Xwrite_partial', 'a\nb\nc\nd\n') + start_new() + screen:try_resize(75, 8) + exec([[ + set ruler + set nobackup ff=unix cmdheight=2 + edit Xwrite_partial + ]]) + + feed(':confirm 2,3w\n') + screen:expect([[ + a | + b | + c | + d | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('N') + screen:expect([[ + ^a | + b | + c | + d | + {0:~ }| + {0:~ }| + | + 1,1 All | + ]]) + eq('a\nb\nc\nd\n', read_file('Xwrite_partial')) + os.remove('Xwrite_partial') + + feed(':confirm 2,3w\n') + screen:expect([[ + a | + b | + c | + d | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('Y') + if iswin() then + screen:expect([[ + a | + b | + c | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + "Xwrite_partial" [New][unix] 2L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + else + screen:expect([[ + a | + b | + c | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + "Xwrite_partial" [New] 2L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + end + eq('b\nc\n', read_file('Xwrite_partial')) + + os.remove('Xwrite_partial') + end) end) diff --git a/test/functional/legacy/global_spec.lua b/test/functional/legacy/global_spec.lua new file mode 100644 index 0000000000..9f4528530c --- /dev/null +++ b/test/functional/legacy/global_spec.lua @@ -0,0 +1,51 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local exec = helpers.exec +local feed = helpers.feed +local sleep = helpers.sleep + +before_each(clear) + +describe(':global', function() + -- oldtest: Test_interrupt_global() + it('can be interrupted using Ctrl-C in cmdline mode vim-patch:9.0.0082', function() + local screen = Screen.new(75, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, reverse = true}, -- MsgSeparator + [1] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg + }) + screen:attach() + + exec([[ + set nohlsearch noincsearch + cnoremap ; <Cmd>sleep 10<CR> + call setline(1, repeat(['foo'], 5)) + ]]) + + feed(':g/foo/norm :<C-V>;<CR>') + sleep(10) -- Wait for :sleep to start + feed('<C-C>') + screen:expect([[ + ^foo | + foo | + foo | + foo | + foo | + {1:Interrupted} | + ]]) + + -- Also test in Ex mode + feed('gQg/foo/norm :<C-V>;<CR>') + sleep(10) -- Wait for :sleep to start + feed('<C-C>') + screen:expect([[ + {0: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :g/foo/norm :; | + | + {1:Interrupted} | + :^ | + ]]) + end) +end) diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index b296ac909d..51c2406933 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -27,7 +27,16 @@ describe('messages', function() it('works', function() command('call setline(1, range(1, 100))') - feed(':%p#\n') + feed(':%pfoo<C-H><C-H><C-H>#') + screen:expect([[ + 1 | + 2 | + 3 | + 4 | + 5 | + :%p#^ | + ]]) + feed('\n') screen:expect([[ {2: 1 }1 | {2: 2 }2 | @@ -199,11 +208,11 @@ describe('messages', function() -- Up all the way with 'g'. feed('g') screen:expect([[ + :%p# | {2: 1 }1 | {2: 2 }2 | {2: 3 }3 | {2: 4 }4 | - {2: 5 }5 | {1:-- More --}^ | ]]) @@ -241,6 +250,18 @@ describe('messages', function() {1:Press ENTER or type command to continue}^ | ]]) + -- A command line that doesn't print text is appended to scrollback, + -- even if it invokes a nested command line. + feed([[:<C-R>=':'<CR>:<CR>g<lt>]]) + screen:expect([[ + {2: 97 }97 | + {2: 98 }98 | + {2: 99 }99 | + {2:100 }100 | + ::: | + {1:Press ENTER or type command to continue}^ | + ]]) + feed(':%p#\n') screen:expect([[ {2: 1 }1 | diff --git a/test/functional/legacy/syn_attr_spec.lua b/test/functional/legacy/syn_attr_spec.lua new file mode 100644 index 0000000000..06e8427e27 --- /dev/null +++ b/test/functional/legacy/syn_attr_spec.lua @@ -0,0 +1,60 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local command = helpers.command +local eq = helpers.eq +local eval = helpers.eval + +before_each(clear) + +-- oldtest: Test_missing_attr() +it('synIDattr() works', function() + local bool_attrs = { + 'bold', + 'italic', + 'reverse', + 'standout', + 'underline', + 'undercurl', + 'underdouble', + 'underdotted', + 'underdashed', + 'strikethrough', + 'nocombine', + } + + command('hi Mine cterm=NONE gui=NONE') + eq('Mine', eval([[synIDattr(hlID("Mine"), "name")]])) + for _, mode in ipairs({'cterm', 'gui'}) do + eq('', eval(([[synIDattr("Mine"->hlID(), "bg", '%s')]]):format(mode))) + eq('', eval(([[synIDattr("Mine"->hlID(), "fg", '%s')]]):format(mode))) + eq('', eval(([[synIDattr("Mine"->hlID(), "sp", '%s')]]):format(mode))) + for _, attr in ipairs(bool_attrs) do + eq('', eval(([[synIDattr(hlID("Mine"), "%s", '%s')]]):format(attr, mode))) + eq('', eval(([[synIDattr(hlID("Mine"), "%s", '%s')]]):format(attr, mode))) + eq('', eval(([[synIDattr(hlID("Mine"), "%s", '%s')]]):format(attr, mode))) + end + eq('', eval(([[synIDattr(hlID("Mine"), "inverse", '%s')]]):format(mode))) + end + + for i, attr1 in ipairs(bool_attrs) do + local attr2 = bool_attrs[i - 1] or bool_attrs[#bool_attrs] + + command(('hi Mine cterm=%s gui=%s'):format(attr1, attr2)) + eq('1', eval(([[synIDattr(hlID("Mine"), "%s", 'cterm')]]):format(attr1))) + eq('', eval(([[synIDattr(hlID("Mine"), "%s", 'cterm')]]):format(attr2))) + eq('', eval(([[synIDattr("Mine"->hlID(), "%s", 'gui')]]):format(attr1))) + eq('1', eval(([[synIDattr("Mine"->hlID(), "%s", 'gui')]]):format(attr2))) + + command(('hi Mine cterm=%s gui=%s'):format(attr2, attr1)) + eq('', eval(([[synIDattr("Mine"->hlID(), "%s", 'cterm')]]):format(attr1))) + eq('1', eval(([[synIDattr("Mine"->hlID(), "%s", 'cterm')]]):format(attr2))) + eq('1', eval(([[synIDattr(hlID("Mine"), "%s", 'gui')]]):format(attr1))) + eq('', eval(([[synIDattr(hlID("Mine"), "%s", 'gui')]]):format(attr2))) + end + + command('hi Mine cterm=reverse gui=inverse') + eq('1', eval([[synIDattr(hlID("Mine"), "reverse", 'cterm')]])) + eq('1', eval([[synIDattr(hlID("Mine"), "inverse", 'cterm')]])) + eq('1', eval([[synIDattr(hlID("Mine"), "reverse", 'gui')]])) + eq('1', eval([[synIDattr(hlID("Mine"), "inverse", 'gui')]])) +end) |