diff options
Diffstat (limited to 'test/functional/legacy')
137 files changed, 2386 insertions, 2077 deletions
diff --git a/test/functional/legacy/002_filename_recognition_spec.lua b/test/functional/legacy/002_filename_recognition_spec.lua index 26a62d92fe..dd1335df94 100644 --- a/test/functional/legacy/002_filename_recognition_spec.lua +++ b/test/functional/legacy/002_filename_recognition_spec.lua @@ -1,9 +1,10 @@ -- Test if URLs are recognized as filenames by commands such as "gf". Here -- we'll use `expand("<cfile>")` since "gf" would need to open the file. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('filename recognition', function() setup(clear) diff --git a/test/functional/legacy/004_bufenter_with_modelines_spec.lua b/test/functional/legacy/004_bufenter_with_modelines_spec.lua index 9b0df024c8..6865153452 100644 --- a/test/functional/legacy/004_bufenter_with_modelines_spec.lua +++ b/test/functional/legacy/004_bufenter_with_modelines_spec.lua @@ -1,9 +1,10 @@ -- Test for autocommand that changes current buffer on BufEnter event. -- Check if modelines are interpreted for the correct buffer. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('BufEnter with modelines', function() setup(clear) diff --git a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua index 8e977aa73e..4d2d06f942 100644 --- a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua +++ b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua @@ -1,10 +1,11 @@ -- Test for autocommand that deletes the current buffer on BufLeave event. -- Also test deleting the last buffer, should give a new, empty buffer. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local command, expect = helpers.command, helpers.expect -local poke_eventloop = helpers.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe('test5', function() setup(clear) diff --git a/test/functional/legacy/007_ball_buffer_list_spec.lua b/test/functional/legacy/007_ball_buffer_list_spec.lua index d4e4547c43..15f3b0b9b8 100644 --- a/test/functional/legacy/007_ball_buffer_list_spec.lua +++ b/test/functional/legacy/007_ball_buffer_list_spec.lua @@ -1,8 +1,9 @@ -- Test for autocommand that changes the buffer list, when doing ":ball". -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe(':ball', function() setup(clear) diff --git a/test/functional/legacy/008_autocommands_spec.lua b/test/functional/legacy/008_autocommands_spec.lua index 16f0216bc0..b7b411d631 100644 --- a/test/functional/legacy/008_autocommands_spec.lua +++ b/test/functional/legacy/008_autocommands_spec.lua @@ -1,13 +1,14 @@ -- Test for BufWritePre autocommand that deletes or unloads the buffer. -- Test for BufUnload autocommand that unloads all other buffers. -local helpers = require('test.functional.helpers')(after_each) -local source = helpers.source -local clear, command, expect, eq, eval = - helpers.clear, helpers.command, helpers.expect, helpers.eq, helpers.eval -local write_file, dedent = helpers.write_file, helpers.dedent -local read_file = helpers.read_file -local expect_exit = helpers.expect_exit +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source = n.source +local clear, command, expect, eq, eval = n.clear, n.command, n.expect, t.eq, n.eval +local write_file, dedent = t.write_file, t.dedent +local read_file = t.read_file +local expect_exit = n.expect_exit describe('autocommands that delete and unload buffers:', function() local test_file = 'Xtest-008_autocommands.out' diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua index eba878b99a..45965d8791 100644 --- a/test/functional/legacy/011_autocommands_spec.lua +++ b/test/functional/legacy/011_autocommands_spec.lua @@ -12,19 +12,14 @@ -- Use a FileChangedShell autocommand to avoid a prompt for "Xtestfile.gz" -- being modified outside of Vim (noticed on Solaris). -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local clear, feed_command, expect, eq, neq, dedent, write_file, feed = - helpers.clear, - helpers.feed_command, - helpers.expect, - helpers.eq, - helpers.neq, - helpers.dedent, - helpers.write_file, - helpers.feed -local command = helpers.command -local read_file = helpers.read_file -local is_os = helpers.is_os + n.clear, n.feed_command, n.expect, t.eq, t.neq, t.dedent, t.write_file, n.feed +local command = n.command +local read_file = t.read_file +local is_os = t.is_os local function has_gzip() local null = is_os('win') and 'nul' or '/dev/null' diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua index b428318e3f..5c9185982f 100644 --- a/test/functional/legacy/012_directory_spec.lua +++ b/test/functional/legacy/012_directory_spec.lua @@ -3,19 +3,20 @@ -- - "./dir", in directory relative to file -- - "dir", in directory relative to current dir -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local eq = helpers.eq -local neq = helpers.neq -local poke_eventloop = helpers.poke_eventloop -local fn = helpers.fn -local api = helpers.api -local clear = helpers.clear -local insert = helpers.insert -local command = helpers.command -local write_file = helpers.write_file -local expect_exit = helpers.expect_exit -local mkdir = helpers.mkdir +local eq = t.eq +local neq = t.neq +local poke_eventloop = n.poke_eventloop +local fn = n.fn +local api = n.api +local clear = n.clear +local insert = n.insert +local command = n.command +local write_file = t.write_file +local expect_exit = n.expect_exit +local mkdir = t.mkdir local function ls_dir_sorted(dirname) local files = {} @@ -44,8 +45,8 @@ describe("'directory' option", function() end) teardown(function() expect_exit(command, 'qall!') - helpers.rmdir('Xtest.je') - helpers.rmdir('Xtest2') + n.rmdir('Xtest.je') + n.rmdir('Xtest2') os.remove('Xtest1') end) diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua index d73ff06972..ac90f3f98b 100644 --- a/test/functional/legacy/015_alignment_spec.lua +++ b/test/functional/legacy/015_alignment_spec.lua @@ -2,9 +2,10 @@ -- Also test formatting a paragraph. -- Also test undo after ":%s" and formatting. -local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('alignment', function() setup(clear) diff --git a/test/functional/legacy/018_unset_smart_indenting_spec.lua b/test/functional/legacy/018_unset_smart_indenting_spec.lua index 94fbb283f4..851b3264d3 100644 --- a/test/functional/legacy/018_unset_smart_indenting_spec.lua +++ b/test/functional/legacy/018_unset_smart_indenting_spec.lua @@ -1,12 +1,12 @@ -- Tests for not doing smart indenting when it isn't set. -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local feed = helpers.feed -local clear = helpers.clear -local insert = helpers.insert -local expect = helpers.expect -local feed_command = helpers.feed_command +local feed = n.feed +local clear = n.clear +local insert = n.insert +local expect = n.expect +local feed_command = n.feed_command describe('unset smart indenting', function() before_each(clear) diff --git a/test/functional/legacy/019_smarttab_expandtab_spec.lua b/test/functional/legacy/019_smarttab_expandtab_spec.lua index 7b03ee8e99..3bdc76c220 100644 --- a/test/functional/legacy/019_smarttab_expandtab_spec.lua +++ b/test/functional/legacy/019_smarttab_expandtab_spec.lua @@ -1,9 +1,10 @@ -- Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set. -- Also test that dv_ works correctly -local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe([[performing "r<Tab>" with 'smarttab' and 'expandtab' set/not set, and "dv_"]], function() setup(clear) diff --git a/test/functional/legacy/020_blockwise_visual_spec.lua b/test/functional/legacy/020_blockwise_visual_spec.lua index 8d90b1c77d..f8df3dbf7e 100644 --- a/test/functional/legacy/020_blockwise_visual_spec.lua +++ b/test/functional/legacy/020_blockwise_visual_spec.lua @@ -2,9 +2,10 @@ -- First test for undo working properly when executing commands from a register. -- Also test this in an empty buffer. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('blockwise visual', function() setup(clear) diff --git a/test/functional/legacy/021_control_wi_spec.lua b/test/functional/legacy/021_control_wi_spec.lua index 94871433cd..64dbc47201 100644 --- a/test/functional/legacy/021_control_wi_spec.lua +++ b/test/functional/legacy/021_control_wi_spec.lua @@ -1,8 +1,9 @@ -- Tests for [ CTRL-I with a count and CTRL-W CTRL-I with a count -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('CTRL-W CTRL-I', function() setup(clear) diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua index 64b2f6fa95..97dc5b0153 100644 --- a/test/functional/legacy/023_edit_arguments_spec.lua +++ b/test/functional/legacy/023_edit_arguments_spec.lua @@ -1,9 +1,10 @@ -- Tests for complicated + argument to :edit command -local helpers = require('test.functional.helpers')(after_each) -local clear, insert = helpers.clear, helpers.insert -local command, expect = helpers.command, helpers.expect -local poke_eventloop = helpers.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, insert = n.clear, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe(':edit', function() setup(clear) diff --git a/test/functional/legacy/025_jump_tag_hidden_spec.lua b/test/functional/legacy/025_jump_tag_hidden_spec.lua index 33bab05404..b7090662e6 100644 --- a/test/functional/legacy/025_jump_tag_hidden_spec.lua +++ b/test/functional/legacy/025_jump_tag_hidden_spec.lua @@ -1,9 +1,11 @@ -- Test for jumping to a tag with 'hidden' set, with symbolic link in path of tag. -- This only works for Unix, because of the symbolic link. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('jump to a tag with hidden set', function() setup(clear) @@ -23,7 +25,7 @@ describe('jump to a tag with hidden set', function() feed_command('set hidden') -- Create a link from test25.dir to the current directory. - if helpers.is_os('win') then + if t.is_os('win') then feed_command('!rd /q/s test25.dir') feed_command('!mklink /j test25.dir .') else @@ -33,7 +35,7 @@ describe('jump to a tag with hidden set', function() -- Create tags.text, with the current directory name inserted. feed_command('/tags line') - feed_command('r !' .. (helpers.is_os('win') and 'cd' or 'pwd')) + feed_command('r !' .. (t.is_os('win') and 'cd' or 'pwd')) feed('d$/test<cr>') feed('hP:.w! tags.test<cr>') @@ -44,7 +46,7 @@ describe('jump to a tag with hidden set', function() feed('G<C-]> x:yank a<cr>') feed_command("call delete('tags.test')") feed_command("call delete('Xxx')") - if helpers.is_os('win') then + if t.is_os('win') then feed_command('!rd /q test25.dir') else feed_command('!rm -f test25.dir') diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua index ea8abed7ae..143985c726 100644 --- a/test/functional/legacy/026_execute_while_if_spec.lua +++ b/test/functional/legacy/026_execute_while_if_spec.lua @@ -1,11 +1,11 @@ -- Test for :execute, :while and :if -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local clear = helpers.clear -local expect = helpers.expect -local source = helpers.source -local command = helpers.command +local clear = n.clear +local expect = n.expect +local source = n.source +local command = n.command describe(':execute, :while and :if', function() setup(clear) diff --git a/test/functional/legacy/028_source_ctrl_v_spec.lua b/test/functional/legacy/028_source_ctrl_v_spec.lua index fabf831341..17d4e7cc2e 100644 --- a/test/functional/legacy/028_source_ctrl_v_spec.lua +++ b/test/functional/legacy/028_source_ctrl_v_spec.lua @@ -1,8 +1,9 @@ -- Test for sourcing a file with CTRL-V's at the end of the line -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('CTRL-V at the end of the line', function() setup(clear) diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua index c808a21afc..8d4cc70d8f 100644 --- a/test/functional/legacy/029_join_spec.lua +++ b/test/functional/legacy/029_join_spec.lua @@ -1,12 +1,12 @@ -- Test for joining lines with marks in them (and with 'joinspaces' set/reset) -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local feed = helpers.feed -local clear = helpers.clear -local insert = helpers.insert -local expect = helpers.expect -local feed_command = helpers.feed_command +local feed = n.feed +local clear = n.clear +local insert = n.insert +local expect = n.expect +local feed_command = n.feed_command describe('joining lines', function() before_each(clear) diff --git a/test/functional/legacy/030_fileformats_spec.lua b/test/functional/legacy/030_fileformats_spec.lua index e88afd9c47..1a44ed6cb6 100644 --- a/test/functional/legacy/030_fileformats_spec.lua +++ b/test/functional/legacy/030_fileformats_spec.lua @@ -1,9 +1,11 @@ -- Test for a lot of variations of the 'fileformats' option -local helpers = require('test.functional.helpers')(after_each) -local feed, clear, command = helpers.feed, helpers.clear, helpers.command -local eq, write_file = helpers.eq, helpers.write_file -local poke_eventloop = helpers.poke_eventloop +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local feed, clear, command = n.feed, n.clear, n.command +local eq, write_file = t.eq, t.write_file +local poke_eventloop = n.poke_eventloop describe('fileformats option', function() setup(function() @@ -254,7 +256,7 @@ describe('fileformats option', function() command('set nobinary ff&') -- Assert buffer contents. This has to be done manually as - -- helpers.expect() calls helpers.dedent() which messes up the white space + -- n.expect() calls t.dedent() which messes up the white space -- and carriage returns. eq( 'unix\n'.. @@ -387,6 +389,6 @@ describe('fileformats option', function() '10\n'.. 'unix\n'.. 'unix', - helpers.curbuf_contents()) + n.curbuf_contents()) end) end) diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua index 173ebf1cf4..974df0c21d 100644 --- a/test/functional/legacy/031_close_commands_spec.lua +++ b/test/functional/legacy/031_close_commands_spec.lua @@ -9,15 +9,15 @@ -- :buf -- :edit -local helpers = require('test.functional.helpers')(after_each) - -local feed = helpers.feed -local clear = helpers.clear -local source = helpers.source -local insert = helpers.insert -local expect = helpers.expect -local feed_command = helpers.feed_command -local expect_exit = helpers.expect_exit +local n = require('test.functional.testnvim')() + +local feed = n.feed +local clear = n.clear +local source = n.source +local insert = n.insert +local expect = n.expect +local feed_command = n.feed_command +local expect_exit = n.expect_exit describe('Commands that close windows and/or buffers', function() local function cleanup() diff --git a/test/functional/legacy/033_lisp_indent_spec.lua b/test/functional/legacy/033_lisp_indent_spec.lua index b27de6c16d..e3d06be6bf 100644 --- a/test/functional/legacy/033_lisp_indent_spec.lua +++ b/test/functional/legacy/033_lisp_indent_spec.lua @@ -1,10 +1,11 @@ -- Test for 'lisp' -- If the lisp feature is not enabled, this will fail! -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local command, expect = helpers.command, helpers.expect -local poke_eventloop = helpers.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe('lisp indent', function() setup(clear) diff --git a/test/functional/legacy/034_user_function_spec.lua b/test/functional/legacy/034_user_function_spec.lua index c30c7275f2..89bf3b8920 100644 --- a/test/functional/legacy/034_user_function_spec.lua +++ b/test/functional/legacy/034_user_function_spec.lua @@ -3,9 +3,10 @@ -- Also test that a builtin function cannot be replaced. -- Also test for regression when calling arbitrary expression. -local helpers = require('test.functional.helpers')(after_each) -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe( 'user functions, expr-mappings, overwrite protected builtin functions and regression on calling expressions', diff --git a/test/functional/legacy/035_increment_and_decrement_spec.lua b/test/functional/legacy/035_increment_and_decrement_spec.lua index 84eb9c0eee..b6486a8a27 100644 --- a/test/functional/legacy/035_increment_and_decrement_spec.lua +++ b/test/functional/legacy/035_increment_and_decrement_spec.lua @@ -1,9 +1,10 @@ -- Test Ctrl-A and Ctrl-X, which increment and decrement decimal, hexadecimal, -- and octal numbers. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('increment and decrement commands', function() setup(clear) diff --git a/test/functional/legacy/036_regexp_character_classes_spec.lua b/test/functional/legacy/036_regexp_character_classes_spec.lua index ed35b2b245..9c871e159c 100644 --- a/test/functional/legacy/036_regexp_character_classes_spec.lua +++ b/test/functional/legacy/036_regexp_character_classes_spec.lua @@ -1,8 +1,10 @@ -- Test character classes in regexp using regexpengine 0, 1, 2. -local helpers = require('test.functional.helpers')(after_each) -local clear, command, expect = helpers.clear, helpers.command, helpers.expect -local source, write_file = helpers.source, helpers.write_file +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, command, expect = n.clear, n.command, n.expect +local source, write_file = n.source, t.write_file local function sixlines(text) local result = '' @@ -13,14 +15,14 @@ local function sixlines(text) end local function diff(text, nodedent) - local fname = helpers.tmpname() + local fname = t.tmpname() command('w! ' .. fname) - helpers.poke_eventloop() + n.poke_eventloop() local data = io.open(fname):read('*all') if nodedent then - helpers.eq(text, data) + t.eq(text, data) else - helpers.eq(helpers.dedent(text), data) + t.eq(t.dedent(text), data) end os.remove(fname) end diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua index 2f85e7d5a3..b2edc5933f 100644 --- a/test/functional/legacy/038_virtual_replace_spec.lua +++ b/test/functional/legacy/038_virtual_replace_spec.lua @@ -1,8 +1,9 @@ -- Test Virtual replace mode. -local helpers = require('test.functional.helpers')(after_each) -local feed = helpers.feed -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed = n.feed +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('Virtual replace mode', function() setup(clear) diff --git a/test/functional/legacy/039_visual_block_mode_commands_spec.lua b/test/functional/legacy/039_visual_block_mode_commands_spec.lua index bc3fea765c..9fbf5ae774 100644 --- a/test/functional/legacy/039_visual_block_mode_commands_spec.lua +++ b/test/functional/legacy/039_visual_block_mode_commands_spec.lua @@ -1,11 +1,13 @@ -- Test Visual block mode commands -- And test "U" in Visual mode, also on German sharp S. -local helpers = require('test.functional.helpers')(after_each) -local nvim, eq = helpers.api, helpers.eq -local insert, feed = helpers.insert, helpers.feed -local clear, expect = helpers.clear, helpers.expect -local feed_command = helpers.feed_command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local api, eq = n.api, t.eq +local insert, feed = n.insert, n.feed +local clear, expect = n.clear, n.expect +local feed_command = n.feed_command describe('Visual block mode', function() before_each(function() @@ -204,7 +206,7 @@ describe('Visual block mode', function() feed('G2l') feed('2k<C-v>$gj<ESC>') feed_command([[let cpos=getpos("'>")]]) - local cpos = nvim.nvim_get_var('cpos') + local cpos = api.nvim_get_var('cpos') local expected = { col = 4, off = 0, diff --git a/test/functional/legacy/043_magic_settings_spec.lua b/test/functional/legacy/043_magic_settings_spec.lua index a88ccc2b42..ba4c2dab02 100644 --- a/test/functional/legacy/043_magic_settings_spec.lua +++ b/test/functional/legacy/043_magic_settings_spec.lua @@ -1,8 +1,9 @@ -- Tests for regexp with various magic settings. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('regexp with magic settings', function() setup(clear) diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua index 074ee094b4..99cb64c7e5 100644 --- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua +++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua @@ -3,9 +3,10 @@ -- -- This test contains both "test44" and "test99" from the old test suite. -local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect -- Runs the test protocol with the given 'regexpengine' setting. In the old test -- suite the test protocol was duplicated in test44 and test99, the only diff --git a/test/functional/legacy/046_multi_line_regexps_spec.lua b/test/functional/legacy/046_multi_line_regexps_spec.lua index 30ec76ea3e..a103b55581 100644 --- a/test/functional/legacy/046_multi_line_regexps_spec.lua +++ b/test/functional/legacy/046_multi_line_regexps_spec.lua @@ -1,9 +1,10 @@ -- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for multi-line regexps with ":s" -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local expect = helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect = n.expect describe('multi-line regexp', function() setup(clear) diff --git a/test/functional/legacy/054_buffer_local_autocommands_spec.lua b/test/functional/legacy/054_buffer_local_autocommands_spec.lua index c8b9dfa98f..afde6f220a 100644 --- a/test/functional/legacy/054_buffer_local_autocommands_spec.lua +++ b/test/functional/legacy/054_buffer_local_autocommands_spec.lua @@ -1,10 +1,10 @@ -- Some tests for buffer-local autocommands -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local clear = helpers.clear -local expect = helpers.expect -local command = helpers.command +local clear = n.clear +local expect = n.expect +local command = n.command local fname = 'Xtest-functional-legacy-054' diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua index e8ae60e350..21d6b07a2d 100644 --- a/test/functional/legacy/055_list_and_dict_types_spec.lua +++ b/test/functional/legacy/055_list_and_dict_types_spec.lua @@ -1,8 +1,9 @@ -- Tests for List and Dictionary types. -local helpers = require('test.functional.helpers')(after_each) -local feed, source = helpers.feed, helpers.source -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, source = n.feed, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('list and dictionary types', function() before_each(clear) diff --git a/test/functional/legacy/056_script_local_function_spec.lua b/test/functional/legacy/056_script_local_function_spec.lua index 084817ad7a..dd99224edb 100644 --- a/test/functional/legacy/056_script_local_function_spec.lua +++ b/test/functional/legacy/056_script_local_function_spec.lua @@ -1,9 +1,10 @@ -- vim: set foldmethod=marker foldmarker=[[,]] : -- Test for script-local function. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local expect = helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect = n.expect describe('source function', function() setup(clear) diff --git a/test/functional/legacy/057_sort_spec.lua b/test/functional/legacy/057_sort_spec.lua index 9b4746591f..8b0664d50c 100644 --- a/test/functional/legacy/057_sort_spec.lua +++ b/test/functional/legacy/057_sort_spec.lua @@ -1,10 +1,11 @@ -- Tests for :sort command. -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local insert, command, clear, expect, eq, poke_eventloop = - helpers.insert, helpers.command, helpers.clear, helpers.expect, helpers.eq, helpers.poke_eventloop -local exc_exec = helpers.exc_exec + n.insert, n.command, n.clear, n.expect, t.eq, n.poke_eventloop +local exc_exec = n.exc_exec describe(':sort', function() local text = [[ diff --git a/test/functional/legacy/060_exists_and_has_functions_spec.lua b/test/functional/legacy/060_exists_and_has_functions_spec.lua index 82fece3e84..ec29b6cf04 100644 --- a/test/functional/legacy/060_exists_and_has_functions_spec.lua +++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua @@ -1,9 +1,11 @@ -- Tests for the exists() and has() functions. -local helpers = require('test.functional.helpers')(after_each) -local source = helpers.source -local clear, expect = helpers.clear, helpers.expect -local write_file = helpers.write_file +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source = n.source +local clear, expect = n.clear, n.expect +local write_file = t.write_file describe('exists() and has() functions', function() setup(function() diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua index b5af8f7d52..4177f908a1 100644 --- a/test/functional/legacy/061_undo_tree_spec.lua +++ b/test/functional/legacy/061_undo_tree_spec.lua @@ -1,18 +1,19 @@ -- Tests for undo tree and :earlier and :later. -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local feed_command = helpers.feed_command -local write_file = helpers.write_file -local command = helpers.command -local source = helpers.source -local expect = helpers.expect -local clear = helpers.clear -local feed = helpers.feed -local eval = helpers.eval -local eq = helpers.eq +local feed_command = n.feed_command +local write_file = t.write_file +local command = n.command +local source = n.source +local expect = n.expect +local clear = n.clear +local feed = n.feed +local eval = n.eval +local eq = t.eq local function expect_empty_buffer() - -- The space will be removed by helpers.dedent but is needed because dedent + -- The space will be removed by t.dedent but is needed because dedent -- will fail if it can not find the common indent of the given lines. return expect(' ') end @@ -99,7 +100,7 @@ describe('undo tree:', function() expect_line('123456abc') end - helpers.retry(2, nil, test_earlier_later) + t.retry(2, nil, test_earlier_later) end) it('file-write specifications', function() diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua index 0c2b59932b..7515bcf182 100644 --- a/test/functional/legacy/063_match_and_matchadd_spec.lua +++ b/test/functional/legacy/063_match_and_matchadd_spec.lua @@ -1,10 +1,10 @@ -- Tests for adjusting window and contents -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, command = helpers.clear, helpers.command -local insert = helpers.insert +local clear, command = n.clear, n.command +local insert = n.insert describe('063: Test for ":match", "matchadd()" and related functions', function() setup(clear) @@ -12,10 +12,6 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( it('is working', function() local screen = Screen.new(40, 5) screen:attach() - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, - [1] = { background = Screen.colors.Red }, - }) command('highlight MyGroup1 term=bold ctermbg=red guibg=red') command('highlight MyGroup2 term=italic ctermbg=green guibg=green') @@ -25,8 +21,8 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( insert('abcdefghijklmnopq') command("call matchaddpos('MyGroup1', [[1, 5], [1, 8, 3]], 10, 3)") screen:expect([[ - abcd{1:e}fg{1:hij}klmnop^q | - {0:~ }|*3 + abcd{30:e}fg{30:hij}klmnop^q | + {1:~ }|*3 | ]]) @@ -34,8 +30,8 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( command("call setline(1, 'abcdΣabcdef')") command("call matchaddpos('MyGroup1', [[1, 4, 2], [1, 9, 2]])") screen:expect([[ - abc{1:dΣ}ab{1:cd}e^f | - {0:~ }|*3 + abc{30:dΣ}ab{30:cd}e^f | + {1:~ }|*3 | ]]) end) diff --git a/test/functional/legacy/065_float_and_logic_operators_spec.lua b/test/functional/legacy/065_float_and_logic_operators_spec.lua index ad1b004085..0835a3df52 100644 --- a/test/functional/legacy/065_float_and_logic_operators_spec.lua +++ b/test/functional/legacy/065_float_and_logic_operators_spec.lua @@ -1,8 +1,9 @@ -- Test for floating point and logical operators. -local helpers = require('test.functional.helpers')(after_each) -local insert, source = helpers.insert, helpers.source -local clear, expect = helpers.clear, helpers.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('floating point and logical operators', function() setup(clear) diff --git a/test/functional/legacy/066_visual_block_tab_spec.lua b/test/functional/legacy/066_visual_block_tab_spec.lua index f10152d8ea..6e92bd4c65 100644 --- a/test/functional/legacy/066_visual_block_tab_spec.lua +++ b/test/functional/legacy/066_visual_block_tab_spec.lua @@ -1,9 +1,10 @@ -- vim: set foldmethod=marker foldmarker=[[,]] : -- Test for visual block shift and tab characters. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('visual block shift and tab characters', function() setup(clear) diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua index 4a77bf838a..82b9c4bfa3 100644 --- a/test/functional/legacy/067_augroup_exists_spec.lua +++ b/test/functional/legacy/067_augroup_exists_spec.lua @@ -1,9 +1,10 @@ -- Test that groups and patterns are tested correctly when calling exists() for -- autocommands. -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command, expect = helpers.command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('augroup when calling exists()', function() setup(clear) diff --git a/test/functional/legacy/068_text_formatting_spec.lua b/test/functional/legacy/068_text_formatting_spec.lua index 3a1b21bf87..179c15fb0f 100644 --- a/test/functional/legacy/068_text_formatting_spec.lua +++ b/test/functional/legacy/068_text_formatting_spec.lua @@ -1,10 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local feed = helpers.feed -local clear = helpers.clear -local insert = helpers.insert -local feed_command = helpers.feed_command -local expect = helpers.expect +local feed = n.feed +local clear = n.clear +local insert = n.insert +local feed_command = n.feed_command +local expect = n.expect describe('text formatting', function() setup(clear) diff --git a/test/functional/legacy/069_multibyte_formatting_spec.lua b/test/functional/legacy/069_multibyte_formatting_spec.lua index 05e6aa1435..24a4692e6c 100644 --- a/test/functional/legacy/069_multibyte_formatting_spec.lua +++ b/test/functional/legacy/069_multibyte_formatting_spec.lua @@ -3,15 +3,11 @@ -- And test "ra" on multibyte characters. -- Also test byteidx() and byteidxcomp() -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local feed, insert, eq, eval, clear, feed_command, expect = - helpers.feed, - helpers.insert, - helpers.eq, - helpers.eval, - helpers.clear, - helpers.feed_command, - helpers.expect + n.feed, n.insert, t.eq, n.eval, n.clear, n.feed_command, n.expect describe('multibyte text', function() before_each(clear) diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua index 80665027c3..f7185dacff 100644 --- a/test/functional/legacy/072_undo_file_spec.lua +++ b/test/functional/legacy/072_undo_file_spec.lua @@ -2,9 +2,10 @@ -- Since this script is sourced we need to explicitly break changes up in -- undo-able pieces. Do that by setting 'undolevels'. -local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('72', function() setup(clear) diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua index 0a9ad330c2..d56a2654e3 100644 --- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua +++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua @@ -1,8 +1,10 @@ -- Tests for storing global variables in the .shada file -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local clear, command, eq, neq, eval, poke_eventloop = - helpers.clear, helpers.command, helpers.eq, helpers.neq, helpers.eval, helpers.poke_eventloop + n.clear, n.command, t.eq, t.neq, n.eval, n.poke_eventloop describe('storing global variables in ShaDa files', function() local tempname = 'Xtest-functional-legacy-074' diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua index dc5b1a8540..fa53482393 100644 --- a/test/functional/legacy/078_swapfile_recover_spec.lua +++ b/test/functional/legacy/078_swapfile_recover_spec.lua @@ -3,8 +3,9 @@ -- restored. We need about 10000 lines of 100 characters to get two levels of -- pointer blocks. -local helpers = require('test.functional.helpers')(after_each) -local clear, expect, source = helpers.clear, helpers.expect, helpers.source +local n = require('test.functional.testnvim')() + +local clear, expect, source = n.clear, n.expect, n.source describe('78', function() setup(clear) diff --git a/test/functional/legacy/081_coptions_movement_spec.lua b/test/functional/legacy/081_coptions_movement_spec.lua index d82c46a3d3..cfa65f5c8a 100644 --- a/test/functional/legacy/081_coptions_movement_spec.lua +++ b/test/functional/legacy/081_coptions_movement_spec.lua @@ -1,8 +1,9 @@ -- Test for t movement command and 'cpo-;' setting -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('coptions', function() setup(clear) diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua index 311822c34f..3d91dc4b34 100644 --- a/test/functional/legacy/082_string_comparison_spec.lua +++ b/test/functional/legacy/082_string_comparison_spec.lua @@ -1,9 +1,10 @@ -- Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c) -- Also test "g~ap". -local helpers = require('test.functional.helpers')(after_each) -local feed, source = helpers.feed, helpers.source -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, source = n.feed, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('case-insensitive string comparison in UTF-8', function() setup(clear) diff --git a/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua index 5e9c131c64..05154f660d 100644 --- a/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua +++ b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua @@ -1,12 +1,14 @@ -- Tests for tag search with !_TAG_FILE_ENCODING. -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local insert, source, clear, expect, write_file = - helpers.insert, helpers.source, helpers.clear, helpers.expect, helpers.write_file + n.insert, n.source, n.clear, n.expect, t.write_file local function has_iconv() clear() -- ensures session - return 1 == helpers.eval('has("iconv")') + return 1 == n.eval('has("iconv")') end describe('tag search with !_TAG_FILE_ENCODING', function() @@ -31,7 +33,7 @@ describe('tag search with !_TAG_FILE_ENCODING', function() ) -- The last file is very long but repetitive and can be generated on the -- fly. - local text = helpers.dedent([[ + local text = t.dedent([[ !_TAG_FILE_SORTED 1 // !_TAG_FILE_ENCODING cp932 // ]]) diff --git a/test/functional/legacy/090_sha256_spec.lua b/test/functional/legacy/090_sha256_spec.lua index 701b777df1..648eb65550 100644 --- a/test/functional/legacy/090_sha256_spec.lua +++ b/test/functional/legacy/090_sha256_spec.lua @@ -1,8 +1,9 @@ -- Tests for sha256() function. -local helpers = require('test.functional.helpers')(after_each) -local insert, source = helpers.insert, helpers.source -local clear, expect = helpers.clear, helpers.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('sha256()', function() setup(clear) diff --git a/test/functional/legacy/091_context_variables_spec.lua b/test/functional/legacy/091_context_variables_spec.lua index 3b9fdf740f..cc3ee6787a 100644 --- a/test/functional/legacy/091_context_variables_spec.lua +++ b/test/functional/legacy/091_context_variables_spec.lua @@ -1,8 +1,9 @@ -- Tests for getbufvar(), getwinvar(), gettabvar() and gettabwinvar(). -local helpers = require('test.functional.helpers')(after_each) -local insert, source = helpers.insert, helpers.source -local clear, expect = helpers.clear, helpers.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('context variables', function() setup(clear) diff --git a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua index 3c46c29951..d478545077 100644 --- a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua +++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua @@ -3,9 +3,10 @@ -- -- Same as legacy test 93 but using UTF-8 file encoding. -local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('store cursor position in session file in UTF-8', function() setup(clear) diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua index f09fd9a6e5..5e5e465c01 100644 --- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua +++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua @@ -3,9 +3,10 @@ -- -- Same as legacy test 92 but using Latin-1 file encoding. -local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('store cursor position in session file in Latin-1', function() setup(clear) diff --git a/test/functional/legacy/094_visual_mode_operators_spec.lua b/test/functional/legacy/094_visual_mode_operators_spec.lua index ff1d3e7bec..279c6a432a 100644 --- a/test/functional/legacy/094_visual_mode_operators_spec.lua +++ b/test/functional/legacy/094_visual_mode_operators_spec.lua @@ -4,9 +4,10 @@ -- followed by an operator and those executed via Operator-pending mode. Also -- part of the test are mappings, counts, and repetition with the . command. -local helpers = require('test.functional.helpers')(after_each) -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect -- Vim script user functions needed for some of the test cases. local function source_user_functions() diff --git a/test/functional/legacy/095_regexp_multibyte_spec.lua b/test/functional/legacy/095_regexp_multibyte_spec.lua index fad0dc8023..296bf00b58 100644 --- a/test/functional/legacy/095_regexp_multibyte_spec.lua +++ b/test/functional/legacy/095_regexp_multibyte_spec.lua @@ -3,9 +3,10 @@ -- A pattern that gives the expected result produces OK, so that we know it was -- actually tried. -local helpers = require('test.functional.helpers')(after_each) -local insert, source = helpers.insert, helpers.source -local clear, expect = helpers.clear, helpers.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('regex with multi-byte', function() setup(clear) diff --git a/test/functional/legacy/096_location_list_spec.lua b/test/functional/legacy/096_location_list_spec.lua index 2817d5d240..27bbe706bb 100644 --- a/test/functional/legacy/096_location_list_spec.lua +++ b/test/functional/legacy/096_location_list_spec.lua @@ -6,9 +6,10 @@ -- C. make sure that the location list window is not reused instead of the window -- it belongs to. -local helpers = require('test.functional.helpers')(after_each) -local source = helpers.source -local clear, command, expect = helpers.clear, helpers.command, helpers.expect +local n = require('test.functional.testnvim')() + +local source = n.source +local clear, command, expect = n.clear, n.command, n.expect describe('location list', function() local test_file = 'Xtest-096_location_list.out' diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua index b335b3bf41..4d4bb9e78f 100644 --- a/test/functional/legacy/097_glob_path_spec.lua +++ b/test/functional/legacy/097_glob_path_spec.lua @@ -2,15 +2,17 @@ -- Test whether glob()/globpath() return correct results with certain escaped -- characters. -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command, expect = helpers.command, helpers.expect +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('glob() and globpath()', function() setup(clear) setup(function() - if helpers.is_os('win') then + if t.is_os('win') then os.execute('md sautest\\autoload') os.execute('.>sautest\\autoload\\Test104.vim 2>nul') os.execute('.>sautest\\autoload\\footest.vim 2>nul') @@ -28,7 +30,7 @@ describe('glob() and globpath()', function() -- Consistent sorting of file names command('set nofileignorecase') - if helpers.is_os('win') then + if t.is_os('win') then command([[$put =glob('Xxx{')]]) command([[$put =glob('Xxx$')]]) @@ -72,7 +74,7 @@ describe('glob() and globpath()', function() end) teardown(function() - if helpers.is_os('win') then + if t.is_os('win') then os.execute('del /q/f Xxx{ Xxx$') os.execute('rd /q /s sautest') else diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua index eff755221c..88f1c31b23 100644 --- a/test/functional/legacy/101_hlsearch_spec.lua +++ b/test/functional/legacy/101_hlsearch_spec.lua @@ -1,8 +1,9 @@ -- Test for v:hlsearch -local helpers = require('test.functional.helpers')(after_each) -local clear, feed = helpers.clear, helpers.feed -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed = n.clear, n.feed +local feed_command, expect = n.feed_command, n.expect describe('v:hlsearch', function() setup(clear) diff --git a/test/functional/legacy/102_fnameescape_spec.lua b/test/functional/legacy/102_fnameescape_spec.lua index 11bdbd7c9c..f0361c2f5a 100644 --- a/test/functional/legacy/102_fnameescape_spec.lua +++ b/test/functional/legacy/102_fnameescape_spec.lua @@ -1,8 +1,9 @@ -- Test if fnameescape is correct for special chars like! -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command, expect = helpers.command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('fnameescape', function() setup(clear) diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua index f5cd861019..b6fdf8cc68 100644 --- a/test/functional/legacy/103_visual_mode_reset_spec.lua +++ b/test/functional/legacy/103_visual_mode_reset_spec.lua @@ -1,8 +1,9 @@ -- Test for visual mode not being reset causing E315 error. -local helpers = require('test.functional.helpers')(after_each) -local feed, source = helpers.feed, helpers.source -local clear, expect = helpers.clear, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, source = n.feed, n.source +local clear, expect = n.clear, n.expect describe('E315 error', function() setup(clear) diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua index 2a83d48c07..4189b568a2 100644 --- a/test/functional/legacy/106_errorformat_spec.lua +++ b/test/functional/legacy/106_errorformat_spec.lua @@ -1,8 +1,9 @@ -- Tests for errorformat. -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command, expect = helpers.command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, expect = n.command, n.expect describe('errorformat', function() setup(clear) diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua index 5a8fdda32d..57ecf76f3a 100644 --- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua +++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua @@ -1,12 +1,12 @@ -- Tests for adjusting window and contents -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local poke_eventloop = helpers.poke_eventloop -local clear = helpers.clear -local insert = helpers.insert -local command = helpers.command +local poke_eventloop = n.poke_eventloop +local clear = n.clear +local insert = n.insert +local command = n.command describe('107', function() setup(clear) @@ -50,7 +50,7 @@ describe('107', function() [1, '1 '] | [50, '50 '] | ^[59, '59 '] | - ~ |*9 + {1:~ }|*9 3 more lines | ]]) end) diff --git a/test/functional/legacy/108_backtrace_debug_commands_spec.lua b/test/functional/legacy/108_backtrace_debug_commands_spec.lua index ccdd0cd2be..d2ae785813 100644 --- a/test/functional/legacy/108_backtrace_debug_commands_spec.lua +++ b/test/functional/legacy/108_backtrace_debug_commands_spec.lua @@ -1,9 +1,10 @@ -- Tests for backtrace debug commands. -local helpers = require('test.functional.helpers')(after_each) -local command = helpers.command -local feed, clear = helpers.feed, helpers.clear -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local command = n.command +local feed, clear = n.feed, n.clear +local feed_command, expect = n.feed_command, n.expect describe('108', function() before_each(clear) diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index 3e78d7ca5f..ac2a39a381 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -1,11 +1,13 @@ -- Test argument list commands -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, command, eq = helpers.clear, helpers.command, helpers.eq -local expect_exit = helpers.expect_exit -local feed = helpers.feed -local pcall_err = helpers.pcall_err + +local clear, command, eq = n.clear, n.command, t.eq +local expect_exit = n.expect_exit +local feed = n.feed +local pcall_err = t.pcall_err describe('argument list commands', function() before_each(clear) @@ -24,26 +26,26 @@ describe('argument list commands', function() feed(':confirm quit\n') screen:expect([[ | - ~ | - | + {1:~ }| + {3: }| :confirm quit | - 2 more files to edit. Quit anyway? | - [Y]es, (N)o: ^ | + {6:2 more files to edit. Quit anyway?} | + {6:[Y]es, (N)o: }^ | ]]) feed('N') screen:expect([[ ^ | - ~ |*4 + {1:~ }|*4 | ]]) feed(':confirm quit\n') screen:expect([[ | - ~ | - | + {1:~ }| + {3: }| :confirm quit | - 2 more files to edit. Quit anyway? | - [Y]es, (N)o: ^ | + {6:2 more files to edit. Quit anyway?} | + {6:[Y]es, (N)o: }^ | ]]) expect_exit(1000, feed, 'Y') end) diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua index 04c90281a7..47eea5e7d5 100644 --- a/test/functional/legacy/assert_spec.lua +++ b/test/functional/legacy/assert_spec.lua @@ -1,16 +1,18 @@ -local helpers = require('test.functional.helpers')(after_each) -local nvim, call = helpers.api, helpers.call -local clear, eq = helpers.clear, helpers.eq -local source, command = helpers.source, helpers.command -local exc_exec = helpers.exc_exec -local eval = helpers.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local api, call = n.api, n.call +local clear, eq = n.clear, t.eq +local source, command = n.source, n.command +local exc_exec = n.exc_exec +local eval = n.eval local function expected_errors(errors) - eq(errors, nvim.nvim_get_vvar('errors')) + eq(errors, api.nvim_get_vvar('errors')) end local function expected_empty() - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end describe('assert function:', function() diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua index e5980f5942..3bfa8bcd1e 100644 --- a/test/functional/legacy/autochdir_spec.lua +++ b/test/functional/legacy/autochdir_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eq, matches = helpers.clear, helpers.eq, helpers.matches -local eval, command, call, api = helpers.eval, helpers.command, helpers.call, helpers.api -local source, exec_capture = helpers.source, helpers.exec_capture -local mkdir = helpers.mkdir +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, matches = n.clear, t.eq, t.matches +local eval, command, call, api = n.eval, n.command, n.call, n.api +local source, exec_capture = n.source, n.exec_capture +local mkdir = t.mkdir local function expected_empty() eq({}, api.nvim_get_vvar('errors')) @@ -18,7 +20,7 @@ describe('autochdir behavior', function() end) after_each(function() - helpers.rmdir(dir) + n.rmdir(dir) end) -- Tests vim/vim#777 without test_autochdir(). diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua index 9966df263b..9a1ad991f7 100644 --- a/test/functional/legacy/autocmd_option_spec.lua +++ b/test/functional/legacy/autocmd_option_spec.lua @@ -1,11 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) -local nvim = helpers.api -local clear, eq, neq, eval = helpers.clear, helpers.eq, helpers.neq, helpers.eval -local api = helpers.api -local curbuf = helpers.api.nvim_get_current_buf -local curwin = helpers.api.nvim_get_current_win -local exec_capture = helpers.exec_capture -local source, command = helpers.source, helpers.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, neq, eval = n.clear, t.eq, t.neq, n.eval +local api = n.api +local curbuf = n.api.nvim_get_current_buf +local curwin = n.api.nvim_get_current_win +local exec_capture = n.exec_capture +local source, command = n.source, n.command local function declare_hook_function() source([[ @@ -39,7 +40,7 @@ local function init_var() end local function get_result() - local ret = nvim.nvim_get_var('ret') + local ret = api.nvim_get_var('ret') init_var() return ret end @@ -697,24 +698,24 @@ describe('au OptionSet', function() it('should trigger if a boolean option be set globally', function() set_hook('autochdir') - nvim.nvim_set_option_value('autochdir', true, { scope = 'global' }) - eq(true, nvim.nvim_get_option_value('autochdir', { scope = 'global' })) + api.nvim_set_option_value('autochdir', true, { scope = 'global' }) + eq(true, api.nvim_get_option_value('autochdir', { scope = 'global' })) expected_combination({ 'autochdir', false, '', false, true, 'global', 'setglobal' }) end) it('should trigger if a number option be set globally', function() set_hook('cmdheight') - nvim.nvim_set_option_value('cmdheight', 5, { scope = 'global' }) - eq(5, nvim.nvim_get_option_value('cmdheight', { scope = 'global' })) + api.nvim_set_option_value('cmdheight', 5, { scope = 'global' }) + eq(5, api.nvim_get_option_value('cmdheight', { scope = 'global' })) expected_combination({ 'cmdheight', 1, '', 1, 5, 'global', 'setglobal' }) end) it('should trigger if a string option be set globally', function() set_hook('ambiwidth') - nvim.nvim_set_option_value('ambiwidth', 'double', { scope = 'global' }) - eq('double', nvim.nvim_get_option_value('ambiwidth', { scope = 'global' })) + api.nvim_set_option_value('ambiwidth', 'double', { scope = 'global' }) + eq('double', api.nvim_get_option_value('ambiwidth', { scope = 'global' })) expected_combination({ 'ambiwidth', 'single', diff --git a/test/functional/legacy/autocmd_spec.lua b/test/functional/legacy/autocmd_spec.lua index 97051f3d3f..4d82da6312 100644 --- a/test/functional/legacy/autocmd_spec.lua +++ b/test/functional/legacy/autocmd_spec.lua @@ -1,10 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local write_file = helpers.write_file -local command = helpers.command -local feed = helpers.feed -local api = helpers.api -local eq = helpers.eq +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local write_file = t.write_file +local command = n.command +local feed = n.feed +local api = n.api +local eq = t.eq before_each(clear) diff --git a/test/functional/legacy/autoformat_join_spec.lua b/test/functional/legacy/autoformat_join_spec.lua index 22b1c258fe..9a240c8bda 100644 --- a/test/functional/legacy/autoformat_join_spec.lua +++ b/test/functional/legacy/autoformat_join_spec.lua @@ -1,9 +1,10 @@ -- Tests for setting the '[,'] marks when joining lines. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local command, expect = helpers.command, helpers.expect -local poke_eventloop = helpers.poke_eventloop +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local poke_eventloop = n.poke_eventloop describe('autoformat join', function() setup(clear) diff --git a/test/functional/legacy/breakindent_spec.lua b/test/functional/legacy/breakindent_spec.lua index cf0065f394..8c3d73b17b 100644 --- a/test/functional/legacy/breakindent_spec.lua +++ b/test/functional/legacy/breakindent_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local exec = helpers.exec -local feed = helpers.feed + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed before_each(clear) @@ -67,50 +68,43 @@ describe('breakindent', function() setlocal breakindent call setline(1, "\t" .. join(range(100))) ]]) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - [2] = { bold = true, reverse = true }, -- StatusLine - [3] = { reverse = true }, -- StatusLineNC - [4] = { bold = true }, -- ModeMsg - }) screen:attach() feed('v$') screen:expect([[ - {0:<<<} {1: 93 94 95 96 97 98 99}^ | - {2:[No Name] [+] }| + {1:<<<} {17: 93 94 95 96 97 98 99}^ | + {3:[No Name] [+] }| | - {0:~ }| - {3:[No Name] }| - {4:-- VISUAL --} | + {1:~ }| + {2:[No Name] }| + {5:-- VISUAL --} | ]]) command('setlocal showbreak=+++') screen:expect([[ - {0:+++}{1: 90 91 92 93 94 95 96 97 98 99}^ | - {2:[No Name] [+] }| + {1:+++}{17: 90 91 92 93 94 95 96 97 98 99}^ | + {3:[No Name] [+] }| | - {0:~ }| - {3:[No Name] }| - {4:-- VISUAL --} | + {1:~ }| + {2:[No Name] }| + {5:-- VISUAL --} | ]]) command('setlocal breakindentopt+=sbr') screen:expect([[ - {0:+++} {1: 93 94 95 96 97 98 99}^ | - {2:[No Name] [+] }| + {1:+++} {17: 93 94 95 96 97 98 99}^ | + {3:[No Name] [+] }| | - {0:~ }| - {3:[No Name] }| - {4:-- VISUAL --} | + {1:~ }| + {2:[No Name] }| + {5:-- VISUAL --} | ]]) command('setlocal nobreakindent') screen:expect([[ - {0:+++}{1: 98 99}^ | - {2:[No Name] [+] }| + {1:+++}{17: 98 99}^ | + {3:[No Name] [+] }| | - {0:~ }| - {3:[No Name] }| - {4:-- VISUAL --} | + {1:~ }| + {2:[No Name] }| + {5:-- VISUAL --} | ]]) end) end) diff --git a/test/functional/legacy/buffer_spec.lua b/test/functional/legacy/buffer_spec.lua deleted file mode 100644 index b3964540f0..0000000000 --- a/test/functional/legacy/buffer_spec.lua +++ /dev/null @@ -1,59 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, source = helpers.clear, helpers.source -local call, eq, api = helpers.call, helpers.eq, helpers.api - -local function expected_empty() - eq({}, api.nvim_get_vvar('errors')) -end - -describe('buffer', function() - before_each(function() - clear() - api.nvim_ui_attach(80, 24, {}) - api.nvim_set_option_value('hidden', false, {}) - end) - - it('deleting a modified buffer with :confirm', function() - source([[ - func Test_bdel_with_confirm() - new - call setline(1, 'test') - call assert_fails('bdel', 'E89:') - call nvim_input('c') - confirm bdel - call assert_equal(2, winnr('$')) - call assert_equal(1, &modified) - call nvim_input('n') - confirm bdel - call assert_equal(1, winnr('$')) - endfunc - ]]) - call('Test_bdel_with_confirm') - expected_empty() - end) - - it('editing another buffer from a modified buffer with :confirm', function() - source([[ - func Test_goto_buf_with_confirm() - new Xfile - enew - call setline(1, 'test') - call assert_fails('b Xfile', 'E37:') - call nvim_input('c') - call assert_fails('confirm b Xfile', 'E37:') - call assert_equal(1, &modified) - call assert_equal('', @%) - call nvim_input('y') - call assert_fails('confirm b Xfile', 'E37:') - call assert_equal(1, &modified) - call assert_equal('', @%) - call nvim_input('n') - confirm b Xfile - call assert_equal('Xfile', @%) - close! - endfunc - ]]) - call('Test_goto_buf_with_confirm') - expected_empty() - end) -end) diff --git a/test/functional/legacy/changelist_spec.lua b/test/functional/legacy/changelist_spec.lua index b673e74128..e2f87351de 100644 --- a/test/functional/legacy/changelist_spec.lua +++ b/test/functional/legacy/changelist_spec.lua @@ -1,9 +1,10 @@ -- Test changelist position after splitting window -- Set 'undolevels' to make changelist for sourced file -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('changelist', function() setup(clear) diff --git a/test/functional/legacy/charsearch_spec.lua b/test/functional/legacy/charsearch_spec.lua index c1a59c9ee1..da13b61e0f 100644 --- a/test/functional/legacy/charsearch_spec.lua +++ b/test/functional/legacy/charsearch_spec.lua @@ -1,8 +1,9 @@ -- Test for character searches -local helpers = require('test.functional.helpers')(after_each) -local feed, insert = helpers.feed, helpers.insert -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert = n.feed, n.insert +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('charsearch', function() setup(clear) diff --git a/test/functional/legacy/close_count_spec.lua b/test/functional/legacy/close_count_spec.lua index 930dae668a..0a08ad9fe6 100644 --- a/test/functional/legacy/close_count_spec.lua +++ b/test/functional/legacy/close_count_spec.lua @@ -1,13 +1,14 @@ -- Tests for :[count]close! and :[count]hide -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local eq = helpers.eq -local poke_eventloop = helpers.poke_eventloop -local eval = helpers.eval -local feed = helpers.feed -local clear = helpers.clear -local command = helpers.command +local eq = t.eq +local poke_eventloop = n.poke_eventloop +local eval = n.eval +local feed = n.feed +local clear = n.clear +local command = n.command describe('close_count', function() setup(clear) diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index 8c94451f9a..2e0e52117d 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -1,11 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local feed = helpers.feed -local feed_command = helpers.feed_command -local exec = helpers.exec -local api = helpers.api + +local clear = n.clear +local command = n.command +local feed = n.feed +local feed_command = n.feed_command +local exec = n.exec +local api = n.api local pesc = vim.pesc describe('cmdline', function() @@ -15,12 +16,6 @@ describe('cmdline', function() it('is cleared when switching tabs', function() local screen = Screen.new(30, 10) screen:attach() - screen:set_default_attr_ids { - [1] = { underline = true, background = Screen.colors.LightGrey }, - [2] = { bold = true }, - [3] = { reverse = true }, - [4] = { bold = true, foreground = Screen.colors.Blue1 }, - } feed_command([[call setline(1, range(30))]]) screen:expect([[ @@ -39,9 +34,9 @@ describe('cmdline', function() feed [[:tabnew<cr>]] screen:expect { grid = [[ - {1: + [No Name] }{2: [No Name] }{3: }{1:X}| + {24: + [No Name] }{5: [No Name] }{2: }{24:X}| ^ | - {4:~ }|*7 + {1:~ }|*7 :tabnew | ]], } @@ -49,9 +44,9 @@ describe('cmdline', function() feed [[<C-w>-<C-w>-]] screen:expect { grid = [[ - {1: + [No Name] }{2: [No Name] }{3: }{1:X}| + {24: + [No Name] }{5: [No Name] }{2: }{24:X}| ^ | - {4:~ }|*5 + {1:~ }|*5 |*3 ]], } @@ -59,7 +54,7 @@ describe('cmdline', function() feed [[gt]] screen:expect { grid = [[ - {2: + [No Name] }{1: [No Name] }{3: }{1:X}| + {5: + [No Name] }{24: [No Name] }{2: }{24:X}| ^0 | 1 | 2 | @@ -74,9 +69,9 @@ describe('cmdline', function() feed [[gt]] screen:expect([[ - {1: + [No Name] }{2: [No Name] }{3: }{1:X}| + {24: + [No Name] }{5: [No Name] }{2: }{24:X}| ^ | - {4:~ }|*5 + {1:~ }|*5 |*3 ]]) end) @@ -93,8 +88,8 @@ describe('cmdline', function() feed_command('DoSomething') screen:expect([[ | - ~ |*2 - | + {1:~ }|*2 + {3: }| Executing: DoSomething | Executing: echo 'hello' |set ts=4 |let v = '123' |echo v | hello | @@ -102,17 +97,13 @@ describe('cmdline', function() Executing: let v = '123' |echo v | Executing: echo v | 123 | - Press ENTER or type command to continue^ | + {6: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 @@ -120,9 +111,9 @@ describe('cmdline', function() ]]) feed(':') screen:expect([[ - {1:foo }| + {2:foo }| | - {0:~ }|*3 + {1:~ }|*3 :^ | ]]) end) @@ -130,9 +121,6 @@ describe('cmdline', function() -- oldtest: Test_redraw_in_autocmd() it('cmdline cursor position is correct after :redraw with cmdheight=2', function() local screen = Screen.new(30, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - }) screen:attach() exec([[ set cmdheight=2 @@ -141,7 +129,7 @@ describe('cmdline', function() feed(':for i in range(3)<CR>') screen:expect([[ | - {0:~ }|*3 + {1:~ }|*3 :for i in range(3) | : ^ | ]]) @@ -149,7 +137,7 @@ describe('cmdline', function() -- Note: this may still be considered broken, ref #18140 screen:expect([[ | - {0:~ }|*3 + {1:~ }|*3 : :let i =^ | | ]]) @@ -157,10 +145,6 @@ describe('cmdline', function() it("setting 'cmdheight' works after outputting two messages vim-patch:9.0.0665", function() local screen = Screen.new(60, 8) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, reverse = true }, -- StatusLine - }) screen:attach() exec([[ set cmdheight=1 laststatus=2 @@ -175,15 +159,15 @@ describe('cmdline', function() feed(':call EchoTwo()') screen:expect([[ | - {0:~ }|*5 - {1:[No Name] }| + {1:~ }|*5 + {3:[No Name] }| :call EchoTwo()^ | ]]) feed('<CR>') screen:expect([[ ^ | - {0:~ }|*5 - {1:[No Name] }| + {1:~ }|*5 + {3:[No Name] }| | ]]) end) @@ -191,21 +175,15 @@ describe('cmdline', function() -- oldtest: Test_cmdheight_tabline() it("changing 'cmdheight' when there is a tabline", function() local screen = Screen.new(60, 8) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, reverse = true }, -- StatusLine - [2] = { bold = true }, -- TabLineSel - [3] = { reverse = true }, -- TabLineFill - }) screen:attach() api.nvim_set_option_value('laststatus', 2, {}) api.nvim_set_option_value('showtabline', 2, {}) api.nvim_set_option_value('cmdheight', 1, {}) screen:expect([[ - {2: [No Name] }{3: }| + {5: [No Name] }{2: }| ^ | - {0:~ }|*4 - {1:[No Name] }| + {1:~ }|*4 + {3:[No Name] }| | ]]) end) @@ -213,9 +191,6 @@ describe('cmdline', function() -- oldtest: Test_rulerformat_position() it("ruler has correct position with 'rulerformat' set", function() local screen = Screen.new(20, 3) - screen:set_default_attr_ids { - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - } screen:attach() api.nvim_set_option_value('ruler', true, {}) api.nvim_set_option_value('rulerformat', 'longish', {}) @@ -224,7 +199,7 @@ describe('cmdline', function() feed [[<C-W>v<C-W>|<C-W>p]] screen:expect [[ │^ | - {0:~ }│{0:~}| + {1:~ }│{1:~}| longish | ]] end) diff --git a/test/functional/legacy/command_count_spec.lua b/test/functional/legacy/command_count_spec.lua index 8707c0459c..a6be459a4d 100644 --- a/test/functional/legacy/command_count_spec.lua +++ b/test/functional/legacy/command_count_spec.lua @@ -1,8 +1,9 @@ -- Test for user command counts -local helpers = require('test.functional.helpers')(after_each) -local clear, source, expect = helpers.clear, helpers.source, helpers.expect -local feed_command = helpers.feed_command +local n = require('test.functional.testnvim')() + +local clear, source, expect = n.clear, n.source, n.expect +local feed_command = n.feed_command -- luacheck: ignore 613 (Trailing whitespace in a string) describe('command_count', function() diff --git a/test/functional/legacy/comparators_spec.lua b/test/functional/legacy/comparators_spec.lua index 32e830a0af..86df5b1c41 100644 --- a/test/functional/legacy/comparators_spec.lua +++ b/test/functional/legacy/comparators_spec.lua @@ -1,8 +1,10 @@ -- " Test for expression comparators. -local helpers = require('test.functional.helpers')(after_each) -local clear, eq = helpers.clear, helpers.eq -local eval, command = helpers.eval, helpers.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq = n.clear, t.eq +local eval, command = n.eval, n.command describe('comparators', function() before_each(clear) diff --git a/test/functional/legacy/conceal_spec.lua b/test/functional/legacy/conceal_spec.lua index 9a23d16c5b..f4c1983bb7 100644 --- a/test/functional/legacy/conceal_spec.lua +++ b/test/functional/legacy/conceal_spec.lua @@ -1,12 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local exec = helpers.exec -local feed = helpers.feed + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed +local api = n.api local expect_pos = function(row, col) - return helpers.eq({ row, col }, helpers.eval('[screenrow(), screencol()]')) + return t.eq({ row, col }, n.eval('[screenrow(), screencol()]')) end describe('Conceal', function() @@ -18,12 +21,6 @@ describe('Conceal', function() -- oldtest: Test_conceal_two_windows() it('works', function() local screen = Screen.new(75, 12) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, reverse = true }, -- StatusLine - [2] = { reverse = true }, -- StatusLineNC, IncSearch - [3] = { bold = true }, -- ModeMsg - }) screen:attach() exec([[ let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"] @@ -47,12 +44,12 @@ describe('Conceal', function() two ^here | three three | Second window | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| one one one one one | two here | three three | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| /here | ]]) @@ -64,12 +61,12 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| one one one one one | two here | three three | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| /here | ]]) @@ -82,12 +79,12 @@ describe('Conceal', function() two |hidden| ^here | three three | Second window | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| one one one one one | two here | three three | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| /here | ]]) @@ -99,12 +96,12 @@ describe('Conceal', function() two here | three |hidden^| three | Second window | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| one one one one one | two here | three three | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| /here | ]]) @@ -116,13 +113,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| ^here | three three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| /here | ]]) @@ -133,13 +130,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two ^here | three three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| /here | ]]) feed('a') @@ -148,14 +145,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| h^ere | three three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- INSERT --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- INSERT --} | ]]) feed('<Esc>/e') screen:expect([[ @@ -163,13 +160,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| h{2:e}re | three three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| /e^ | ]]) feed('<Esc>v') @@ -178,14 +175,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| ^here | three three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- VISUAL --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- VISUAL --} | ]]) feed('<Esc>') @@ -196,13 +193,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| ^here | three three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| | ]]) feed('a') @@ -211,14 +208,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two h^ere | three three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- INSERT --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- INSERT --} | ]]) feed('<Esc>/e') screen:expect([[ @@ -226,13 +223,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| h{2:e}re | three three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| /e^ | ]]) feed('<Esc>v') @@ -241,14 +238,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| ^here | three three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- VISUAL --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- VISUAL --} | ]]) feed('<Esc>') @@ -259,13 +256,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| ^here | three three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| | ]]) feed('a') @@ -274,14 +271,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| h^ere | three three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- INSERT --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- INSERT --} | ]]) feed('<Esc>/e') screen:expect([[ @@ -289,13 +286,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| h{2:e}re | three three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| /e^ | ]]) feed('<Esc>v') @@ -304,14 +301,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two ^here | three three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- VISUAL --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- VISUAL --} | ]]) feed('<Esc>') @@ -323,14 +320,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two |hidden| h^ere | three three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- INSERT --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- INSERT --} | ]]) feed('<Down>') screen:expect([[ @@ -338,14 +335,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two here | three |hidden|^ three | - {0:~ }| - {1:[No Name] [+] }| - {3:-- INSERT --} | + {1:~ }| + {3:[No Name] [+] }| + {5:-- INSERT --} | ]]) feed('<Esc>') @@ -355,13 +352,13 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two here | three |hidden^| three | - {0:~ }| - {1:[No Name] [+] }| + {1:~ }| + {3:[No Name] [+] }| | ]]) feed('o') @@ -370,14 +367,14 @@ describe('Conceal', function() two here | three three | Second window | - {0:~ }| + {1:~ }| {2:[No Name] [+] }| one one one one one | two here | three three | ^ | - {1:[No Name] [+] }| - {3:-- INSERT --} | + {3:[No Name] [+] }| + {5:-- INSERT --} | ]]) feed('<Esc>') end) @@ -433,15 +430,73 @@ describe('Conceal', function() ]]) end) - -- oldtest: Test_conceal_resize_term() - it('resize editor', function() - local screen = Screen.new(75, 6) + -- oldtest: Test_conceal_wrapped_cursorline_wincolor() + it('CursorLine highlight on wrapped lines', function() + local screen = Screen.new(40, 4) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { background = Screen.colors.Green }, -- CursorLine (low-priority) + [2] = { foreground = Screen.colors.Red }, -- CursorLine (high-priority) + }) + screen:attach() + exec([[ + call setline(1, 'one one one |hidden| one one one one one one one one') + syntax match test /|hidden|/ conceal + set conceallevel=2 concealcursor=n cursorline + normal! g$ + hi! CursorLine guibg=Green + ]]) + screen:expect([[ + {1:one one one one one one one on^e }| + {1: one one one }| + {0:~ }| + | + ]]) + command('hi! CursorLine guibg=NONE guifg=Red') + screen:expect([[ + {2:one one one one one one one on^e }| + {2: one one one }| + {0:~ }| + | + ]]) + end) + + -- oldtest: Test_conceal_wrapped_cursorline_wincolor_rightleft() + it('CursorLine highlight on wrapped lines with rightleft', function() + local screen = Screen.new(40, 4) screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { foreground = Screen.colors.Blue }, -- Comment + [1] = { background = Screen.colors.Green }, -- CursorLine (low-priority) + [2] = { foreground = Screen.colors.Red }, -- CursorLine (high-priority) }) screen:attach() exec([[ + call setline(1, 'one one one |hidden| one one one one one one one one') + syntax match test /|hidden|/ conceal + set conceallevel=2 concealcursor=n cursorline rightleft + normal! g$ + hi! CursorLine guibg=Green + ]]) + screen:expect([[ + {1: ^eno eno eno eno eno eno eno eno}| + {1: eno eno eno }| + {0: ~}| + | + ]]) + command('hi! CursorLine guibg=NONE guifg=Red') + screen:expect([[ + {2: ^eno eno eno eno eno eno eno eno}| + {2: eno eno eno }| + {0: ~}| + | + ]]) + end) + + -- oldtest: Test_conceal_resize_term() + it('resize editor', function() + local screen = Screen.new(75, 6) + screen:attach() + exec([[ call setline(1, '`one` `two` `three` `four` `five`, the backticks should be concealed') setl cocu=n cole=3 syn region CommentCodeSpan matchgroup=Comment start=/`/ end=/`/ concealends @@ -449,14 +504,14 @@ describe('Conceal', function() ]]) screen:expect([[ one two three four five, the ^backticks should be concealed | - {0:~ }|*4 + {1:~ }|*4 | ]]) screen:try_resize(75, 7) screen:expect([[ one two three four five, the ^backticks should be concealed | - {0:~ }|*5 + {1:~ }|*5 | ]]) end) @@ -464,9 +519,6 @@ describe('Conceal', function() -- oldtest: Test_conceal_linebreak() it('with linebreak', function() local screen = Screen.new(75, 8) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - }) screen:attach() exec([[ let &wrap = v:true @@ -486,9 +538,9 @@ describe('Conceal', function() ^xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | - {0:+ }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | - {0:+ }cccccc | - {0:~ }|*2 + {1:+ }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + {1:+ }cccccc | + {1:~ }|*2 | ]]) end) @@ -570,4 +622,210 @@ describe('Conceal', function() feed('$') expect_pos(9, 26) end) + + local function test_conceal_virtualedit_after_eol(wrap) + local screen = Screen.new(60, 3) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + }) + screen:attach() + api.nvim_set_option_value('wrap', wrap, {}) + exec([[ + call setline(1, 'abcdefgh|hidden|ijklmnpop') + syntax match test /|hidden|/ conceal + set conceallevel=2 concealcursor=n virtualedit=all + normal! $ + ]]) + screen:expect([[ + abcdefghijklmnpo^p | + {0:~ }| + | + ]]) + feed('l') + screen:expect([[ + abcdefghijklmnpop^ | + {0:~ }| + | + ]]) + feed('l') + screen:expect([[ + abcdefghijklmnpop ^ | + {0:~ }| + | + ]]) + feed('l') + screen:expect([[ + abcdefghijklmnpop ^ | + {0:~ }| + | + ]]) + feed('rr') + screen:expect([[ + abcdefghijklmnpop ^r | + {0:~ }| + | + ]]) + end + + -- oldtest: Test_conceal_virtualedit_after_eol() + describe('cursor drawn at correct column with virtualedit', function() + it('with wrapping', function() + test_conceal_virtualedit_after_eol(true) + end) + it('without wrapping', function() + test_conceal_virtualedit_after_eol(false) + end) + end) + + local function test_conceal_virtualedit_after_eol_rightleft(wrap) + local screen = Screen.new(60, 3) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + }) + screen:attach() + api.nvim_set_option_value('wrap', wrap, {}) + exec([[ + call setline(1, 'abcdefgh|hidden|ijklmnpop') + syntax match test /|hidden|/ conceal + set conceallevel=2 concealcursor=n virtualedit=all rightleft + normal! $ + ]]) + screen:expect([[ + ^popnmlkjihgfedcba| + {0: ~}| + | + ]]) + feed('h') + screen:expect([[ + ^ popnmlkjihgfedcba| + {0: ~}| + | + ]]) + feed('h') + screen:expect([[ + ^ popnmlkjihgfedcba| + {0: ~}| + | + ]]) + feed('h') + screen:expect([[ + ^ popnmlkjihgfedcba| + {0: ~}| + | + ]]) + feed('rr') + screen:expect([[ + ^r popnmlkjihgfedcba| + {0: ~}| + | + ]]) + end + + -- oldtest: Test_conceal_virtualedit_after_eol_rightleft() + describe('cursor drawn correctly with virtualedit and rightleft', function() + it('with wrapping', function() + test_conceal_virtualedit_after_eol_rightleft(true) + end) + it('without wrapping', function() + test_conceal_virtualedit_after_eol_rightleft(false) + end) + end) + + local function test_conceal_double_width(wrap) + local screen = Screen.new(60, 4) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { background = Screen.colors.DarkGrey, foreground = Screen.colors.LightGrey }, + [2] = { background = Screen.colors.LightRed }, + }) + screen:attach() + api.nvim_set_option_value('wrap', wrap, {}) + exec([[ + call setline(1, ['aaaaa口=口bbbbb口=口ccccc', 'foobar']) + syntax match test /口=口/ conceal cchar=β + set conceallevel=2 concealcursor=n colorcolumn=30 + normal! $ + ]]) + screen:expect([[ + aaaaa{1:β}bbbbb{1:β}cccc^c {2: } | + foobar {2: } | + {0:~ }| + | + ]]) + feed('gM') + screen:expect([[ + aaaaa{1:β}bb^bbb{1:β}ccccc {2: } | + foobar {2: } | + {0:~ }| + | + ]]) + command('set conceallevel=3') + screen:expect([[ + aaaaabb^bbbccccc {2: } | + foobar {2: } | + {0:~ }| + | + ]]) + feed('$') + screen:expect([[ + aaaaabbbbbcccc^c {2: } | + foobar {2: } | + {0:~ }| + | + ]]) + end + + -- oldtest: Test_conceal_double_width() + describe('cursor drawn correctly when double-width chars are concealed', function() + it('with wrapping', function() + test_conceal_double_width(true) + end) + it('without wrapping', function() + test_conceal_double_width(false) + end) + end) + + -- oldtest: Test_conceal_double_width_wrap() + it('line wraps correctly when double-width chars are concealed', function() + local screen = Screen.new(20, 4) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { background = Screen.colors.DarkGrey, foreground = Screen.colors.LightGrey }, + [2] = { background = Screen.colors.LightRed }, + }) + screen:attach() + exec([[ + call setline(1, 'aaaaaaaaaa口=口bbbbbbbbbb口=口cccccccccc') + syntax match test /口=口/ conceal cchar=β + set conceallevel=2 concealcursor=n + normal! $ + ]]) + screen:expect([[ + aaaaaaaaaa{1:β}bbbbb | + bbbbb{1:β}ccccccccc^c | + {0:~ }| + | + ]]) + feed('gM') + screen:expect([[ + aaaaaaaaaa{1:β}bbbbb | + ^bbbbb{1:β}cccccccccc | + {0:~ }| + | + ]]) + command('set conceallevel=3') + screen:expect([[ + aaaaaaaaaabbbbb | + ^bbbbbcccccccccc | + {0:~ }| + | + ]]) + feed('$') + screen:expect([[ + aaaaaaaaaabbbbb | + bbbbbccccccccc^c | + {0:~ }| + | + ]]) + end) end) diff --git a/test/functional/legacy/cpoptions_spec.lua b/test/functional/legacy/cpoptions_spec.lua index 288146199a..56b0e72c72 100644 --- a/test/functional/legacy/cpoptions_spec.lua +++ b/test/functional/legacy/cpoptions_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local feed = helpers.feed + +local clear = n.clear +local command = n.command +local feed = n.feed before_each(clear) @@ -15,13 +16,13 @@ describe('cpoptions', function() feed('c2w') screen:expect([[ ^one tw$ three | - ~ |*4 - -- INSERT -- | + {1:~ }|*4 + {5:-- INSERT --} | ]]) feed('vim<Esc>') screen:expect([[ vi^m three | - ~ |*4 + {1:~ }|*4 | ]]) end) diff --git a/test/functional/legacy/crash_spec.lua b/test/functional/legacy/crash_spec.lua index 094bea253e..04f77c7d4f 100644 --- a/test/functional/legacy/crash_spec.lua +++ b/test/functional/legacy/crash_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) -local assert_alive = helpers.assert_alive -local clear = helpers.clear -local command = helpers.command -local feed = helpers.feed +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local clear = n.clear +local command = n.command +local feed = n.feed before_each(clear) diff --git a/test/functional/legacy/debugger_spec.lua b/test/functional/legacy/debugger_spec.lua index 7ed5e84da6..c6f552ab51 100644 --- a/test/functional/legacy/debugger_spec.lua +++ b/test/functional/legacy/debugger_spec.lua @@ -1,9 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local feed = helpers.feed -local write_file = helpers.write_file + +local clear = n.clear +local command = n.command +local feed = n.feed +local write_file = t.write_file before_each(clear) @@ -12,10 +14,6 @@ describe('debugger', function() before_each(function() screen = Screen.new(999, 10) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, - [1] = { reverse = true, bold = true }, - }) screen:attach() end) @@ -33,7 +31,7 @@ describe('debugger', function() screen:expect { grid = [[ ^let g:Xtest_var += 1{MATCH: *}| - {0:~{MATCH: *}}|*8 + {1:~{MATCH: *}}|*8 :source %{MATCH: *}| ]], } @@ -41,8 +39,8 @@ describe('debugger', function() screen:expect { grid = [[ let g:Xtest_var += 1{MATCH: *}| - {0:~{MATCH: *}}| - {1:{MATCH: *}}| + {1:~{MATCH: *}}| + {3:{MATCH: *}}| Breakpoint in "{MATCH:.*}XdebugBreakExpr.vim" line 1{MATCH: *}| Entering Debug mode. Type "cont" to continue.{MATCH: *}| Oldval = "10"{MATCH: *}| @@ -56,7 +54,7 @@ describe('debugger', function() screen:expect { grid = [[ ^let g:Xtest_var += 1{MATCH: *}| - {0:~{MATCH: *}}|*8 + {1:~{MATCH: *}}|*8 {MATCH: *}| ]], } @@ -64,8 +62,8 @@ describe('debugger', function() screen:expect { grid = [[ let g:Xtest_var += 1{MATCH: *}| - {0:~{MATCH: *}}| - {1:{MATCH: *}}| + {1:~{MATCH: *}}| + {3:{MATCH: *}}| Breakpoint in "{MATCH:.*}XdebugBreakExpr.vim" line 1{MATCH: *}| Entering Debug mode. Type "cont" to continue.{MATCH: *}| Oldval = "11"{MATCH: *}| diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index 1227065af2..f8e761c7f0 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -1,7 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, source = helpers.clear, helpers.source -local eq, eval, command = helpers.eq, helpers.eval, helpers.command -local exc_exec = helpers.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, source = n.clear, n.source +local eq, eval, command = t.eq, n.eval, n.command +local exc_exec = n.exc_exec describe('Test for delete()', function() before_each(clear) @@ -48,7 +50,7 @@ describe('Test for delete()', function() it('symlink directory delete', function() command("call mkdir('Xdir1')") - if helpers.is_os('win') then + if t.is_os('win') then command('silent !mklink /j Xlink Xdir1') else command('silent !ln -s Xdir1 Xlink') diff --git a/test/functional/legacy/digraph_spec.lua b/test/functional/legacy/digraph_spec.lua index 015f144b74..ed1071079c 100644 --- a/test/functional/legacy/digraph_spec.lua +++ b/test/functional/legacy/digraph_spec.lua @@ -1,7 +1,8 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local feed = helpers.feed + +local clear = n.clear +local feed = n.feed before_each(clear) @@ -9,29 +10,24 @@ describe('digraph', function() -- oldtest: Test_entering_digraph() it('characters displayed on the screen', function() local screen = Screen.new(10, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { foreground = Screen.colors.Blue }, -- SpecialKey - [2] = { bold = true }, -- ModeMsg - }) screen:attach() feed('i<C-K>') screen:expect([[ - {1:^?} | - {0:~ }|*4 - {2:-- INSERT --}| + {18:^?} | + {1:~ }|*4 + {5:-- INSERT --}| ]]) feed('1') screen:expect([[ - {1:^1} | - {0:~ }|*4 - {2:-- INSERT --}| + {18:^1} | + {1:~ }|*4 + {5:-- INSERT --}| ]]) feed('2') screen:expect([[ ½^ | - {0:~ }|*4 - {2:-- INSERT --}| + {1:~ }|*4 + {5:-- INSERT --}| ]]) end) end) diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua index 153fad2e22..98b9596847 100644 --- a/test/functional/legacy/display_spec.lua +++ b/test/functional/legacy/display_spec.lua @@ -1,10 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) - +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed -local command = helpers.command + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local command = n.command describe('display', function() before_each(clear) @@ -13,9 +13,6 @@ describe('display', function() it('scroll when modified at topline vim-patch:8.2.1488', function() local screen = Screen.new(20, 4) screen:attach() - screen:set_default_attr_ids({ - [1] = { bold = true }, - }) command([[call setline(1, repeat('a', 21))]]) feed('O') @@ -23,7 +20,7 @@ describe('display', function() ^ | aaaaaaaaaaaaaaaaaaaa| a | - {1:-- INSERT --} | + {5:-- INSERT --} | ]]) end) @@ -31,11 +28,6 @@ describe('display', function() it('scrolling when modified at topline in Visual mode vim-patch:8.2.4626', function() local screen = Screen.new(60, 8) screen:attach() - screen:set_default_attr_ids({ - [1] = { bold = true }, -- ModeMsg - [2] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - [3] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue }, -- SignColumn - }) exec([[ set scrolloff=0 @@ -47,9 +39,9 @@ describe('display', function() ]]) feed('VG7kk') screen:expect([[ - {3: }^f{2:oo} | - {3: }foo |*6 - {1:-- VISUAL LINE --} | + {7: }^f{17:oo} | + {7: }foo |*6 + {5:-- VISUAL LINE --} | ]]) end) @@ -149,7 +141,7 @@ describe('display', function() ]]) feed('736|') screen:expect([[ - <<<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*11 ^aaaaaaaaaaaaaaa | | @@ -157,22 +149,22 @@ describe('display', function() -- The correct part of the last line is moved into view. feed('D') screen:expect([[ - <<<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^a| - bbbbb bbbbb bbbbb bbbbb bbbbb bb@@@| + bbbbb bbbbb bbbbb bbbbb bbbbb bb{1:@@@}| | ]]) -- "w_skipcol" does not change because the topline is still long enough -- to maintain the current skipcol. feed('g04l11gkD') screen:expect([[ - <<<^a | + {1:<<<}^a | bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb| bbbbb ccccc ccccc ccccc ccccc cccc| c ccccc ccccc ddddd ddddd ddddd ddd| dd ddddd ddddd ddddd | - ~ |*8 + {1:~ }|*8 | ]]) -- "w_skipcol" is reset to bring the entire topline into view because @@ -183,7 +175,7 @@ describe('display', function() aa^a | bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb| bbbbb ccccc ccccc ccccc ccccc cccc| - c ccccc ccccc ddddd ddddd ddddd @@@| + c ccccc ccccc ddddd ddddd ddddd {1:@@@}| | ]]) end) @@ -197,7 +189,7 @@ describe('display', function() norm $j ]]) screen:expect([[ - <<<bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {1:<<<}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*5 b^b | | @@ -207,7 +199,7 @@ describe('display', function() exec('set number cpo+=n scrolloff=0') feed('$0') screen:expect([[ - <<<b^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {1:<<<}b^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6 | ]]) @@ -215,14 +207,14 @@ describe('display', function() exec('set smoothscroll') feed('$b') screen:expect([[ - 2 b ^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {8: 2 }b ^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6 | ]]) -- Same for "ge". feed('$ge') screen:expect([[ - 2 ^b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {8: 2 }^b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6 | ]]) diff --git a/test/functional/legacy/edit_spec.lua b/test/functional/legacy/edit_spec.lua index 0762e5e671..f3d18a2541 100644 --- a/test/functional/legacy/edit_spec.lua +++ b/test/functional/legacy/edit_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local expect = helpers.expect -local feed = helpers.feed + +local clear = n.clear +local command = n.command +local expect = n.expect +local feed = n.feed local sleep = vim.uv.sleep before_each(clear) @@ -30,22 +31,17 @@ describe('edit', function() -- oldtest: Test_edit_insert_reg() it('inserting a register using CTRL-R', function() local screen = Screen.new(10, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { foreground = Screen.colors.Blue }, -- SpecialKey - [2] = { bold = true }, -- ModeMsg - }) screen:attach() feed('a<C-R>') screen:expect([[ - {1:^"} | - {0:~ }|*4 - {2:-- INSERT --}| + {18:^"} | + {1:~ }|*4 + {5:-- INSERT --}| ]]) feed('=') screen:expect([[ - {1:"} | - {0:~ }|*4 + {18:"} | + {1:~ }|*4 =^ | ]]) end) @@ -53,51 +49,42 @@ describe('edit', function() -- oldtest: Test_edit_ctrl_r_failed() it('positioning cursor after CTRL-R expression failed', function() local screen = Screen.new(60, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { foreground = Screen.colors.Blue }, -- SpecialKey - [2] = { foreground = Screen.colors.SlateBlue }, - [3] = { bold = true }, -- ModeMsg - [4] = { reverse = true, bold = true }, -- MsgSeparator - [5] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - [6] = { foreground = Screen.colors.SeaGreen, bold = true }, -- MoreMsg - }) screen:attach() feed('i<C-R>') screen:expect([[ - {1:^"} | - {0:~ }|*4 - {3:-- INSERT --} | + {18:^"} | + {1:~ }|*4 + {5:-- INSERT --} | ]]) - feed('={}') + feed('=0z') screen:expect([[ - {1:"} | - {0:~ }|*4 - ={2:{}}^ | + {18:"} | + {1:~ }|*4 + ={26:0}{9:z}^ | ]]) - -- trying to insert a dictionary produces an error + -- trying to insert a blob produces an error feed('<CR>') screen:expect([[ - {1:"} | - {0:~ }| - {4: }| - ={2:{}} | - {5:E731: Using a Dictionary as a String} | + {18:"} | + {1:~ }| + {3: }| + ={26:0}{9:z} | + {9:E976: Using a Blob as a String} | {6:Press ENTER or type command to continue}^ | ]]) feed(':') screen:expect([[ :^ | - {0:~ }|*4 - {3:-- INSERT --} | + {1:~ }|*4 + {5:-- INSERT --} | ]]) -- ending Insert mode should put the cursor back on the ':' feed('<Esc>') screen:expect([[ ^: | - {0:~ }|*4 + {1:~ }|*4 | ]]) end) diff --git a/test/functional/legacy/erasebackword_spec.lua b/test/functional/legacy/erasebackword_spec.lua index 46057fe599..3042c52784 100644 --- a/test/functional/legacy/erasebackword_spec.lua +++ b/test/functional/legacy/erasebackword_spec.lua @@ -1,7 +1,8 @@ -- Test for CTRL-W in Insert mode -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, expect = helpers.clear, helpers.feed, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, expect = n.clear, n.feed, n.expect describe('CTRL-W in Insert mode', function() setup(clear) diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua index 21d0ce118d..554af9418d 100644 --- a/test/functional/legacy/eval_spec.lua +++ b/test/functional/legacy/eval_spec.lua @@ -1,13 +1,15 @@ -- Test for various eval features. -local helpers = require('test.functional.helpers')(after_each) -local assert_alive = helpers.assert_alive -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, command, expect = helpers.clear, helpers.command, helpers.expect -local eq, eval, write_file = helpers.eq, helpers.eval, helpers.write_file -local poke_eventloop = helpers.poke_eventloop -local exc_exec = helpers.exc_exec -local dedent = helpers.dedent +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local feed, insert, source = n.feed, n.insert, n.source +local clear, command, expect = n.clear, n.command, n.expect +local eq, eval, write_file = t.eq, n.eval, t.write_file +local poke_eventloop = n.poke_eventloop +local exc_exec = n.exc_exec +local dedent = t.dedent describe('eval', function() setup(function() diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua index ae4c4309d1..574c3e4069 100644 --- a/test/functional/legacy/ex_mode_spec.lua +++ b/test/functional/legacy/ex_mode_spec.lua @@ -1,12 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local eval = helpers.eval -local feed = helpers.feed -local api = helpers.api -local poke_eventloop = helpers.poke_eventloop + +local clear = n.clear +local command = n.command +local eq = t.eq +local eval = n.eval +local feed = n.feed +local api = n.api +local poke_eventloop = n.poke_eventloop before_each(clear) @@ -45,60 +47,55 @@ describe('Ex mode', function() it('substitute confirmation prompt', function() command('set noincsearch nohlsearch inccommand=') local screen = Screen.new(60, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, reverse = true }, -- MsgSeparator - [1] = { foreground = Screen.colors.Brown }, -- LineNr - [2] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - }) screen:attach() command([[call setline(1, ['foo foo', 'foo foo', 'foo foo'])]]) command([[set number]]) feed('gQ') screen:expect([[ - {1: 1 }foo foo | - {1: 2 }foo foo | - {1: 3 }foo foo | - {0: }| + {8: 1 }foo foo | + {8: 2 }foo foo | + {8: 3 }foo foo | + {3: }| Entering Ex mode. Type "visual" to go to Normal mode. | :^ | ]]) feed('%s/foo/bar/gc<CR>') screen:expect([[ - {1: 1 }foo foo | - {0: }| + {8: 1 }foo foo | + {3: }| Entering Ex mode. Type "visual" to go to Normal mode. | :%s/foo/bar/gc | - {1: 1 }foo foo | + {8: 1 }foo foo | ^^^^ | ]]) feed('N<CR>') screen:expect([[ Entering Ex mode. Type "visual" to go to Normal mode. | :%s/foo/bar/gc | - {1: 1 }foo foo | + {8: 1 }foo foo | ^^^N | - {1: 1 }foo foo | + {8: 1 }foo foo | ^^^^ | ]]) feed('n<CR>') screen:expect([[ - {1: 1 }foo foo | + {8: 1 }foo foo | ^^^N | - {1: 1 }foo foo | + {8: 1 }foo foo | ^^^n | - {1: 1 }foo foo | + {8: 1 }foo foo | ^^^^ | ]]) feed('y<CR>') feed('q<CR>') screen:expect([[ - {1: 1 }foo foo | + {8: 1 }foo foo | ^^^y | - {1: 2 }foo foo | + {8: 2 }foo foo | ^^^q | - {1: 2 }foo foo | + {8: 2 }foo foo | :^ | ]]) @@ -106,35 +103,31 @@ describe('Ex mode', function() feed('<CR>') screen:expect([[ ^^^y | - {1: 2 }foo foo | + {8: 2 }foo foo | ^^^q | - {1: 2 }foo foo | - {1: 3 }foo foo | + {8: 2 }foo foo | + {8: 3 }foo foo | :^ | ]]) feed(':vi<CR>') screen:expect([[ - {1: 1 }foo bar | - {1: 2 }foo foo | - {1: 3 }^foo foo | - {2:~ }|*2 + {8: 1 }foo bar | + {8: 2 }foo foo | + {8: 3 }^foo foo | + {1:~ }|*2 | ]]) 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: }| + {3: }| Entering Ex mode. Type "visual" to go to Normal mode. | :for i in range(1) | | diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua index 41f14c4645..de3d498f27 100644 --- a/test/functional/legacy/excmd_spec.lua +++ b/test/functional/legacy/excmd_spec.lua @@ -1,18 +1,20 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() 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 fn = helpers.fn -local api = helpers.api -local read_file = helpers.read_file -local source = helpers.source -local eq = helpers.eq -local write_file = helpers.write_file -local is_os = helpers.is_os + +local clear = n.clear +local command = n.command +local exec = n.exec +local exec_lua = n.exec_lua +local expect_exit = n.expect_exit +local feed = n.feed +local fn = n.fn +local api = n.api +local read_file = t.read_file +local source = n.source +local eq = t.eq +local write_file = t.write_file +local is_os = t.is_os local function sizeoflong() if not exec_lua('return pcall(require, "ffi")') then @@ -48,12 +50,6 @@ describe(':confirm command dialog', function() local function start_new() clear() 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 @@ -76,17 +72,17 @@ describe(':confirm command dialog', function() feed(':confirm qall\n') screen:expect([[ bar2 | - {0:~ }|*5 + {1:~ }|*5 {2:Xbar [+] }| foo2 | - {0:~ }|*4 + {1:~ }|*4 {2:Xfoo [+] }| | - {0:~ }|*2 - {1: }| + {1:~ }|*2 + {3: }| :confirm qall | - {3:Save changes to "Xbar"?} | - {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + {6:Save changes to "Xbar"?} | + {6:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | ]]) expect_exit(1000, feed, 'A') @@ -106,17 +102,17 @@ describe(':confirm command dialog', function() feed(':confirm qall\n') screen:expect([[ bar3 | - {0:~ }|*5 + {1:~ }|*5 {2:Xbar [+] }| foo3 | - {0:~ }|*4 + {1:~ }|*4 {2:Xfoo [+] }| | - {0:~ }|*2 - {1: }| + {1:~ }|*2 + {3: }| :confirm qall | - {3:Save changes to "Xbar"?} | - {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + {6:Save changes to "Xbar"?} | + {6:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | ]]) expect_exit(1000, feed, 'D') @@ -136,33 +132,33 @@ describe(':confirm command dialog', function() feed(':confirm qall\n') screen:expect([[ bar4 | - {0:~ }|*5 + {1:~ }|*5 {2:Xbar [+] }| foo4 | - {0:~ }|*4 + {1:~ }|*4 {2:Xfoo [+] }| | - {0:~ }|*2 - {1: }| + {1:~ }|*2 + {3: }| :confirm qall | - {3:Save changes to "Xbar"?} | - {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + {6:Save changes to "Xbar"?} | + {6:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | ]]) feed('N') screen:expect([[ bar4 | - {0:~ }|*5 + {1:~ }|*5 {2:Xbar [+] }| foo4 | - {0:~ }|*4 + {1:~ }|*4 {2:Xfoo [+] }| | - {1: }| + {3: }| :confirm qall | - {3:Save changes to "Xbar"?} | + {6:Save changes to "Xbar"?} | | - {3:Save changes to "Xfoo"?} | - {3:[Y]es, (N)o, (C)ancel: }^ | + {6:Save changes to "Xfoo"?} | + {6:[Y]es, (N)o, (C)ancel: }^ | ]]) expect_exit(1000, feed, 'Y') @@ -186,39 +182,39 @@ describe(':confirm command dialog', function() feed(':confirm close\n') screen:expect([[ abc | - {0:~ }|*3 - {1:[No Name] [+] }| + {1:~ }|*3 + {3:[No Name] [+] }| | - {1: }| + {3: }| :confirm close | - {3:Save changes to "Untitled"?} | - {3:[Y]es, (N)o, (C)ancel: }^ | + {6:Save changes to "Untitled"?} | + {6:[Y]es, (N)o, (C)ancel: }^ | ]]) feed('C') screen:expect([[ ^abc | - {0:~ }|*3 - {1:[No Name] [+] }| + {1:~ }|*3 + {3:[No Name] [+] }| | - {0:~ }|*2 + {1:~ }|*2 {2:[No Name] }| | ]]) feed(':confirm close\n') screen:expect([[ abc | - {0:~ }|*3 - {1:[No Name] [+] }| + {1:~ }|*3 + {3:[No Name] [+] }| | - {1: }| + {3: }| :confirm close | - {3:Save changes to "Untitled"?} | - {3:[Y]es, (N)o, (C)ancel: }^ | + {6:Save changes to "Untitled"?} | + {6:[Y]es, (N)o, (C)ancel: }^ | ]]) feed('N') screen:expect([[ ^ | - {0:~ }|*8 + {1:~ }|*8 | ]]) end) @@ -237,16 +233,16 @@ describe(':confirm command dialog', function() feed(':confirm q\n') screen:expect([[ foo | - {0:~ }|*3 - {1: }| + {1:~ }|*3 + {3: }| :confirm q | - {3:Save changes to "Untitled"?} | - {3:[Y]es, (N)o, (C)ancel: }^ | + {6:Save changes to "Untitled"?} | + {6:[Y]es, (N)o, (C)ancel: }^ | ]]) feed('C') screen:expect([[ ^abc | - {0:~ }|*6 + {1:~ }|*6 | ]]) @@ -254,16 +250,16 @@ describe(':confirm command dialog', function() feed(':confirm wq\n') screen:expect([[ foo | - {0:~ }|*3 - {1: }| + {1:~ }|*3 + {3: }| "Xfoo" [noeol] 1L, 3B written | - {3:Save changes to "Untitled"?} | - {3:[Y]es, (N)o, (C)ancel: }^ | + {6:Save changes to "Untitled"?} | + {6:[Y]es, (N)o, (C)ancel: }^ | ]]) feed('C') screen:expect([[ ^abc | - {0:~ }|*6 + {1:~ }|*6 "Xfoo" [noeol] 1L, 3B written | ]]) @@ -286,17 +282,17 @@ describe(':confirm command dialog', function() feed(':set ro | confirm w\n') screen:expect([[ foobar | - {0:~ }|*2 - {1: }| + {1:~ }|*2 + {3: }| :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: }^ | + {6:'readonly' option is set for "Xconfirm_write_ro".} | + {6:Do you wish to write anyway?} | + {6:(Y)es, [N]o: }^ | ]]) feed('N') screen:expect([[ fooba^r | - {0:~ }|*5 + {1:~ }|*5 | 1,6 All | ]]) @@ -305,35 +301,35 @@ describe(':confirm command dialog', function() feed(':confirm w\n') screen:expect([[ foobar | - {0:~ }|*2 - {1: }| + {1:~ }|*2 + {3: }| :confirm w | - {3:'readonly' option is set for "Xconfirm_write_ro".} | - {3:Do you wish to write anyway?} | - {3:(Y)es, [N]o: }^ | + {6:'readonly' option is set for "Xconfirm_write_ro".} | + {6:Do you wish to write anyway?} | + {6:(Y)es, [N]o: }^ | ]]) feed('Y') if is_os('win') then screen:expect([[ foobar | - {0:~ }| - {1: }| + {1:~ }| + {3: }| :confirm w | - {3:'readonly' option is set for "Xconfirm_write_ro".} | - {3:Do you wish to write anyway?} | + {6:'readonly' option is set for "Xconfirm_write_ro".} | + {6:Do you wish to write anyway?} | "Xconfirm_write_ro" [unix] 1L, 7B written | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) else screen:expect([[ foobar | - {0:~ }| - {1: }| + {1:~ }| + {3: }| :confirm w | - {3:'readonly' option is set for "Xconfirm_write_ro".} | - {3:Do you wish to write anyway?} | + {6:'readonly' option is set for "Xconfirm_write_ro".} | + {6:Do you wish to write anyway?} | "Xconfirm_write_ro" 1L, 7B written | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) end eq('foobar\n', read_file('Xconfirm_write_ro')) @@ -344,36 +340,36 @@ describe(':confirm command dialog', function() feed(':set noro | silent undo | confirm w\n') screen:expect([[ foobar | - {0:~ }| - {1: }| + {1:~ }| + {3: }| :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: }^ | + {6:File permissions of "Xconfirm_write_ro" are read-only.} | + {6:It may still be possible to write it.} | + {6:Do you wish to try?} | + {6:(Y)es, [N]o: }^ | ]]) feed('Y') if is_os('win') then screen:expect([[ foobar | - {1: }| + {3: }| :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?} | + {6:File permissions of "Xconfirm_write_ro" are read-only.} | + {6:It may still be possible to write it.} | + {6:Do you wish to try?} | "Xconfirm_write_ro" [unix] 1L, 4B written | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) else screen:expect([[ foobar | - {1: }| + {3: }| :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?} | + {6:File permissions of "Xconfirm_write_ro" are read-only.} | + {6:It may still be possible to write it.} | + {6:Do you wish to try?} | "Xconfirm_write_ro" 1L, 4B written | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) end eq('foo\n', read_file('Xconfirm_write_ro')) @@ -399,10 +395,10 @@ describe(':confirm command dialog', function() b | c | d | - {1: }| + {3: }| :confirm 2,3w | - {3:Write partial file?} | - {3:(Y)es, [N]o: }^ | + {6:Write partial file?} | + {6:(Y)es, [N]o: }^ | ]]) feed('N') screen:expect([[ @@ -410,7 +406,7 @@ describe(':confirm command dialog', function() b | c | d | - {0:~ }|*2 + {1:~ }|*2 | 1,1 All | ]]) @@ -423,10 +419,10 @@ describe(':confirm command dialog', function() b | c | d | - {1: }| + {3: }| :confirm 2,3w | - {3:Write partial file?} | - {3:(Y)es, [N]o: }^ | + {6:Write partial file?} | + {6:(Y)es, [N]o: }^ | ]]) feed('Y') if is_os('win') then @@ -434,22 +430,22 @@ describe(':confirm command dialog', function() a | b | c | - {1: }| + {3: }| :confirm 2,3w | - {3:Write partial file?} | + {6:Write partial file?} | "Xwrite_partial" [New][unix] 2L, 4B written | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) else screen:expect([[ a | b | c | - {1: }| + {3: }| :confirm 2,3w | - {3:Write partial file?} | + {6:Write partial file?} | "Xwrite_partial" [New] 2L, 4B written | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) end eq('b\nc\n', read_file('Xwrite_partial')) diff --git a/test/functional/legacy/filechanged_spec.lua b/test/functional/legacy/filechanged_spec.lua deleted file mode 100644 index 46ecfdcd63..0000000000 --- a/test/functional/legacy/filechanged_spec.lua +++ /dev/null @@ -1,142 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, source = helpers.clear, helpers.source -local call, eq, api = helpers.call, helpers.eq, helpers.api -local is_os = helpers.is_os -local skip = helpers.skip - -local function expected_empty() - eq({}, api.nvim_get_vvar('errors')) -end - -describe('file changed dialog', function() - before_each(function() - clear() - api.nvim_ui_attach(80, 24, {}) - api.nvim_set_option_value('autoread', false, {}) - api.nvim_set_option_value('fsync', true, {}) - end) - - it('works', function() - skip(is_os('win')) - source([[ - func Test_file_changed_dialog() - au! FileChangedShell - - new Xchanged_d - call setline(1, 'reload this') - write - " Need to wait until the timestamp would change by at least a second. - sleep 2 - silent !echo 'extra line' >>Xchanged_d - call nvim_input('L') - checktime - call assert_match('W11:', v:warningmsg) - call assert_equal(2, line('$')) - call assert_equal('reload this', getline(1)) - call assert_equal('extra line', getline(2)) - - " delete buffer, only shows an error, no prompt - silent !rm Xchanged_d - checktime - call assert_match('E211:', v:warningmsg) - call assert_equal(2, line('$')) - call assert_equal('extra line', getline(2)) - let v:warningmsg = 'empty' - - " change buffer, recreate the file and reload - call setline(1, 'buffer is changed') - silent !echo 'new line' >Xchanged_d - call nvim_input('L') - checktime - call assert_match('W12:', v:warningmsg) - call assert_equal(1, line('$')) - call assert_equal('new line', getline(1)) - - " Only mode changed, reload - silent !chmod +x Xchanged_d - call nvim_input('L') - checktime - call assert_match('W16:', v:warningmsg) - call assert_equal(1, line('$')) - call assert_equal('new line', getline(1)) - - " Only time changed, no prompt - sleep 2 - silent !touch Xchanged_d - let v:warningmsg = '' - checktime Xchanged_d - call assert_equal('', v:warningmsg) - call assert_equal(1, line('$')) - call assert_equal('new line', getline(1)) - - " File created after starting to edit it - call delete('Xchanged_d') - new Xchanged_d - call writefile(['one'], 'Xchanged_d') - call nvim_input('L') - checktime Xchanged_d - call assert_equal(['one'], getline(1, '$')) - close! - - bwipe! - call delete('Xchanged_d') - endfunc - ]]) - call('Test_file_changed_dialog') - expected_empty() - end) - - it('works with FileChangedShell', function() - source([[ - func Test_FileChangedShell_edit_dialog() - new Xchanged_r - call setline(1, 'reload this') - set fileformat=unix - silent write " Use :silent to prevent a hit-enter prompt - - " File format changed, reload (content only) via prompt - augroup testreload - au! - au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask' - augroup END - call assert_equal(&fileformat, 'unix') - sleep 10m " make the test less flaky in Nvim - call writefile(["line1\r", "line2\r"], 'Xchanged_r') - let g:reason = '' - call nvim_input('L') " load file content only - checktime - call assert_equal('changed', g:reason) - call assert_equal(&fileformat, 'unix') - call assert_equal("line1\r", getline(1)) - call assert_equal("line2\r", getline(2)) - %s/\r - silent write " Use :silent to prevent a hit-enter prompt - - " File format changed, reload (file and options) via prompt - augroup testreload - au! - au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask' - augroup END - call assert_equal(&fileformat, 'unix') - sleep 10m " make the test less flaky in Nvim - call writefile(["line1\r", "line2\r"], 'Xchanged_r') - let g:reason = '' - call nvim_input('a') " load file content and options - checktime - call assert_equal('changed', g:reason) - call assert_equal(&fileformat, 'dos') - call assert_equal("line1", getline(1)) - call assert_equal("line2", getline(2)) - set fileformat=unix - silent write " Use :silent to prevent a hit-enter prompt - - au! testreload - bwipe! - call delete(undofile('Xchanged_r')) - call delete('Xchanged_r') - endfunc - ]]) - call('Test_FileChangedShell_edit_dialog') - expected_empty() - end) -end) diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua index 01b87ac9a0..21f0b9f001 100644 --- a/test/functional/legacy/fixeol_spec.lua +++ b/test/functional/legacy/fixeol_spec.lua @@ -1,8 +1,9 @@ -- Tests for 'fixeol' -local helpers = require('test.functional.helpers')(after_each) -local feed = helpers.feed -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed = n.feed +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('fixeol', function() local function rmtestfiles() diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua index 570b523d92..ce8c710a46 100644 --- a/test/functional/legacy/fnamemodify_spec.lua +++ b/test/functional/legacy/fnamemodify_spec.lua @@ -1,11 +1,13 @@ -- Test filename modifiers. -local helpers = require('test.functional.helpers')(after_each) -local clear, source = helpers.clear, helpers.source -local call, eq, nvim = helpers.call, helpers.eq, helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, source = n.clear, n.source +local call, eq, api = n.call, t.eq, n.api local function expected_empty() - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end describe('filename modifiers', function() diff --git a/test/functional/legacy/fold_spec.lua b/test/functional/legacy/fold_spec.lua index c39aae87d2..4fea1ef113 100644 --- a/test/functional/legacy/fold_spec.lua +++ b/test/functional/legacy/fold_spec.lua @@ -1,25 +1,19 @@ -- Tests for folding. + +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local helpers = require('test.functional.helpers')(after_each) -local feed, insert, feed_command, expect_any = - helpers.feed, helpers.insert, helpers.feed_command, helpers.expect_any -local command = helpers.command -local exec = helpers.exec +local feed, insert, feed_command, expect_any = n.feed, n.insert, n.feed_command, n.expect_any +local command = n.command +local exec = n.exec describe('folding', function() local screen before_each(function() - helpers.clear() + n.clear() screen = Screen.new(45, 8) - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [2] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, -- Folded - [3] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey }, -- FoldColumn - [4] = { foreground = Screen.colors.Brown }, -- LineNr - }) screen:attach() end) @@ -67,7 +61,7 @@ describe('folding', function() feed('kYpj') feed_command('call append("$", foldlevel("."))') - helpers.poke_eventloop() + n.poke_eventloop() screen:expect([[ dd {{{ | ee {{{ }}} | @@ -93,7 +87,7 @@ describe('folding', function() feed_command('call append("$", foldlevel(2))') feed('zR') - helpers.poke_eventloop() + n.poke_eventloop() screen:expect([[ aa | bb | @@ -222,15 +216,15 @@ describe('folding', function() command('call setline(1, ["{{{1", "nline 1", "{{{1", "line 2"])') screen:expect([[ - {3:+ }{4: 0 }{2:^+-- 2 lines: ·························}| - {3:+ }{4: 1 }{2:+-- 2 lines: ·························}| + {7:+ }{8: 0 }{13:^+-- 2 lines: ·························}| + {7:+ }{8: 1 }{13:+-- 2 lines: ·························}| {1:~ }|*5 | ]]) feed('j') screen:expect([[ - {3:+ }{4: 1 }{2:+-- 2 lines: ·························}| - {3:+ }{4: 0 }{2:^+-- 2 lines: ·························}| + {7:+ }{8: 1 }{13:+-- 2 lines: ·························}| + {7:+ }{8: 0 }{13:^+-- 2 lines: ·························}| {1:~ }|*5 | ]]) @@ -246,7 +240,7 @@ describe('folding', function() screen:expect([[ ^one | - {2:+-- 2 lines: two····························}| + {13:+-- 2 lines: two····························}| four | {1:~ }|*4 | @@ -263,7 +257,7 @@ describe('folding', function() feed('4G') screen:expect([[ one | - {2:+-- 2 lines: two····························}| + {13:+-- 2 lines: two····························}| ^four | {1:~ }|*4 | @@ -280,7 +274,7 @@ describe('folding', function() feed('1G') screen:expect([[ ^one | - {2:+-- 2 lines: two····························}| + {13:+-- 2 lines: two····························}| four | {1:~ }|*4 | @@ -297,7 +291,7 @@ describe('folding', function() feed('k') screen:expect([[ ^one | - {2:+-- 2 lines: two····························}| + {13:+-- 2 lines: two····························}| four | {1:~ }|*4 | diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua index 36128bb0a2..b55c5437ef 100644 --- a/test/functional/legacy/function_sort_spec.lua +++ b/test/functional/legacy/function_sort_spec.lua @@ -1,11 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) - -local eq = helpers.eq -local neq = helpers.neq -local eval = helpers.eval -local clear = helpers.clear -local source = helpers.source -local exc_exec = helpers.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq = t.eq +local neq = t.neq +local eval = n.eval +local clear = n.clear +local source = n.source +local exc_exec = n.exc_exec describe('sort', function() before_each(clear) diff --git a/test/functional/legacy/getcwd_spec.lua b/test/functional/legacy/getcwd_spec.lua index eae13da528..c95a010c5a 100644 --- a/test/functional/legacy/getcwd_spec.lua +++ b/test/functional/legacy/getcwd_spec.lua @@ -1,14 +1,16 @@ -- Tests for getcwd(), haslocaldir(), and :lcd -local helpers = require('test.functional.helpers')(after_each) -local eq, eval, source = helpers.eq, helpers.eval, helpers.source -local call, clear, command = helpers.call, helpers.clear, helpers.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, eval, source = t.eq, n.eval, n.source +local call, clear, command = n.call, n.clear, n.command describe('getcwd', function() before_each(clear) after_each(function() - helpers.rmdir('Xtopdir') + n.rmdir('Xtopdir') end) it('is working', function() diff --git a/test/functional/legacy/gf_spec.lua b/test/functional/legacy/gf_spec.lua index b51f671bee..4c98edf8e0 100644 --- a/test/functional/legacy/gf_spec.lua +++ b/test/functional/legacy/gf_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local pcall_err = helpers.pcall_err +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local eq = t.eq +local pcall_err = t.pcall_err describe('gf', function() before_each(clear) diff --git a/test/functional/legacy/glob2regpat_spec.lua b/test/functional/legacy/glob2regpat_spec.lua index de304f3e4b..6d08a77386 100644 --- a/test/functional/legacy/glob2regpat_spec.lua +++ b/test/functional/legacy/glob2regpat_spec.lua @@ -1,6 +1,8 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq, eval = helpers.eq, helpers.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eq, eval = t.eq, n.eval describe('glob2regpat()', function() before_each(clear) diff --git a/test/functional/legacy/global_spec.lua b/test/functional/legacy/global_spec.lua index 2c92b7814a..718fd421b0 100644 --- a/test/functional/legacy/global_spec.lua +++ b/test/functional/legacy/global_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed -local poke_eventloop = helpers.poke_eventloop + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local poke_eventloop = n.poke_eventloop before_each(clear) @@ -11,10 +12,6 @@ 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([[ @@ -29,7 +26,7 @@ describe(':global', function() screen:expect([[ ^foo | foo |*4 - {1:Interrupted} | + {9:Interrupted} | ]]) -- Also test in Ex mode @@ -37,11 +34,11 @@ describe(':global', function() poke_eventloop() -- Wait for :sleep to start feed('<C-C>') screen:expect([[ - {0: }| + {3: }| Entering Ex mode. Type "visual" to go to Normal mode. | :g/foo/norm :; | | - {1:Interrupted} | + {9:Interrupted} | :^ | ]]) end) diff --git a/test/functional/legacy/highlight_spec.lua b/test/functional/legacy/highlight_spec.lua index 3d06bf3978..35afd9bb4a 100644 --- a/test/functional/legacy/highlight_spec.lua +++ b/test/functional/legacy/highlight_spec.lua @@ -1,12 +1,14 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local helpers = require('test.functional.helpers')(after_each) -local clear, feed = helpers.clear, helpers.feed -local expect = helpers.expect -local eq = helpers.eq -local poke_eventloop = helpers.poke_eventloop -local exc_exec = helpers.exc_exec -local feed_command = helpers.feed_command -local exec = helpers.exec + +local clear, feed = n.clear, n.feed +local expect = n.expect +local eq = t.eq +local poke_eventloop = n.poke_eventloop +local exc_exec = n.exc_exec +local feed_command = n.feed_command +local exec = n.exec before_each(clear) @@ -22,15 +24,15 @@ describe(':highlight', function() -- is discarded resulting in test failure screen:expect([[ :highlight | - SpecialKey xxx ctermfg=4 | - guifg=Blue | - EndOfBuffer xxx links to NonText| + SpecialKey {18:xxx} {18:ctermfg=}4 | + {18:guifg=}Blue | + EndOfBuffer {1:xxx} {18:links to} NonText| | - TermCursor xxx cterm=reverse | - gui=reverse | + TermCursor {2:xxx} {18:cterm=}reverse | + {18:gui=}reverse | TermCursorNC xxx cleared | - NonText xxx ctermfg=12 | - -- More --^ | + NonText {1:xxx} {18:ctermfg=}12 | + {6:-- More --}^ | ]]) feed('q') poke_eventloop() -- wait until we're back to normal @@ -99,11 +101,6 @@ describe('Visual selection highlight', function() -- oldtest: Test_visual_sbr() it("when 'showbreak' is set", function() local screen = Screen.new(60, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - [2] = { bold = true }, -- ModeMsg - }) screen:attach() exec([[ set showbreak=> @@ -112,9 +109,9 @@ describe('Visual selection highlight', function() ]]) feed('v$') screen:expect([[ - {0:>}{1:n, no sea takimata sanctus est Lorem ipsum dolor sit amet.}^ | + {1:>}{17:n, no sea takimata sanctus est Lorem ipsum dolor sit amet.}^ | |*4 - {2:-- VISUAL --} | + {5:-- VISUAL --} | ]]) end) end) diff --git a/test/functional/legacy/increment_spec.lua b/test/functional/legacy/increment_spec.lua index a81044114c..c9c2324c42 100644 --- a/test/functional/legacy/increment_spec.lua +++ b/test/functional/legacy/increment_spec.lua @@ -1,9 +1,11 @@ -- Tests for using Ctrl-A/Ctrl-X on visual selections -local helpers = require('test.functional.helpers')(after_each) -local source, command = helpers.source, helpers.command -local call, clear = helpers.call, helpers.clear -local eq, nvim = helpers.eq, helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source, command = n.source, n.command +local call, clear = n.call, n.clear +local eq, api = t.eq, n.api describe('Ctrl-A/Ctrl-X on visual selections', function() before_each(function() @@ -743,18 +745,18 @@ describe('Ctrl-A/Ctrl-X on visual selections', function() it('works on Test ' .. id, function() command('set nrformats&vi') -- &vi makes Vim compatible call('Test_visual_increment_' .. id) - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) end it('does not drop leading zeroes', function() command('set nrformats&vi') -- &vi makes Vim compatible call('Test_normal_increment_01') - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) it('maintains correct column after CTRL-A', function() call('Test_normal_increment_02') - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) end) diff --git a/test/functional/legacy/insertcount_spec.lua b/test/functional/legacy/insertcount_spec.lua index e53c9dc6ce..53402c2163 100644 --- a/test/functional/legacy/insertcount_spec.lua +++ b/test/functional/legacy/insertcount_spec.lua @@ -1,8 +1,9 @@ -- Tests for repeating insert and replace. -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local feed_command, expect = helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local feed_command, expect = n.feed_command, n.expect describe('insertcount', function() setup(clear) diff --git a/test/functional/legacy/join_spec.lua b/test/functional/legacy/join_spec.lua index d683d25eb0..397a714b2f 100644 --- a/test/functional/legacy/join_spec.lua +++ b/test/functional/legacy/join_spec.lua @@ -1,8 +1,10 @@ -- Test for joining lines -local helpers = require('test.functional.helpers')(after_each) -local clear, eq = helpers.clear, helpers.eq -local eval, command = helpers.eval, helpers.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq = n.clear, t.eq +local eval, command = n.eval, n.command describe('joining lines', function() before_each(clear) diff --git a/test/functional/legacy/lispwords_spec.lua b/test/functional/legacy/lispwords_spec.lua index efac8775d3..b0130320ed 100644 --- a/test/functional/legacy/lispwords_spec.lua +++ b/test/functional/legacy/lispwords_spec.lua @@ -1,9 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local eval = helpers.eval -local command = helpers.command -local source = helpers.source +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eq = t.eq +local eval = n.eval +local command = n.command +local source = n.source describe('lispwords', function() before_each(clear) diff --git a/test/functional/legacy/listchars_spec.lua b/test/functional/legacy/listchars_spec.lua index 746e0550a6..db9ec7fc9d 100644 --- a/test/functional/legacy/listchars_spec.lua +++ b/test/functional/legacy/listchars_spec.lua @@ -1,9 +1,10 @@ -- Tests for 'listchars' display with 'list' and :list. -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, insert, exec = helpers.feed, helpers.insert, helpers.exec -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect + +local feed, insert, exec = n.feed, n.insert, n.exec +local clear, feed_command, expect = n.clear, n.feed_command, n.expect -- luacheck: ignore 621 (Indentation) describe("'listchars'", function() @@ -102,12 +103,6 @@ describe("'listchars'", function() it('"exceeds" character does not appear in foldcolumn vim-patch:8.2.3121', function() local screen = Screen.new(60, 10) - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [2] = { bold = true, reverse = true }, -- StatusLine - [3] = { reverse = true }, -- StatusLineNC - [4] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue }, -- FoldColumn, SignColumn - }) screen:attach() exec([[ call setline(1, ['aaa', '', 'a', 'aaaaaa']) @@ -117,83 +112,83 @@ describe("'listchars'", function() ]]) feed('13<C-W>>') screen:expect([[ - {4: }aaa │{4: }a{1:>}│{4: }^aaa | - {4: } │{4: } │{4: } | - {4: }a │{4: }a │{4: }a | - {4: }aaaaaa │{4: }a{1:>}│{4: }aaaaaa | + {7: }aaa │{7: }a{1:>}│{7: }^aaa | + {7: } │{7: } │{7: } | + {7: }a │{7: }a │{7: }a | + {7: }aaaaaa │{7: }a{1:>}│{7: }aaaaaa | {1:~ }│{1:~ }│{1:~ }|*4 - {3:[No Name] [+] <[+] }{2:[No Name] [+] }| + {2:[No Name] [+] <[+] }{3:[No Name] [+] }| | ]]) feed('<C-W>>') screen:expect([[ - {4: }aaa │{4: }{1:>}│{4: }^aaa | - {4: } │{4: } │{4: } | - {4: }a │{4: }a│{4: }a | - {4: }aaaaaa │{4: }{1:>}│{4: }aaaaaa | + {7: }aaa │{7: }{1:>}│{7: }^aaa | + {7: } │{7: } │{7: } | + {7: }a │{7: }a│{7: }a | + {7: }aaaaaa │{7: }{1:>}│{7: }aaaaaa | {1:~ }│{1:~ }│{1:~ }|*4 - {3:[No Name] [+] <+] }{2:[No Name] [+] }| + {2:[No Name] [+] <+] }{3:[No Name] [+] }| | ]]) feed('<C-W>>') screen:expect([[ - {4: }aaa │{4: }│{4: }^aaa | - {4: } │{4: }│{4: } | - {4: }a │{4: }│{4: }a | - {4: }aaaaaa │{4: }│{4: }aaaaaa | + {7: }aaa │{7: }│{7: }^aaa | + {7: } │{7: }│{7: } | + {7: }a │{7: }│{7: }a | + {7: }aaaaaa │{7: }│{7: }aaaaaa | {1:~ }│{1:~ }│{1:~ }|*4 - {3:[No Name] [+] <] }{2:[No Name] [+] }| + {2:[No Name] [+] <] }{3:[No Name] [+] }| | ]]) feed('<C-W>>') screen:expect([[ - {4: }aaa │{4: }│{4: }^aaa | - {4: } │{4: }│{4: } | - {4: }a │{4: }│{4: }a | - {4: }aaaaaa │{4: }│{4: }aaaaaa | + {7: }aaa │{7: }│{7: }^aaa | + {7: } │{7: }│{7: } | + {7: }a │{7: }│{7: }a | + {7: }aaaaaa │{7: }│{7: }aaaaaa | {1:~ }│{1:~ }│{1:~ }|*4 - {3:[No Name] [+] < }{2:[No Name] [+] }| + {2:[No Name] [+] < }{3:[No Name] [+] }| | ]]) feed('<C-W>>') screen:expect([[ - {4: }aaa │{4: }│{4: }^aaa | - {4: } │{4: }│{4: } | - {4: }a │{4: }│{4: }a | - {4: }aaaaaa │{4: }│{4: }aaaaaa | + {7: }aaa │{7: }│{7: }^aaa | + {7: } │{7: }│{7: } | + {7: }a │{7: }│{7: }a | + {7: }aaaaaa │{7: }│{7: }aaaaaa | {1:~ }│{1:~}│{1:~ }|*4 - {3:[No Name] [+] < }{2:[No Name] [+] }| + {2:[No Name] [+] < }{3:[No Name] [+] }| | ]]) feed('<C-W>h') feed_command('set nowrap foldcolumn=4') screen:expect([[ - {4: }aaa │{4: }^aaa │{4: }aaa | - {4: } │{4: } │{4: } | - {4: }a │{4: }a │{4: }a | - {4: }aaaaaa │{4: }aaaaaa │{4: }aaaaaa | + {7: }aaa │{7: }^aaa │{7: }aaa | + {7: } │{7: } │{7: } | + {7: }a │{7: }a │{7: }a | + {7: }aaaaaa │{7: }aaaaaa │{7: }aaaaaa | {1:~ }│{1:~ }│{1:~ }|*4 - {3:[No Name] [+] }{2:[No Name] [+] }{3:[No Name] [+] }| + {2:[No Name] [+] }{3:[No Name] [+] }{2:[No Name] [+] }| :set nowrap foldcolumn=4 | ]]) feed('15<C-W><lt>') screen:expect([[ - {4: }aaa │{4: }│{4: }aaa | - {4: } │{4: }│{4: } | - {4: }a │{4: }│{4: }a | - {4: }aaaaaa │{4: ^ }│{4: }aaaaaa | + {7: }aaa │{7: }│{7: }aaa | + {7: } │{7: }│{7: } | + {7: }a │{7: }│{7: }a | + {7: }aaaaaa │{7: ^ }│{7: }aaaaaa | {1:~ }│{1:~ }│{1:~ }|*4 - {3:[No Name] [+] }{2:<[+] }{3:[No Name] [+] }| + {2:[No Name] [+] }{3:<[+] }{2:[No Name] [+] }| :set nowrap foldcolumn=4 | ]]) feed('4<C-W><lt>') screen:expect([[ - {4: }aaa │{4: }│{4: }aaa | - {4: } │{4: }│{4: } | - {4: }a │{4: }│{4: }a | - {4: }aaaaaa │{4:^ }│{4: }aaaaaa | + {7: }aaa │{7: }│{7: }aaa | + {7: } │{7: }│{7: } | + {7: }a │{7: }│{7: }a | + {7: }aaaaaa │{7:^ }│{7: }aaaaaa | {1:~ }│{1:~}│{1:~ }|*4 - {3:[No Name] [+] }{2:< }{3:[No Name] [+] }| + {2:[No Name] [+] }{3:< }{2:[No Name] [+] }| :set nowrap foldcolumn=4 | ]]) end) diff --git a/test/functional/legacy/listlbr_spec.lua b/test/functional/legacy/listlbr_spec.lua index 50628e5ef9..da641c3b6f 100644 --- a/test/functional/legacy/listlbr_spec.lua +++ b/test/functional/legacy/listlbr_spec.lua @@ -1,9 +1,10 @@ -- Test for linebreak and list option (non-utf8) -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('listlbr', function() before_each(clear) @@ -204,11 +205,6 @@ describe('listlbr', function() -- oldtest: Test_linebreak_reset_restore() it('cursor position is drawn correctly after operator', function() local screen = Screen.new(60, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - [2] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - }) screen:attach() -- f_wincol() calls validate_cursor() @@ -220,61 +216,61 @@ describe('listlbr', function() feed('$v$') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | - bbbbbbbbbb {1:c}^ | - {0:~ }|*3 + bbbbbbbbbb {17:c}^ | + {1:~ }|*3 2 | ]]) feed('zo') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | bbbbbbbbbb ^c | - {0:~ }|*3 - {2:E490: No fold found} | + {1:~ }|*3 + {9:E490: No fold found} | ]]) feed('$v$') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | - bbbbbbbbbb {1:c}^ | - {0:~ }|*3 - {2:E490: No fold found} 2 | + bbbbbbbbbb {17:c}^ | + {1:~ }|*3 + {9:E490: No fold found} 2 | ]]) feed('gq') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | bbbbbbbbbb ^c | - {0:~ }|*3 - {2:E490: No fold found} | + {1:~ }|*3 + {9:E490: No fold found} | ]]) feed('$<C-V>$') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | - bbbbbbbbbb {1:c}^ | - {0:~ }|*3 - {2:E490: No fold found} 1x2 | + bbbbbbbbbb {17:c}^ | + {1:~ }|*3 + {9:E490: No fold found} 1x2 | ]]) feed('I') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | bbbbbbbbbb ^c | - {0:~ }|*3 - {2:E490: No fold found} | + {1:~ }|*3 + {9:E490: No fold found} | ]]) feed('<Esc>$v$') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | - bbbbbbbbbb {1:c}^ | - {0:~ }|*3 - {2:E490: No fold found} 2 | + bbbbbbbbbb {17:c}^ | + {1:~ }|*3 + {9:E490: No fold found} 2 | ]]) feed('s') screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | bbbbbbbbbb ^ | - {0:~ }|*3 - {2:E490: No fold found} | + {1:~ }|*3 + {9:E490: No fold found} | ]]) end) end) diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua index 8e5d9b88bc..74cc594cc1 100644 --- a/test/functional/legacy/listlbr_utf8_spec.lua +++ b/test/functional/legacy/listlbr_utf8_spec.lua @@ -1,11 +1,12 @@ -- Test for linebreak and list option in utf-8 mode -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local source = helpers.source -local feed = helpers.feed -local exec = helpers.exec -local clear, expect = helpers.clear, helpers.expect + +local source = n.source +local feed = n.feed +local exec = n.exec +local clear, expect = n.clear, n.expect describe('linebreak', function() before_each(clear) @@ -214,11 +215,6 @@ describe('linebreak', function() -- oldtest: Test_visual_ends_before_showbreak() it("Visual area is correct when it ends before multibyte 'showbreak'", function() local screen = Screen.new(60, 8) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - [2] = { bold = true }, -- ModeMsg - }) screen:attach() exec([[ let &wrap = v:true @@ -229,10 +225,10 @@ describe('linebreak', function() ]]) screen:expect([[ xxxxx | - {0:↪ }{1:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy}^ {1: }| - {0:↪ }zzzz | - {0:~ }|*4 - {2:-- VISUAL --} | + {1:↪ }{17:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy}^ {17: }| + {1:↪ }zzzz | + {1:~ }|*4 + {5:-- VISUAL --} | ]]) end) end) diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 9eddec40f7..3fc324f66a 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -1,9 +1,13 @@ -- Test for mappings and abbreviations -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local expect, poke_eventloop = helpers.expect, helpers.poke_eventloop -local command, eq, eval, api = helpers.command, helpers.eq, helpers.eval, helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') + +local clear, feed, insert = n.clear, n.feed, n.insert +local expect, poke_eventloop = n.expect, n.poke_eventloop +local command, eq, eval, api = n.command, t.eq, n.eval, n.api +local exec = n.exec local sleep = vim.uv.sleep describe('mapping', function() @@ -23,6 +27,7 @@ describe('mapping', function() vim ]]) end) + -- oldtest: Test_map_ctrl_c_insert() it('Ctrl-c works in Insert mode', function() -- Mapping of ctrl-c in insert mode command('set cpo-=< cpo-=k') @@ -41,6 +46,7 @@ describe('mapping', function() ]]) end) + -- oldtest: Test_map_ctrl_c_visual() it('Ctrl-c works in Visual mode', function() command([[vnoremap <c-c> :<C-u>$put ='vmap works'<cr>]]) feed('GV') @@ -83,6 +89,7 @@ describe('mapping', function() +]]) end) + -- oldtest: Test_map_feedkeys() it('feedkeys', function() insert([[ a b c d @@ -100,6 +107,7 @@ describe('mapping', function() ]]) end) + -- oldtest: Test_map_cursor() it('i_CTRL-G_U', function() -- <c-g>U<cursor> works only within a single line command('imapclear') @@ -128,7 +136,8 @@ describe('mapping', function() ]]) end) - it('dragging starts Select mode even if coming from mapping vim-patch:8.2.4806', function() + -- oldtest: Test_mouse_drag_mapped_start_select() + it('dragging starts Select mode even if coming from mapping', function() command('set mouse=a') command('set selectmode=mouse') @@ -141,7 +150,8 @@ describe('mapping', function() eq('s', eval('mode()')) end) - it('<LeftDrag> mapping in Insert mode works correctly vim-patch:8.2.4692', function() + -- oldtest: Test_mouse_drag_insert_map() + it('<LeftDrag> mapping in Insert mode works correctly', function() command('set mouse=a') command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>') @@ -165,7 +175,8 @@ describe('mapping', function() eq('n', eval('mode()')) end) - it('timeout works after an <Nop> mapping is triggered on timeout vim-patch:8.1.0052', function() + -- oldtest: Test_map_after_timed_out_nop() + it('timeout works after an <Nop> mapping is triggered on timeout', function() command('set timeout timeoutlen=400') command('inoremap ab TEST') command('inoremap a <Nop>') @@ -181,4 +192,62 @@ describe('mapping', function() feed('b') expect('TEST') end) + + -- oldtest: Test_showcmd_part_map() + it("'showcmd' with a partial mapping", function() + local screen = Screen.new(60, 6) + screen:attach() + exec([[ + set notimeout showcmd + nnoremap ,a <Ignore> + nnoremap ;a <Ignore> + nnoremap Àa <Ignore> + nnoremap Ëa <Ignore> + nnoremap βa <Ignore> + nnoremap ωa <Ignore> + nnoremap …a <Ignore> + nnoremap <C-W>a <Ignore> + ]]) + + for _, c in ipairs({ ',', ';', 'À', 'Ë', 'β', 'ω', '…' }) do + feed(c) + screen:expect(([[ + ^ | + {1:~ }|*4 + %s | + ]]):format(c)) + feed('a') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end + + feed('\23') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('a') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + + feed('<C-W>') + screen:expect([[ + ^ | + {1:~ }|*4 + ^W | + ]]) + feed('a') + screen:expect([[ + ^ | + {1:~ }|*4 + | + ]]) + end) end) diff --git a/test/functional/legacy/marks_spec.lua b/test/functional/legacy/marks_spec.lua index 470ea49652..fd968eb355 100644 --- a/test/functional/legacy/marks_spec.lua +++ b/test/functional/legacy/marks_spec.lua @@ -1,6 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, feed_command, expect = n.clear, n.feed_command, n.expect describe('marks', function() before_each(function() diff --git a/test/functional/legacy/match_spec.lua b/test/functional/legacy/match_spec.lua index ab791f03e5..0fc8708244 100644 --- a/test/functional/legacy/match_spec.lua +++ b/test/functional/legacy/match_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed before_each(clear) @@ -10,28 +11,24 @@ describe('matchaddpos()', function() -- oldtest: Test_matchaddpos_dump() it('can add more than 8 match positions vim-patch:9.0.0620', function() local screen = Screen.new(60, 14) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.Yellow }, -- Search - }) screen:attach() exec([[ call setline(1, ['1234567890123']->repeat(14)) call matchaddpos('Search', range(1, 12)->map({i, v -> [v, v]})) ]]) screen:expect([[ - {1:^1}234567890123 | - 1{1:2}34567890123 | - 12{1:3}4567890123 | - 123{1:4}567890123 | - 1234{1:5}67890123 | - 12345{1:6}7890123 | - 123456{1:7}890123 | - 1234567{1:8}90123 | - 12345678{1:9}0123 | - 123456789{1:0}123 | - 1234567890{1:1}23 | - 12345678901{1:2}3 | + {10:^1}234567890123 | + 1{10:2}34567890123 | + 12{10:3}4567890123 | + 123{10:4}567890123 | + 1234{10:5}67890123 | + 12345{10:6}7890123 | + 123456{10:7}890123 | + 1234567{10:8}90123 | + 12345678{10:9}0123 | + 123456789{10:0}123 | + 1234567890{10:1}23 | + 12345678901{10:2}3 | 1234567890123 | | ]]) @@ -42,10 +39,6 @@ describe('match highlighting', function() -- oldtest: Test_match_in_linebreak() it('does not continue in linebreak vim-patch:8.2.3698', function() local screen = Screen.new(75, 10) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - }) screen:attach() exec([=[ set breakindent linebreak breakat+=] @@ -53,20 +46,15 @@ describe('match highlighting', function() call matchaddpos('ErrorMsg', [[1, 51]]) ]=]) screen:expect([[ - ^xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx{1:]} | + ^xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx{9:]} | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | - {0:~ }|*7 + {1:~ }|*7 | ]]) end) it('is shown with incsearch vim-patch:8.2.3940', function() local screen = Screen.new(75, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.Yellow }, -- Search - [2] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - }) screen:attach() exec([[ set incsearch @@ -76,16 +64,16 @@ describe('match highlighting', function() screen:expect([[ ^0 | 1 | - {2:2} | + {9:2} | 3 | 4 | | ]]) feed(':s/0') screen:expect([[ - {1:0} | + {10:0} | 1 | - {2:2} | + {9:2} | 3 | 4 | :s/0^ | @@ -94,10 +82,6 @@ describe('match highlighting', function() it('on a Tab vim-patch:8.2.4062', function() local screen = Screen.new(75, 10) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - }) screen:attach() exec([[ set linebreak @@ -105,8 +89,8 @@ describe('match highlighting', function() call matchadd('ErrorMsg', '\t') ]]) screen:expect([[ - {1: ^ }ix | - {0:~ }|*8 + {9: ^ }ix | + {1:~ }|*8 | ]]) end) diff --git a/test/functional/legacy/matchparen_spec.lua b/test/functional/legacy/matchparen_spec.lua index b03107deb0..3841761515 100644 --- a/test/functional/legacy/matchparen_spec.lua +++ b/test/functional/legacy/matchparen_spec.lua @@ -1,9 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) - +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed describe('matchparen', function() before_each(clear) @@ -12,11 +12,6 @@ describe('matchparen', function() it('redraws properly after scrolling with scrolloff=1', function() local screen = Screen.new(30, 7) screen:attach() - screen:set_default_attr_ids({ - [1] = { bold = true }, - [2] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, - }) - exec([[ source $VIMRUNTIME/plugin/matchparen.vim set scrolloff=1 @@ -26,13 +21,13 @@ describe('matchparen', function() feed('V<c-d><c-d>') screen:expect([[ - {2:{} | - {2:}} | - {2:{} | - {2:f} | + {17:{} | + {17:}} | + {17:{} | + {17:f} | ^g | } | - {1:-- VISUAL LINE --} | + {5:-- VISUAL LINE --} | ]]) end) @@ -61,13 +56,15 @@ describe('matchparen', function() set hidden call setline(1, ['()']) normal 0 + + func OtherBuffer() + enew + exe "normal iaa\<Esc>0" + endfunc ]]) screen:expect(screen1) - exec([[ - enew - exe "normal iaa\<Esc>0" - ]]) + exec('call OtherBuffer()') screen:expect(screen2) feed('<C-^>') @@ -77,17 +74,43 @@ describe('matchparen', function() screen:expect(screen2) end) + -- oldtest: Test_matchparen_win_execute() + it('matchparen highlight when switching buffer in win_execute()', function() + local screen = Screen.new(20, 5) + screen:set_default_attr_ids({ + [1] = { background = Screen.colors.Cyan }, + [2] = { reverse = true, bold = true }, + [3] = { reverse = true }, + }) + screen:attach() + + exec([[ + source $VIMRUNTIME/plugin/matchparen.vim + let s:win = win_getid() + call setline(1, '{}') + split + + func SwitchBuf() + call win_execute(s:win, 'enew | buffer #') + endfunc + ]]) + screen:expect([[ + {1:^{}} | + {2:[No Name] [+] }| + {} | + {3:[No Name] [+] }| + | + ]]) + + -- Switching buffer away and back shouldn't change matchparen highlight. + exec('call SwitchBuf()') + screen:expect_unchanged() + end) + -- oldtest: Test_matchparen_pum_clear() it('is cleared when completion popup is shown', function() local screen = Screen.new(30, 9) screen:attach() - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, - [1] = { background = Screen.colors.Plum1 }, - [2] = { background = Screen.colors.Grey }, - [3] = { bold = true }, - [4] = { bold = true, foreground = Screen.colors.SeaGreen }, - }) exec([[ source $VIMRUNTIME/plugin/matchparen.vim @@ -103,11 +126,11 @@ describe('matchparen', function() aaa | aaaa | (aaa^) | - {1: aa }{0: }| - {2: aaa }{0: }| - {1: aaaa }{0: }| - {0:~ }| - {3:-- }{4:match 2 of 3} | + {4: aa }{1: }| + {12: aaa }{1: }| + {4: aaaa }{1: }| + {1:~ }| + {5:-- }{6:match 2 of 3} | ]], } end) diff --git a/test/functional/legacy/memory_usage_spec.lua b/test/functional/legacy/memory_usage_spec.lua index a05e9fdf57..87890d4c25 100644 --- a/test/functional/legacy/memory_usage_spec.lua +++ b/test/functional/legacy/memory_usage_spec.lua @@ -1,17 +1,19 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eval = helpers.eval -local eq = helpers.eq -local feed_command = helpers.feed_command -local retry = helpers.retry -local ok = helpers.ok -local source = helpers.source -local poke_eventloop = helpers.poke_eventloop -local load_adjust = helpers.load_adjust -local write_file = helpers.write_file -local is_os = helpers.is_os -local is_ci = helpers.is_ci -local is_asan = helpers.is_asan +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eval = n.eval +local eq = t.eq +local feed_command = n.feed_command +local retry = t.retry +local ok = t.ok +local source = n.source +local poke_eventloop = n.poke_eventloop +local load_adjust = n.load_adjust +local write_file = t.write_file +local is_os = t.is_os +local is_ci = t.is_ci +local is_asan = n.is_asan clear() if is_asan() then @@ -59,7 +61,7 @@ local monitor_memory_usage = { end table.remove(self.hist, 1) self.last = self.hist[#self.hist] - eq(#result, 1) + eq(1, #result) end) end, dump = function(self) diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index a87398b158..2f3693b5ad 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -1,12 +1,13 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local exec = helpers.exec -local feed = helpers.feed -local api = helpers.api -local nvim_dir = helpers.nvim_dir -local assert_alive = helpers.assert_alive + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed +local api = n.api +local nvim_dir = n.nvim_dir +local assert_alive = n.assert_alive before_each(clear) @@ -16,12 +17,6 @@ describe('messages', function() -- oldtest: Test_warning_scroll() it('a warning causes scrolling if and only if it has a stacktrace', function() screen = Screen.new(75, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - [2] = { bold = true, reverse = true }, -- MsgSeparator - [3] = { foreground = Screen.colors.Red }, -- WarningMsg - }) screen:attach() -- When the warning comes from a script, messages are scrolled so that the @@ -35,14 +30,14 @@ describe('messages', function() screen:expect({ grid = [[ | - {0:~ }|*4 - {3:W10: Warning: Changing a readonly file}^ | + {1:~ }|*4 + {19:W10: Warning: Changing a readonly file}^ | ]], timeout = 500, }) screen:expect([[ ^ | - {0:~ }|*4 + {1:~ }|*4 Already at oldest change | ]]) end) @@ -50,10 +45,6 @@ describe('messages', function() -- oldtest: Test_message_not_cleared_after_mode() it('clearing mode does not remove message', function() screen = Screen.new(60, 10) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - }) screen:attach() exec([[ nmap <silent> gx :call DebugSilent('normal')<CR> @@ -71,7 +62,7 @@ describe('messages', function() ^one | NoSuchFile | three | - {0:~ }|*6 + {1:~ }|*6 from DebugSilent normal | ]]) @@ -81,7 +72,7 @@ describe('messages', function() ^one | NoSuchFile | three | - {0:~ }|*6 + {1:~ }|*6 from DebugSilent visual | ]]) @@ -92,9 +83,9 @@ describe('messages', function() one | NoSuchFil^e | three | - {0:~ }|*5 + {1:~ }|*5 from DebugSilent visual | - {1:E447: Can't find file "NoSuchFile" in path} | + {9:E447: Can't find file "NoSuchFile" in path} | ]]) end) @@ -403,10 +394,6 @@ describe('messages', function() -- oldtest: Test_echo_verbose_system() it('verbose message before echo command', function() screen = Screen.new(60, 10) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - }) screen:attach() command('cd ' .. nvim_dir) @@ -426,7 +413,7 @@ describe('messages', function() 4: foo | 5: foo | 6: foo | - {1:-- More --}^ | + {6:-- More --}^ | ]]) feed('<Space>') screen:expect([[ @@ -439,7 +426,7 @@ describe('messages', function() 13: foo | 14: foo | 15: foo | - {1:-- More --}^ | + {6:-- More --}^ | ]]) feed('b') screen:expect([[ @@ -452,7 +439,7 @@ describe('messages', function() 4: foo | 5: foo | 6: foo | - {1:-- More --}^ | + {6:-- More --}^ | ]]) -- do the same with 'cmdheight' set to 2 @@ -460,7 +447,7 @@ describe('messages', function() command('set ch=2') screen:expect([[ ^ | - {0:~ }|*7 + {1:~ }|*7 |*2 ]]) feed([[:4 verbose echo system('foo')<CR>]]) @@ -474,7 +461,7 @@ describe('messages', function() 4: foo | 5: foo | 6: foo | - {1:-- More --}^ | + {6:-- More --}^ | ]]) feed('<Space>') screen:expect([[ @@ -487,7 +474,7 @@ describe('messages', function() 13: foo | 14: foo | 15: foo | - {1:-- More --}^ | + {6:-- More --}^ | ]]) feed('b') screen:expect([[ @@ -500,37 +487,32 @@ describe('messages', function() 4: foo | 5: foo | 6: foo | - {1:-- More --}^ | + {6:-- More --}^ | ]]) end) -- oldtest: Test_quit_long_message() it('with control characters can be quit vim-patch:8.2.1844', function() screen = Screen.new(40, 10) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - [2] = { foreground = Screen.colors.Blue }, -- SpecialKey - }) screen:attach() feed([[:echom range(9999)->join("\x01")<CR>]]) screen:expect([[ - 0{2:^A}1{2:^A}2{2:^A}3{2:^A}4{2:^A}5{2:^A}6{2:^A}7{2:^A}8{2:^A}9{2:^A}10{2:^A}11{2:^A}12| - {2:^A}13{2:^A}14{2:^A}15{2:^A}16{2:^A}17{2:^A}18{2:^A}19{2:^A}20{2:^A}21{2:^A}22| - {2:^A}23{2:^A}24{2:^A}25{2:^A}26{2:^A}27{2:^A}28{2:^A}29{2:^A}30{2:^A}31{2:^A}32| - {2:^A}33{2:^A}34{2:^A}35{2:^A}36{2:^A}37{2:^A}38{2:^A}39{2:^A}40{2:^A}41{2:^A}42| - {2:^A}43{2:^A}44{2:^A}45{2:^A}46{2:^A}47{2:^A}48{2:^A}49{2:^A}50{2:^A}51{2:^A}52| - {2:^A}53{2:^A}54{2:^A}55{2:^A}56{2:^A}57{2:^A}58{2:^A}59{2:^A}60{2:^A}61{2:^A}62| - {2:^A}63{2:^A}64{2:^A}65{2:^A}66{2:^A}67{2:^A}68{2:^A}69{2:^A}70{2:^A}71{2:^A}72| - {2:^A}73{2:^A}74{2:^A}75{2:^A}76{2:^A}77{2:^A}78{2:^A}79{2:^A}80{2:^A}81{2:^A}82| - {2:^A}83{2:^A}84{2:^A}85{2:^A}86{2:^A}87{2:^A}88{2:^A}89{2:^A}90{2:^A}91{2:^A}92| - {1:-- More --}^ | + 0{18:^A}1{18:^A}2{18:^A}3{18:^A}4{18:^A}5{18:^A}6{18:^A}7{18:^A}8{18:^A}9{18:^A}10{18:^A}11{18:^A}12| + {18:^A}13{18:^A}14{18:^A}15{18:^A}16{18:^A}17{18:^A}18{18:^A}19{18:^A}20{18:^A}21{18:^A}22| + {18:^A}23{18:^A}24{18:^A}25{18:^A}26{18:^A}27{18:^A}28{18:^A}29{18:^A}30{18:^A}31{18:^A}32| + {18:^A}33{18:^A}34{18:^A}35{18:^A}36{18:^A}37{18:^A}38{18:^A}39{18:^A}40{18:^A}41{18:^A}42| + {18:^A}43{18:^A}44{18:^A}45{18:^A}46{18:^A}47{18:^A}48{18:^A}49{18:^A}50{18:^A}51{18:^A}52| + {18:^A}53{18:^A}54{18:^A}55{18:^A}56{18:^A}57{18:^A}58{18:^A}59{18:^A}60{18:^A}61{18:^A}62| + {18:^A}63{18:^A}64{18:^A}65{18:^A}66{18:^A}67{18:^A}68{18:^A}69{18:^A}70{18:^A}71{18:^A}72| + {18:^A}73{18:^A}74{18:^A}75{18:^A}76{18:^A}77{18:^A}78{18:^A}79{18:^A}80{18:^A}81{18:^A}82| + {18:^A}83{18:^A}84{18:^A}85{18:^A}86{18:^A}87{18:^A}88{18:^A}89{18:^A}90{18:^A}91{18:^A}92| + {6:-- More --}^ | ]]) feed('q') screen:expect([[ ^ | - {0:~ }|*8 + {1:~ }|*8 | ]]) end) @@ -539,11 +521,6 @@ describe('messages', function() describe('mode is cleared when', function() before_each(function() screen = Screen.new(40, 6) - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [2] = { bold = true }, -- ModeMsg - [3] = { bold = true, reverse = true }, -- StatusLine - }) screen:attach() end) @@ -561,7 +538,7 @@ describe('messages', function() ^ | {1:~ }|*3 {3: }| - {2:-- INSERT --} | + {5:-- INSERT --} | ]]) feed('<C-C>') screen:expect([[ @@ -583,7 +560,7 @@ describe('messages', function() ^ | {1:~ }|*3 {3:[No Name] }| - {2:-- INSERT --} | + {5:-- INSERT --} | ]]) feed('<Esc>') screen:expect([[ @@ -600,7 +577,7 @@ describe('messages', function() screen:expect([[ ^ | {1:~ }|*4 - {2:-- (insert) --} | + {5:-- (insert) --} | ]]) feed('<C-C>') screen:expect([[ @@ -614,11 +591,6 @@ describe('messages', function() -- oldtest: Test_ask_yesno() it('y/n prompt works', function() screen = Screen.new(75, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - [2] = { bold = true, reverse = true }, -- MsgSeparator - }) screen:attach() command('set noincsearch nohlsearch inccommand=') command('call setline(1, range(1, 2))') @@ -627,57 +599,51 @@ describe('messages', function() screen:expect([[ 1 | 2 | - {0:~ }|*3 - {1:Backwards range given, OK to swap (y/n)?}^ | + {1:~ }|*3 + {6:Backwards range given, OK to swap (y/n)?}^ | ]]) feed('n') screen:expect([[ ^1 | 2 | - {0:~ }|*3 - {1:Backwards range given, OK to swap (y/n)?}n | + {1:~ }|*3 + {6:Backwards range given, OK to swap (y/n)?}n | ]]) feed(':2,1s/^/Esc/\n') screen:expect([[ 1 | 2 | - {0:~ }|*3 - {1:Backwards range given, OK to swap (y/n)?}^ | + {1:~ }|*3 + {6:Backwards range given, OK to swap (y/n)?}^ | ]]) feed('<Esc>') screen:expect([[ ^1 | 2 | - {0:~ }|*3 - {1:Backwards range given, OK to swap (y/n)?}n | + {1:~ }|*3 + {6:Backwards range given, OK to swap (y/n)?}n | ]]) feed(':2,1s/^/y/\n') screen:expect([[ 1 | 2 | - {0:~ }|*3 - {1:Backwards range given, OK to swap (y/n)?}^ | + {1:~ }|*3 + {6:Backwards range given, OK to swap (y/n)?}^ | ]]) feed('y') screen:expect([[ y1 | ^y2 | - {0:~ }|*3 - {1:Backwards range given, OK to swap (y/n)?}y | + {1:~ }|*3 + {6:Backwards range given, OK to swap (y/n)?}y | ]]) end) -- oldtest: Test_fileinfo_tabpage_cmdheight() it("fileinfo works when 'cmdheight' has just decreased", function() screen = Screen.new(40, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true }, -- TabLineSel - [2] = { underline = true, background = Screen.colors.LightGrey }, -- TabLine - [3] = { reverse = true }, -- TabLineFill - }) screen:attach() exec([[ @@ -688,17 +654,17 @@ describe('messages', function() set cmdheight=2 ]]) screen:expect([[ - {2: [No Name] }{1: [No Name] }{3: }{2:X}| + {24: [No Name] }{5: [No Name] }{2: }{24:X}| ^ | - {0:~ }|*2 + {1:~ }|*2 |*2 ]]) feed(':tabprev | edit Xfileinfo.txt<CR>') screen:expect([[ - {1: Xfileinfo.txt }{2: [No Name] }{3: }{2:X}| + {5: Xfileinfo.txt }{24: [No Name] }{2: }{24:X}| ^ | - {0:~ }|*3 + {1:~ }|*3 "Xfileinfo.txt" [New] | ]]) assert_alive() @@ -707,9 +673,6 @@ describe('messages', function() -- oldtest: Test_fileinfo_after_echo() it('fileinfo does not overwrite echo message vim-patch:8.2.4156', function() screen = Screen.new(40, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - }) screen:attach() exec([[ @@ -730,7 +693,7 @@ describe('messages', function() feed('0$') screen:expect([[ ^hi | - {0:~ }|*4 + {1:~ }|*4 'b' written | ]]) os.remove('b.txt') diff --git a/test/functional/legacy/mksession_spec.lua b/test/functional/legacy/mksession_spec.lua index 689d918cd9..28d4637954 100644 --- a/test/functional/legacy/mksession_spec.lua +++ b/test/functional/legacy/mksession_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local fn = helpers.fn -local eq = helpers.eq +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local fn = n.fn +local eq = t.eq describe('mksession', function() before_each(clear) diff --git a/test/functional/legacy/move_spec.lua b/test/functional/legacy/move_spec.lua index 1500d48ad9..c2be8bb3eb 100644 --- a/test/functional/legacy/move_spec.lua +++ b/test/functional/legacy/move_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local feed = helpers.feed -local fn = helpers.fn + +local clear = n.clear +local feed = n.feed +local fn = n.fn before_each(clear) @@ -10,9 +11,6 @@ describe(':move', function() -- oldtest: Test_move_undo() it('redraws correctly when undone', function() local screen = Screen.new(60, 10) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - }) screen:attach() fn.setline(1, { 'First', 'Second', 'Third', 'Fourth' }) @@ -22,7 +20,7 @@ describe(':move', function() ^First | Third | Fourth | - {0:~ }|*5 + {1:~ }|*5 :move +1 | ]]) @@ -34,7 +32,7 @@ describe(':move', function() Second | Third | Fourth | - {0:~ }|*5 + {1:~ }|*5 | ]]) end) diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua index 7a2ba1ecf2..5e981b5862 100644 --- a/test/functional/legacy/nested_function_spec.lua +++ b/test/functional/legacy/nested_function_spec.lua @@ -1,8 +1,9 @@ -- Tests for nested function. -local helpers = require('test.functional.helpers')(after_each) -local clear, insert = helpers.clear, helpers.insert -local command, expect, source = helpers.command, helpers.expect, helpers.source +local n = require('test.functional.testnvim')() + +local clear, insert = n.clear, n.insert +local command, expect, source = n.command, n.expect, n.source describe('test_nested_function', function() setup(clear) diff --git a/test/functional/legacy/normal_spec.lua b/test/functional/legacy/normal_spec.lua index 1dddeed033..5158ca3009 100644 --- a/test/functional/legacy/normal_spec.lua +++ b/test/functional/legacy/normal_spec.lua @@ -1,35 +1,106 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -before_each(clear) +local clear = n.clear +local exec = n.exec +local feed = n.feed +local api = n.api +local eq = t.eq +local fn = n.fn describe('normal', function() + local screen + + before_each(function() + clear() + screen = Screen.new(40, 19) + screen:attach() + end) + -- oldtest: Test_normal_j_below_botline() - it( - [["j" does not skip lines when scrolling below botline and 'foldmethod' is not "manual"]], - function() - local screen = Screen.new(40, 19) - screen:attach() - screen:set_default_attr_ids({ { foreground = Screen.colors.Brown } }) - exec([[ + it([[no skipped lines with "j" scrolling below botline and 'foldmethod' not "manual"]], function() + exec([[ set number foldmethod=diff scrolloff=0 call setline(1, map(range(1, 9), 'repeat(v:val, 200)')) norm Lj ]]) - screen:expect([[ - {1: 2 }222222222222222222222222222222222222| - {1: }222222222222222222222222222222222222|*4 - {1: }22222222222222222222 | - {1: 3 }333333333333333333333333333333333333| - {1: }333333333333333333333333333333333333|*4 - {1: }33333333333333333333 | - {1: 4 }^444444444444444444444444444444444444| - {1: }444444444444444444444444444444444444|*4 - {1: }44444444444444444444 | + screen:expect([[ + {8: 2 }222222222222222222222222222222222222| + {8: }222222222222222222222222222222222222|*4 + {8: }22222222222222222222 | + {8: 3 }333333333333333333333333333333333333| + {8: }333333333333333333333333333333333333|*4 + {8: }33333333333333333333 | + {8: 4 }^444444444444444444444444444444444444| + {8: }444444444444444444444444444444444444|*4 + {8: }44444444444444444444 | | ]]) - end - ) + end) + + -- oldtest: Test_single_line_scroll() + it('(Half)-page scroll up or down reveals virtual lines #19605, #27967', function() + fn.setline(1, 'foobar one two three') + exec('set smoothscroll') + local ns = api.nvim_create_namespace('') + api.nvim_buf_set_extmark(0, ns, 0, 0, { + virt_lines = { { { '---', 'IncSearch' } } }, + virt_lines_above = true, + }) + -- Nvim: not actually necessary to scroll down to hide the virtual line. + -- Check topfill instead of skipcol and show the screen state. + feed('<C-E>') + eq(0, fn.winsaveview().topfill) + local s1 = [[ + ^foobar one two three | + {1:~ }|*17 + | + ]] + screen:expect(s1) + feed('<C-B>') + eq(1, fn.winsaveview().topfill) + local s2 = [[ + {2:---} | + ^foobar one two three | + {1:~ }|*16 + | + ]] + screen:expect(s2) + feed('<C-E>') + eq(0, fn.winsaveview().topfill) + screen:expect(s1) + feed('<C-U>') + eq(1, fn.winsaveview().topfill) + screen:expect(s2) + + -- Nvim: also test virt_lines below the last line + feed('yy100pG<C-L>') + api.nvim_buf_set_extmark(0, ns, 100, 0, { virt_lines = { { { '---', 'IncSearch' } } } }) + screen:expect({ + grid = [[ + foobar one two three |*17 + ^foobar one two three | + | + ]], + }) + feed('<C-F>') + screen:expect({ + grid = [[ + ^foobar one two three | + {2:---} | + {1:~ }|*16 + | + ]], + }) + feed('ggG<C-D>') + screen:expect({ + grid = [[ + foobar one two three |*16 + ^foobar one two three | + {2:---} | + | + ]], + }) + end) end) diff --git a/test/functional/legacy/number_spec.lua b/test/functional/legacy/number_spec.lua index c112532eed..0ebd731f65 100644 --- a/test/functional/legacy/number_spec.lua +++ b/test/functional/legacy/number_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local exec = helpers.exec -local feed = helpers.feed + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed describe("'number' and 'relativenumber'", function() before_each(clear) @@ -214,10 +215,6 @@ describe("'number' and 'relativenumber'", function() -- oldtest: Test_relativenumber_callback() it('relative line numbers are updated if cursor is moved from timer', function() local screen = Screen.new(50, 8) - screen:set_default_attr_ids({ - [1] = { foreground = Screen.colors.Brown }, -- LineNr - [2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText - }) screen:attach() exec([[ call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) @@ -232,22 +229,22 @@ describe("'number' and 'relativenumber'", function() ]]) screen:expect({ grid = [[ - {1: 3 }aaaaa | - {1: 2 }bbbbb | - {1: 1 }ccccc | - {1: 0 }^ddddd | - {2:~ }|*3 + {8: 3 }aaaaa | + {8: 2 }bbbbb | + {8: 1 }ccccc | + {8: 0 }^ddddd | + {1:~ }|*3 | ]], timeout = 100, }) screen:expect({ grid = [[ - {1: 0 }^aaaaa | - {1: 1 }bbbbb | - {1: 2 }ccccc | - {1: 3 }ddddd | - {2:~ }|*3 + {8: 0 }^aaaaa | + {8: 1 }bbbbb | + {8: 2 }ccccc | + {8: 3 }ddddd | + {1:~ }|*3 | ]], }) @@ -256,10 +253,6 @@ describe("'number' and 'relativenumber'", function() -- oldtest: Test_number_insert_delete_lines() it('line numbers are updated when deleting/inserting lines', function() local screen = Screen.new(50, 8) - screen:set_default_attr_ids({ - [1] = { foreground = Screen.colors.Brown }, -- LineNr - [2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText - }) screen:attach() exec([[ call setline(1, range(1, 7)) @@ -267,37 +260,37 @@ describe("'number' and 'relativenumber'", function() call cursor(2, 1) ]]) local snapshot1 = [[ - {1: 1 }1 | - {1: 2 }^2 | - {1: 3 }3 | - {1: 4 }4 | - {1: 5 }5 | - {1: 6 }6 | - {1: 7 }7 | + {8: 1 }1 | + {8: 2 }^2 | + {8: 3 }3 | + {8: 4 }4 | + {8: 5 }5 | + {8: 6 }6 | + {8: 7 }7 | | ]] screen:expect(snapshot1) feed('dd') screen:expect([[ - {1: 1 }1 | - {1: 2 }^3 | - {1: 3 }4 | - {1: 4 }5 | - {1: 5 }6 | - {1: 6 }7 | - {2:~ }| + {8: 1 }1 | + {8: 2 }^3 | + {8: 3 }4 | + {8: 4 }5 | + {8: 5 }6 | + {8: 6 }7 | + {1:~ }| | ]]) feed('P') screen:expect(snapshot1) feed('2dd') screen:expect([[ - {1: 1 }1 | - {1: 2 }^4 | - {1: 3 }5 | - {1: 4 }6 | - {1: 5 }7 | - {2:~ }|*2 + {8: 1 }1 | + {8: 2 }^4 | + {8: 3 }5 | + {8: 4 }6 | + {8: 5 }7 | + {1:~ }|*2 | ]]) feed('P') diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua index 2f20b6bd51..e9a3b73cf7 100644 --- a/test/functional/legacy/options_spec.lua +++ b/test/functional/legacy/options_spec.lua @@ -1,11 +1,13 @@ -- See also: test/old/testdir/test_options.vim -local helpers = require('test.functional.helpers')(after_each) -local command, clear = helpers.command, helpers.clear -local source, expect = helpers.source, helpers.expect -local exc_exec = helpers.exc_exec -local matches = helpers.matches +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local command, clear = n.command, n.clear +local source, expect = n.source, n.expect +local exc_exec = n.exc_exec +local matches = t.matches + describe('options', function() setup(clear) @@ -66,11 +68,11 @@ describe('set', function() command('verbose set scroll?') screen:expect([[ | - ~ |*11 - | + {1:~ }|*11 + {3: }| scroll=7 | Last set from changed window size | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) end) diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index e4810feedb..72ec420b15 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -1,14 +1,16 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = helpers.feed -local source = helpers.source -local clear = helpers.clear -local command = helpers.command -local expect = helpers.expect -local poke_eventloop = helpers.poke_eventloop -local api = helpers.api -local eq = helpers.eq -local neq = helpers.neq + +local feed = n.feed +local source = n.source +local clear = n.clear +local command = n.command +local expect = n.expect +local poke_eventloop = n.poke_eventloop +local api = n.api +local eq = t.eq +local neq = t.neq describe('prompt buffer', function() local screen @@ -58,11 +60,11 @@ describe('prompt buffer', function() ]]) screen:expect([[ cmd: ^ | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {3:[Prompt] [+] }| other buffer | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) end @@ -79,15 +81,15 @@ describe('prompt buffer', function() Command: "hello" | Result: "hello" | cmd: ^ | - [Prompt] | + {3:[Prompt] }| other buffer | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) feed('exit\n') screen:expect([[ ^other buffer | - ~ |*8 + {1:~ }|*8 | ]]) end) @@ -98,43 +100,43 @@ describe('prompt buffer', function() feed('hello<BS><BS>') screen:expect([[ cmd: hel^ | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {3:[Prompt] [+] }| other buffer | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) feed('<Left><Left><Left><BS>-') screen:expect([[ cmd: -^hel | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {3:[Prompt] [+] }| other buffer | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) feed('<C-O>lz') screen:expect([[ cmd: -hz^el | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {3:[Prompt] [+] }| other buffer | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) feed('<End>x') screen:expect([[ cmd: -hzelx^ | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {3:[Prompt] [+] }| other buffer | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) feed('<C-U>exit\n') screen:expect([[ ^other buffer | - ~ |*8 + {1:~ }|*8 | ]]) end) @@ -143,32 +145,30 @@ describe('prompt buffer', function() it('switch windows', function() source_script() feed('<C-O>:call SwitchWindows()<CR>') - screen:expect { - grid = [[ + screen:expect([[ cmd: | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {2:[Prompt] [+] }| ^other buffer | - ~ |*3 + {1:~ }|*3 | - ]], - } + ]]) feed('<C-O>:call SwitchWindows()<CR>') screen:expect([[ cmd: ^ | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {3:[Prompt] [+] }| other buffer | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) feed('<Esc>') screen:expect([[ cmd:^ | - ~ |*3 - [Prompt] [+] | + {1:~ }|*3 + {3:[Prompt] [+] }| other buffer | - ~ |*3 + {1:~ }|*3 | ]]) end) diff --git a/test/functional/legacy/put_spec.lua b/test/functional/legacy/put_spec.lua index c78946d690..587424da10 100644 --- a/test/functional/legacy/put_spec.lua +++ b/test/functional/legacy/put_spec.lua @@ -1,10 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec_lua = helpers.exec_lua -local api = helpers.api -local source = helpers.source -local eq = helpers.eq + +local clear = n.clear +local exec_lua = n.exec_lua +local api = n.api +local source = n.source +local eq = t.eq local function sizeoflong() if not exec_lua('return pcall(require, "ffi")') then @@ -66,8 +68,8 @@ describe('put', function() three more text │ three more text | ^four more text │ four more text | │ | - ~ │~ |*2 - [No Name] [+] [No Name] [+] | + {1:~ }│{1:~ }|*2 + {3:[No Name] [+] }{2:[No Name] [+] }| | ]]) end) diff --git a/test/functional/legacy/qf_title_spec.lua b/test/functional/legacy/qf_title_spec.lua index 9f97eb27b2..26b096d633 100644 --- a/test/functional/legacy/qf_title_spec.lua +++ b/test/functional/legacy/qf_title_spec.lua @@ -1,8 +1,9 @@ -- Tests for quickfix window's title -local helpers = require('test.functional.helpers')(after_each) -local insert, source = helpers.insert, helpers.source -local clear, expect = helpers.clear, helpers.expect +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, expect = n.clear, n.expect describe('qf_title', function() setup(clear) diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua index 8d22c299d6..97578067d5 100644 --- a/test/functional/legacy/scroll_opt_spec.lua +++ b/test/functional/legacy/scroll_opt_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed -local assert_alive = helpers.assert_alive + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local assert_alive = n.assert_alive before_each(clear) @@ -23,9 +24,9 @@ describe('smoothscroll', function() set number ]]) feed('<C-Y>') - screen:expect({ any = ' 1 ^one' }) + screen:expect({ any = '{8: 1 }^one' }) feed('<C-E><C-E><C-E>') - screen:expect({ any = ' 2 ^two' }) + screen:expect({ any = '{8: 2 }^two' }) end) -- oldtest: Test_smoothscroll_CtrlE_CtrlY() @@ -43,28 +44,28 @@ describe('smoothscroll', function() long word long word long word | ^line | line |*2 - ~ |*2 + {1:~ }|*2 | ]] local s2 = [[ - <<<d word word word word word word word | + {1:<<<}d word word word word word word word | word word word word | line three | long word long word long word long word | long word long word long word | ^line | line |*2 - ~ |*3 + {1:~ }|*3 | ]] local s3 = [[ - <<<d word word word | + {1:<<<}d word word word | line three | long word long word long word long word | long word long word long word | ^line | line |*2 - ~ |*4 + {1:~ }|*4 | ]] local s4 = [[ @@ -73,28 +74,28 @@ describe('smoothscroll', function() long word long word long word | line |*2 ^line | - ~ |*5 + {1:~ }|*5 | ]] local s5 = [[ - <<<d word word word | + {1:<<<}d word word word | line three | long word long word long word long word | long word long word long word | line |*2 ^line | - ~ |*4 + {1:~ }|*4 | ]] local s6 = [[ - <<<d word word word word word word word | + {1:<<<}d word word word word word word word | word word word word | line three | long word long word long word long word | long word long word long word | line |*2 ^line | - ~ |*3 + {1:~ }|*3 | ]] local s7 = [[ @@ -105,7 +106,7 @@ describe('smoothscroll', function() long word long word long word | line |*2 ^line | - ~ |*2 + {1:~ }|*2 | ]] local s8 = [[ @@ -117,7 +118,7 @@ describe('smoothscroll', function() long word long word long word | line |*2 ^line | - ~ | + {1:~ }| | ]] feed('<C-E>') @@ -160,7 +161,7 @@ describe('smoothscroll', function() ϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛ^ϛϛϛϛϛ| ϛϛϛϛϛ | 222222222222222222222222222222222222 | - ~ |*2 + {1:~ }|*2 | ]]) end) @@ -181,134 +182,136 @@ describe('smoothscroll', function() endfunc ]]) screen:expect([[ - 1 one word word word word word word wo| + {8: 1 }one word word word word word word wo| rd word word word word word word word wo| rd word word word word word | - 2 two long word long word long word lo| + {8: 2 }two long word long word long word lo| ng word long word long word long word | - 3 ^line | - 4 line | - 5 line | - ~ |*3 + {8: 3 }^line | + {8: 4 }line | + {8: 5 }line | + {1:~ }|*3 | ]]) feed('<C-E>') screen:expect([[ - <<<word word word word word word word wo| + {1:<<<}word word word word word word word wo| rd word word word word word | - 2 two long word long word long word lo| + {8: 2 }two long word long word long word lo| ng word long word long word long word | - 3 ^line | - 4 line | - 5 line | - ~ |*4 + {8: 3 }^line | + {8: 4 }line | + {8: 5 }line | + {1:~ }|*4 | ]]) feed('<C-E>') screen:expect([[ - <<<word word word word word | - 2 two long word long word long word lo| + {1:<<<}word word word word word | + {8: 2 }two long word long word long word lo| ng word long word long word long word | - 3 ^line | - 4 line | - 5 line | - ~ |*5 + {8: 3 }^line | + {8: 4 }line | + {8: 5 }line | + {1:~ }|*5 | ]]) exec('set cpo-=n') screen:expect([[ - <<< d word word word word word word | - 2 two long word long word long word lo| - ng word long word long word long wor| - d | - 3 ^line | - 4 line | - 5 line | - ~ |*4 + {1:<<<}{8: }d word word word word word word | + {8: 2 }two long word long word long word lo| + {8: }ng word long word long word long wor| + {8: }d | + {8: 3 }^line | + {8: 4 }line | + {8: 5 }line | + {1:~ }|*4 | ]]) feed('<C-Y>') screen:expect([[ - <<< rd word word word word word word wor| - d word word word word word word | - 2 two long word long word long word lo| - ng word long word long word long wor| - d | - 3 ^line | - 4 line | - 5 line | - ~ |*3 + {1:<<<}{8: }rd word word word word word word wor| + {8: }d word word word word word word | + {8: 2 }two long word long word long word lo| + {8: }ng word long word long word long wor| + {8: }d | + {8: 3 }^line | + {8: 4 }line | + {8: 5 }line | + {1:~ }|*3 | ]]) feed('<C-Y>') screen:expect([[ - 1 one word word word word word word wo| - rd word word word word word word wor| - d word word word word word word | - 2 two long word long word long word lo| - ng word long word long word long wor| - d | - 3 ^line | - 4 line | - 5 line | - ~ |*2 + {8: 1 }one word word word word word word wo| + {8: }rd word word word word word word wor| + {8: }d word word word word word word | + {8: 2 }two long word long word long word lo| + {8: }ng word long word long word long wor| + {8: }d | + {8: 3 }^line | + {8: 4 }line | + {8: 5 }line | + {1:~ }|*2 | ]]) exec('botright split') feed('gg') screen:expect([[ - 1 one word word word word word word wo| - rd word word word word word word wor| - d word word word word word word | - 2 two long word long word long word@@@| - [No Name] [+] | - 1 ^one word word word word word word wo| - rd word word word word word word wor| - d word word word word word word | - 2 two long word long word long word lo| - ng word long word long word long @@@| - [No Name] [+] | + {8: 1 }one word word word word word word wo| + {8: }rd word word word word word word wor| + {8: }d word word word word word word | + {8: 2 }two long word long word long word{1:@@@}| + {2:[No Name] [+] }| + {8: 1 }^one word word word word word word wo| + {8: }rd word word word word word word wor| + {8: }d word word word word word word | + {8: 2 }two long word long word long word lo| + {8: }ng word long word long word long {1:@@@}| + {3:[No Name] [+] }| | ]]) + feed('<C-E>') screen:expect([[ - 1 one word word word word word word wo| - rd word word word word word word wor| - d word word word word word word | - 2 two long word long word long word@@@| - [No Name] [+] | - <<< rd word word word word word word wor| - d word word word word word word^ | - 2 two long word long word long word lo| - ng word long word long word long wor| - d | - [No Name] [+] | + {8: 1 }one word word word word word word wo| + {8: }rd word word word word word word wor| + {8: }d word word word word word word | + {8: 2 }two long word long word long word{1:@@@}| + {2:[No Name] [+] }| + {1:<<<}{8: }rd word word word word word word wor| + {8: }d word word word word word word^ | + {8: 2 }two long word long word long word lo| + {8: }ng word long word long word long wor| + {8: }d | + {3:[No Name] [+] }| | ]]) + feed('<C-E>') screen:expect([[ - 1 one word word word word word word wo| - rd word word word word word word wor| - d word word word word word word | - 2 two long word long word long word@@@| - [No Name] [+] | - <<< d word word word word word word^ | - 2 two long word long word long word lo| - ng word long word long word long wor| - d | - 3 line | - [No Name] [+] | + {8: 1 }one word word word word word word wo| + {8: }rd word word word word word word wor| + {8: }d word word word word word word | + {8: 2 }two long word long word long word{1:@@@}| + {2:[No Name] [+] }| + {1:<<<}{8: }d word word word word word word^ | + {8: 2 }two long word long word long word lo| + {8: }ng word long word long word long wor| + {8: }d | + {8: 3 }line | + {3:[No Name] [+] }| | ]]) exec('close') exec('call DoRel()') screen:expect([[ - 2<<<^ong text very long text very long te| - xt very long text very long text ver| - y long text very long text very long| - text very long text very long text | - 1 three | - ~ |*6 + {8:2}{1:<<<}^ong text very long text very long te| + {8: }xt very long text very long text ver| + {8: }y long text very long text very long| + {8: } text very long text very long text | + {8: 1 }three | + {1:~ }|*6 --No lines in buffer-- | ]]) end) @@ -323,22 +326,22 @@ describe('smoothscroll', function() exe "normal 2Gzt\<C-E>" ]]) screen:expect([[ - <<<t very long text very long text very | + {1:<<<}t very long text very long text very | ^long text very long text very long text | very long text very long text very long | - text very long text- | + text very long text{1:-} | three | - ~ |*2 + {1:~ }|*2 | ]]) exec('set listchars+=precedes:#') screen:expect([[ - #ext very long text very long text very | + {1:#}ext very long text very long text very | ^long text very long text very long text | very long text very long text very long | - text very long text- | + text very long text{1:-} | three | - ~ |*2 + {1:~ }|*2 | ]]) end) @@ -356,13 +359,14 @@ describe('smoothscroll', function() set smoothscroll diffthis ]]) + screen:expect([[ - - ^just some text here | - ~ |*2 - [No Name] [+] | - - just some text here | - ~ | - [No Name] [+] | + {7:- }^just some text here | + {1:~ }|*2 + {3:[No Name] [+] }| + {7:- }just some text here | + {1:~ }| + {2:[No Name] [+] }| | ]]) feed('<C-Y>') @@ -380,7 +384,7 @@ describe('smoothscroll', function() :3 ]]) screen:expect([[ - <<<h some text with some text | + {1:<<<}h some text with some text | Line with some text with some text with | some text with some text with some text | with some text with some text | @@ -401,7 +405,7 @@ describe('smoothscroll', function() -- moving cursor up right after the <<< marker - no need to show whole line feed('2gj3l2k') screen:expect([[ - <<<^h some text with some text | + {1:<<<}^h some text with some text | Line with some text with some text with | some text with some text with some text | with some text with some text | @@ -419,7 +423,7 @@ describe('smoothscroll', function() Line with some text with some text with | some text with some text with some text | with some text with some text | - @ | + {1:@ }| | ]]) end) @@ -443,7 +447,7 @@ describe('smoothscroll', function() ]]) feed('<C-E>') screen:expect([[ - <<<th lot^s of text with lots of text wit| + {1:<<<}th lot^s of text with lots of text wit| h lots of text with lots of text with lo| ts of text with lots of text with lots o| f text with lots of text with lots of te| @@ -452,7 +456,7 @@ describe('smoothscroll', function() ]]) feed('5<C-E>') screen:expect([[ - <<< lots ^of text with lots of text with | + {1:<<<} lots ^of text with lots of text with | lots of text with lots of text with lots| of text with lots of text with lots of | text with lots of text with lots of text| @@ -462,7 +466,7 @@ describe('smoothscroll', function() -- scrolling down, cursor moves screen line up feed('5<C-Y>') screen:expect([[ - <<<th lots of text with lots of text wit| + {1:<<<}th lots of text with lots of text wit| h lots of text with lots of text with lo| ts of text with lots of text with lots o| f text with lots of text with lots of te| @@ -482,7 +486,7 @@ describe('smoothscroll', function() exec('set scrolloff=1') feed('10|<C-E>') screen:expect([[ - <<<th lots of text with lots of text wit| + {1:<<<}th lots of text with lots of text wit| h lots of^ text with lots of text with lo| ts of text with lots of text with lots o| f text with lots of text with lots of te| @@ -492,7 +496,7 @@ describe('smoothscroll', function() -- 'scrolloff' set to 1, scrolling down, cursor moves screen line up feed('<C-E>gjgj<C-Y>') screen:expect([[ - <<<th lots of text with lots of text wit| + {1:<<<}th lots of text with lots of text wit| h lots of text with lots of text with lo| ts of text with lots of text with lots o| f text wi^th lots of text with lots of te| @@ -503,7 +507,7 @@ describe('smoothscroll', function() exec('set scrolloff=2') feed('10|<C-E>') screen:expect([[ - <<<th lots of text with lots of text wit| + {1:<<<}th lots of text with lots of text wit| h lots of text with lots of text with lo| ts of tex^t with lots of text with lots o| f text with lots of text with lots of te| @@ -518,7 +522,7 @@ describe('smoothscroll', function() exec('set scrolloff=0') feed('0j') screen:expect([[ - <<<th lots of text with lots of text wit| + {1:<<<}th lots of text with lots of text wit| h lots of text with lots of text with lo| ts of text with lots of text with lots o| f text with lots of text end | @@ -529,20 +533,20 @@ describe('smoothscroll', function() feed('zt') screen:expect([[ ^four | - ~ |*4 + {1:~ }|*4 | ]]) feed('zz') screen:expect([[ - <<<of text with lots of text with lots o| + {1:<<<}of text with lots of text with lots o| f text with lots of text end | ^four | - ~ |*2 + {1:~ }|*2 | ]]) feed('zb') screen:expect([[ - <<<th lots of text with lots of text wit| + {1:<<<}th lots of text with lots of text wit| h lots of text with lots of text with lo| ts of text with lots of text with lots o| f text with lots of text end | @@ -567,7 +571,7 @@ describe('smoothscroll', function() -- screen. feed('3Gzt<C-E>j') screen:expect([[ - <<<th lots of text with lots of text wit| + {1:<<<}th lots of text with lots of text wit| h lots of text with lots of text with lo| ts of text with lots of text with lots o| f text with lots of text end | @@ -588,16 +592,16 @@ describe('smoothscroll', function() lots of text with lots of text with lot| s of text with lots of text with lots of| text | - ~ | + {1:~ }| | ]] screen:expect(s1) feed('<C-E>') screen:expect([[ - <<<ts of text with lots of text with lot| + {1:<<<}ts of text with lots of text with lot| ^s of text with lots of text with lots of| text | - ~ |*2 + {1:~ }|*2 | ]]) feed('0') @@ -612,20 +616,20 @@ describe('smoothscroll', function() exec('set smoothscroll scrolloff=0 showbreak=+++\\ ') local s1 = [[ ^with lots of text in one line with lots | - +++ of text in one line with lots of tex| - +++ t in one line with lots of text in o| - +++ ne line with lots of text in one lin| - +++ e with lots of text in one line | + {1:+++ }of text in one line with lots of tex| + {1:+++ }t in one line with lots of text in o| + {1:+++ }ne line with lots of text in one lin| + {1:+++ }e with lots of text in one line | | ]] screen:expect(s1) feed('<C-E>') screen:expect([[ - +++ ^of text in one line with lots of tex| - +++ t in one line with lots of text in o| - +++ ne line with lots of text in one lin| - +++ e with lots of text in one line | - ~ | + {1:+++ }^of text in one line with lots of tex| + {1:+++ }t in one line with lots of text in o| + {1:+++ }ne line with lots of text in one lin| + {1:+++ }e with lots of text in one line | + {1:~ }| | ]]) feed('0') @@ -642,13 +646,13 @@ describe('smoothscroll', function() screen:expect([[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 口口口口口口口口口口 | - ~ |*3 + {1:~ }|*3 | ]]) feed('<C-E>') screen:expect([[ - <<< 口口口口口口口^口 | - ~ |*4 + {1:<<<} 口口口口口口口^口 | + {1:~ }|*4 | ]]) end) @@ -656,10 +660,6 @@ describe('smoothscroll', function() -- oldtest: Test_smoothscroll_zero_width() it('does not divide by zero with a narrow window', function() screen:try_resize(12, 2) - screen:set_default_attr_ids({ - [1] = { foreground = Screen.colors.Brown }, - [2] = { foreground = Screen.colors.Blue1, bold = true }, - }) exec([[ call setline(1, ['a'->repeat(100)]) set wrap smoothscroll number laststatus=0 @@ -669,12 +669,12 @@ describe('smoothscroll', function() wincmd v ]]) screen:expect([[ - {1: 1^ }│{1: }│{1: }│{1: }│{1: }| + {8: 1^ }│{8: }│{8: }│{8: }│{8: }| | ]]) feed('llllllllll<C-W>o') screen:expect([[ - {2:<<<}{1: }aa^aaaaaa| + {1:<<<}{8: }aa^aaaaaa| | ]]) end) @@ -694,7 +694,7 @@ describe('smoothscroll', function() ]=]) feed('<C-E>gjgk') screen:expect([[ - <<<lots of text in one line^ | + {1:<<<}lots of text in one line^ | line two | line three | line four | @@ -717,7 +717,7 @@ describe('smoothscroll', function() call search('xxx') ]=]) screen:expect([[ - <<<_____________________________________| + {1:<<<}_____________________________________| ________________________________________| ______________________________________^xx| x______________________________________x| @@ -741,10 +741,10 @@ describe('smoothscroll', function() | ]]) exec("call setline(92, 'a'->repeat(100))") - feed('<C-B>G') + feed('<C-L><C-B>G') -- cursor is not placed below window screen:expect([[ - <<<aaaaaaaaaaaaaaaaa | + {1:<<<}aaaaaaaaaaaaaaaaa | |*7 ^ | | @@ -754,12 +754,6 @@ describe('smoothscroll', function() -- oldtest: Test_smoothscroll_incsearch() it('does not reset skipcol when doing incremental search on the same word', function() screen:try_resize(40, 8) - screen:set_default_attr_ids({ - [1] = { foreground = Screen.colors.Brown }, - [2] = { foreground = Screen.colors.Blue1, bold = true }, - [3] = { background = Screen.colors.Yellow1 }, - [4] = { reverse = true }, - }) exec([[ set smoothscroll number scrolloff=0 incsearch call setline(1, repeat([''], 20)) @@ -768,46 +762,46 @@ describe('smoothscroll', function() ]]) feed('/b') screen:expect([[ - {2:<<<}{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | - {1: 12 } | - {1: 13 } | - {1: 14 }{4:b}{3:bbb} | - {1: 15 } | - {1: 16 } | - {1: 17 } | + {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | + {8: 12 } | + {8: 13 } | + {8: 14 }{2:b}{10:bbb} | + {8: 15 } | + {8: 16 } | + {8: 17 } | /b^ | ]]) feed('b') screen:expect([[ - {2:<<<}{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | - {1: 12 } | - {1: 13 } | - {1: 14 }{4:bb}{3:bb} | - {1: 15 } | - {1: 16 } | - {1: 17 } | + {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | + {8: 12 } | + {8: 13 } | + {8: 14 }{2:bb}{10:bb} | + {8: 15 } | + {8: 16 } | + {8: 17 } | /bb^ | ]]) feed('b') screen:expect([[ - {2:<<<}{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | - {1: 12 } | - {1: 13 } | - {1: 14 }{4:bbb}b | - {1: 15 } | - {1: 16 } | - {1: 17 } | + {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | + {8: 12 } | + {8: 13 } | + {8: 14 }{2:bbb}b | + {8: 15 } | + {8: 16 } | + {8: 17 } | /bbb^ | ]]) feed('b') screen:expect([[ - {2:<<<}{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | - {1: 12 } | - {1: 13 } | - {1: 14 }{4:bbbb} | - {1: 15 } | - {1: 16 } | - {1: 17 } | + {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa | + {8: 12 } | + {8: 13 } | + {8: 14 }{2:bbbb} | + {8: 15 } | + {8: 16 } | + {8: 17 } | /bbbb^ | ]]) end) @@ -815,10 +809,6 @@ describe('smoothscroll', function() -- oldtest: Test_smoothscroll_multi_skipcol() it('scrolling multiple lines and stopping at non-zero skipcol', function() screen:try_resize(40, 10) - screen:set_default_attr_ids({ - [0] = { foreground = Screen.colors.Blue, bold = true }, - [1] = { background = Screen.colors.Grey90 }, - }) exec([[ setlocal cursorline scrolloff=0 smoothscroll call setline(1, repeat([''], 8)) @@ -829,7 +819,7 @@ describe('smoothscroll', function() redraw ]]) screen:expect([[ - {1:^ }| + {21:^ }| | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| aaaaaaaaaa | @@ -841,22 +831,22 @@ describe('smoothscroll', function() ]]) feed('3<C-E>') screen:expect([[ - {0:<<<}{1:aaaaaa^a }| + {1:<<<}{21:aaaaaa^a }| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| aaaaaaaaaa | |*2 bbb | ccc | - {0:~ }|*2 + {1:~ }|*2 | ]]) feed('2<C-E>') screen:expect([[ - {0:<<<}{1:aaaaaa^a }| + {1:<<<}{21:aaaaaa^a }| |*2 bbb | ccc | - {0:~ }|*4 + {1:~ }|*4 | ]]) end) @@ -864,12 +854,6 @@ describe('smoothscroll', function() -- oldtest: Test_smoothscroll_zero_width_scroll_cursor_bot() it('does not divide by zero in zero-width window', function() screen:try_resize(40, 19) - screen:set_default_attr_ids({ - [1] = { foreground = Screen.colors.Brown }, -- LineNr - [2] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [3] = { bold = true, reverse = true }, -- StatusLine - [4] = { reverse = true }, -- StatusLineNC - }) exec([[ silent normal yy silent normal 19p @@ -882,10 +866,10 @@ describe('smoothscroll', function() silent normal 20G ]]) screen:expect([[ - {1: }│ | - {2:@}│ |*15 - {2:^@}│ | - {3:< }{4:[No Name] [+] }| + {8: }│ | + {1:@}│ |*15 + {1:^@}│ | + {3:< }{2:[No Name] [+] }| | ]]) end) @@ -901,15 +885,15 @@ describe('smoothscroll', function() ]]) screen:expect([[ | - [No Name] | + {2:[No Name] }| line1 | line2 | ^line3line3line3line3line3line3line3line3| line3line3line3line3line3line3line3line3| line3line3line3line3 | line4 | - ~ |*2 - [No Name] [+] | + {1:~ }|*2 + {3:[No Name] [+] }| | ]]) end) @@ -929,6 +913,119 @@ describe('smoothscroll', function() assert_alive() end) + -- oldtest: Test_smoothscroll_insert_bottom() + it('works in Insert mode at bottom of window', function() + screen:try_resize(40, 9) + exec([[ + call setline(1, repeat([repeat('A very long line ...', 10)], 5)) + set wrap smoothscroll scrolloff=0 + ]]) + feed('Go123456789<CR>') + screen:expect([[ + {1:<<<}ery long line ...A very long line ...| + A very long line ...A very long line ...|*5 + 123456789 | + ^ | + {5:-- INSERT --} | + ]]) + end) + + -- oldtest: Test_smoothscroll_in_qf_window() + it('works in quickfix window when changing quickfix list', function() + screen:try_resize(60, 20) + exec([[ + set nocompatible display=lastline + copen 5 + setlocal number smoothscroll + let g:l = [{'text': 'foo'}] + repeat([{'text': join(range(30))}], 10) + call setqflist(g:l, 'r') + normal! G + wincmd t + let g:l1 = [{'text': join(range(1000))}] + ]]) + screen:expect([[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {1:<<<}{8: }21 22 23 24 25 26 27 28 29 | + {8: 10 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {8: 11 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {2:[Quickfix List] }| + | + ]]) + + feed([[:call setqflist([], 'r')<CR>]]) + local screen_empty = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {8: 1 } | + {1:~ }|*4 + {2:[Quickfix List] }| + :call setqflist([], 'r') | + ]] + screen:expect(screen_empty) + + feed([[:call setqflist(g:l, 'r')<CR>]]) + local screen_l_top = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {8: 1 }{10:|| foo }| + {8: 2 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {8: 3 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + {8: }21 22 23 24 25 26 27 28 29 | + {2:[Quickfix List] }| + :call setqflist(g:l, 'r') | + ]] + screen:expect(screen_l_top) + + feed([[:call setqflist(g:l1, 'r')<CR>]]) + local screen_l1_top = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {8: 1 }{10:|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 }| + {8: }{10:21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39}| + {8: }{10: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 5}| + {8: }{10:8 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 }| + {8: }{10:77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95}| + {2:[Quickfix List] }| + :call setqflist(g:l1, 'r') | + ]] + screen:expect(screen_l1_top) + + feed('<C-W>b$<C-W>t') + local screen_l1_bot = [[ + ^ | + {1:~ }|*11 + {3:[No Name] }| + {1:<<<}{8: }{10: 937 938 939 940 941 942 943 944 945 946 947 948 949 950}| + {8: }{10: 951 952 953 954 955 956 957 958 959 960 961 962 963 964}| + {8: }{10: 965 966 967 968 969 970 971 972 973 974 975 976 977 978}| + {8: }{10: 979 980 981 982 983 984 985 986 987 988 989 990 991 992}| + {8: }{10: 993 994 995 996 997 998 999 }| + {2:[Quickfix List] }| + :call setqflist(g:l1, 'r') | + ]] + screen:expect(screen_l1_bot) + + feed([[:call setqflist([], 'r')<CR>]]) + screen:expect(screen_empty) + + feed([[:call setqflist(g:l1, 'r')<CR>]]) + screen:expect(screen_l1_top) + + feed('<C-W>b$<C-W>t') + screen:expect(screen_l1_bot) + + feed([[:call setqflist(g:l, 'r')<CR>]]) + screen:expect(screen_l_top) + end) + it('works with virt_lines above and below', function() screen:try_resize(55, 7) exec([=[ @@ -952,7 +1049,7 @@ describe('smoothscroll', function() ]]) feed('<C-E>') screen:expect([[ - <<<e text with some text with some text with some text | + {1:<<<}e text with some text with some text with some text | virt_below1 | virt_above1 | ^Line with some text with some text with some text with | @@ -977,7 +1074,7 @@ describe('smoothscroll', function() some text with some text with some text with some text | virt_below2 | virt_above2 | - Line with some text with some text with some text wi@@@| + Line with some text with some text with some text wi{1:@@@}| | ]]) feed('<C-E>') @@ -992,124 +1089,199 @@ describe('smoothscroll', function() ]]) feed('<C-E>') screen:expect([[ - <<<e text with some text with some text with some tex^t | + {1:<<<}e text with some text with some text with some tex^t | virt_below2 | virt_above2 | Line with some text with some text with some text with | some text with some text with some text with some text | - ~ | + {1:~ }| | ]]) end) - it('works in Insert mode at bottom of window', function() - screen:try_resize(40, 9) - exec([[ - call setline(1, repeat([repeat('A very long line ...', 10)], 5)) - set wrap smoothscroll scrolloff=0 - ]]) - feed('Go123456789<CR>') - screen:expect([[ - <<<ery long line ...A very long line ...| - A very long line ...A very long line ...|*5 - 123456789 | - ^ | - -- INSERT -- | - ]]) - end) - it('<<< marker shows with tabline, winbar and splits', function() screen:try_resize(40, 12) + screen:set_default_attr_ids({ + [1] = { foreground = Screen.colors.Blue1, bold = true }, + [2] = { reverse = true }, + [3] = { bold = true, reverse = true }, + [4] = { background = Screen.colors.LightMagenta }, + [5] = { bold = true }, + [31] = { foreground = Screen.colors.Fuchsia, bold = true }, + }) exec([[ call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7)) set smoothscroll scrolloff=0 norm sj ]]) screen:expect([[ - <<<e text with some text with some text | + {1:<<<}e text with some text with some text | with some text with some text | Line with some text with some text with | some text with some text with some text | with some text with some text | - [No Name] [+] | - <<<e text with some text with some text | + {2:[No Name] [+] }| + {1:<<<}e text with some text with some text | ^with some text with some text | Line with some text with some text with | - some text with some text with some te@@@| - [No Name] [+] | + some text with some text with some te{1:@@@}| + {3:[No Name] [+] }| | ]]) exec('set showtabline=2') feed('<C-E>') screen:expect([[ - 2+ [No Name] | - <<<e text with some text with some text | + {5: }{31:2}{5:+ [No Name] }{2: }| + {1:<<<}e text with some text with some text | with some text with some text | Line with some text with some text with | some text with some text with some text | with some text with some text | - [No Name] [+] | - <<<e text with some text with some text | + {2:[No Name] [+] }| + {1:<<<}e text with some text with some text | ^with some text with some text | - Line with some text with some text wi@@@| - [No Name] [+] | + Line with some text with some text wi{1:@@@}| + {3:[No Name] [+] }| | ]]) exec('set winbar=winbar') feed('<C-w>k<C-E>') screen:expect([[ - 2+ [No Name] | - winbar | - <<<e text with some text with some text | + {5: }{31:2}{5:+ [No Name] }{2: }| + {5:winbar }| + {1:<<<}e text with some text with some text | ^with some text with some text | Line with some text with some text with | - some text with some text with some te@@@| - [No Name] [+] | - winbar | - <<<e text with some text with some text | + some text with some text with some te{1:@@@}| + {3:[No Name] [+] }| + {5:winbar }| + {1:<<<}e text with some text with some text | with some text with some text | - [No Name] [+] | + {2:[No Name] [+] }| | ]]) end) it('works with very long line', function() - screen:set_default_attr_ids({ - [1] = { foreground = Screen.colors.Brown }, - [2] = { foreground = Screen.colors.Blue1, bold = true }, - }) exec([[ edit test/functional/fixtures/bigfile_oneline.txt setlocal smoothscroll number ]]) screen:expect([[ - {1: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;| - {1: }; 0001;<control>;Cc;0;BN;;;;;N;START| - {1: } OF HEADING;;;; 0002;<control>;Cc;0;| - {1: }BN;;;;;N;START OF TEXT;;;; 0003;<con| - {1: }trol>;Cc;0;BN;;;;;N;END OF TEXT;;;; | - {1: }0004;<control>;Cc;0;BN;;;;;N;END OF | - {1: }TRANSMISSION;;;; 0005;<control>;Cc;0| - {1: };BN;;;;;N;ENQUIRY;;;; 0006;<control>| - {1: };Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; 0007;| - {1: }<control>;Cc;0;BN;;;;;N;BELL;;;; 000| - {1: }8;<control>;Cc;0;BN;;;;;N;BACKSPACE;| + {8: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;| + {8: }; 0001;<control>;Cc;0;BN;;;;;N;START| + {8: } OF HEADING;;;; 0002;<control>;Cc;0;| + {8: }BN;;;;;N;START OF TEXT;;;; 0003;<con| + {8: }trol>;Cc;0;BN;;;;;N;END OF TEXT;;;; | + {8: }0004;<control>;Cc;0;BN;;;;;N;END OF | + {8: }TRANSMISSION;;;; 0005;<control>;Cc;0| + {8: };BN;;;;;N;ENQUIRY;;;; 0006;<control>| + {8: };Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; 0007;| + {8: }<control>;Cc;0;BN;;;;;N;BELL;;;; 000| + {8: }8;<control>;Cc;0;BN;;;;;N;BACKSPACE;| | ]]) feed('j') screen:expect([[ - {2:<<<}{1: }CJK COMPATIBILITY IDEOGRAPH-2F91F;Lo| - {1: };0;L;243AB;;;;N;;;;; 2F920;CJK COMPA| - {1: }TIBILITY IDEOGRAPH-2F920;Lo;0;L;7228| - {1: };;;;N;;;;; 2F921;CJK COMPATIBILITY I| - {1: }DEOGRAPH-2F921;Lo;0;L;7235;;;;N;;;;;| - {1: } 2F922;CJK COMPATIBILITY IDEOGRAPH-2| - {1: }F922;Lo;0;L;7250;;;;N;;;;; | - {1: 2 }^2F923;CJK COMPATIBILITY IDEOGRAPH-2F| - {1: }923;Lo;0;L;24608;;;;N;;;;; | - {1: 3 }2F924;CJK COMPATIBILITY IDEOGRAPH-2F| - {1: }924;Lo;0;L;7280;;;;N;;;;; | + {1:<<<}{8: }CJK COMPATIBILITY IDEOGRAPH-2F91F;Lo| + {8: };0;L;243AB;;;;N;;;;; 2F920;CJK COMPA| + {8: }TIBILITY IDEOGRAPH-2F920;Lo;0;L;7228| + {8: };;;;N;;;;; 2F921;CJK COMPATIBILITY I| + {8: }DEOGRAPH-2F921;Lo;0;L;7235;;;;N;;;;;| + {8: } 2F922;CJK COMPATIBILITY IDEOGRAPH-2| + {8: }F922;Lo;0;L;7250;;;;N;;;;; | + {8: 2 }^2F923;CJK COMPATIBILITY IDEOGRAPH-2F| + {8: }923;Lo;0;L;24608;;;;N;;;;; | + {8: 3 }2F924;CJK COMPATIBILITY IDEOGRAPH-2F| + {8: }924;Lo;0;L;7280;;;;N;;;;; | | ]]) end) + + it('works with very long line and scrolloff', function() + screen:try_resize(40, 8) + exec([[ + set smoothscroll scrolloff=3 + call setline(1, ['one', 'two long '->repeat(100), 'three', 'four', 'five', 'six']) + ]]) + --FIXME: incorrect screen due to reset_skipcol()/curs_columns() shenanigans + feed(':norm j721|<CR>') + screen:expect([[ + two long two long two long two long two | + long two long two long two long two long| + two long two long two long two long two| + ^ long two long two long two long two lon| + g two long two long two long two long tw| + o long two long two long two long two lo| + ng two long two long two long two long t| + :norm j721| | + ]]) + feed('gj') + screen:expect([[ + {1:<<<}two long two long two long two long t| + wo long two long two long two long two l| + ong two long two long two long two long | + two long two long two long two long two | + ^long two long two long two long two long| + two long two long two long two long two| + long two long two long two long two lon| + :norm j721| | + ]]) + feed('gj') + screen:expect([[ + {1:<<<}long two long two long two long two l| + ong two long two long two long two long | + two long two long two long two long two | + long two long two long two long two long| + ^ two long two long two long two long two| + long two long two long two long two lon| + g two long two long | + :norm j721| | + ]]) + feed('gj') + screen:expect([[ + {1:<<<}long two long two long two long two l| + ong two long two long two long two long | + two long two long two long two long two | + long two long two long two long two long| + two long two long two long two long two| + ^ long two long two long two long two lon| + g two long two long | + :norm j721| | + ]]) + feed('gj') + screen:expect([[ + {1:<<<}long two long two long two long two l| + ong two long two long two long two long | + two long two long two long two long two | + long two long two long two long two long| + two long two long two long two long two| + long two long two long two long two lon| + ^g two long two long | + :norm j721| | + ]]) + feed('gj') + screen:expect([[ + {1:<<<} long two long two long two long two | + long two long two long two long two long| + two long two long two long two long two| + long two long two long two long two lon| + g two long two long | + ^three | + four | + :norm j721| | + ]]) + feed('gk') + --FIXME: incorrect screen due to reset_skipcol()/curs_columns() shenanigans + screen:expect([[ + two long two long two long two long two | + long two long two long two long two long| + two long two long two long two long two| + long two long two long two long two lon| + g two long two long two long two long tw| + o long two long two long two long two lo| + ^ng two long two long two long two long t| + :norm j721| | + ]]) + end) end) diff --git a/test/functional/legacy/search_mbyte_spec.lua b/test/functional/legacy/search_mbyte_spec.lua index ef7e41aa30..6457567176 100644 --- a/test/functional/legacy/search_mbyte_spec.lua +++ b/test/functional/legacy/search_mbyte_spec.lua @@ -1,10 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() -local poke_eventloop = helpers.poke_eventloop -local clear = helpers.clear -local insert = helpers.insert -local expect = helpers.expect -local command = helpers.command +local poke_eventloop = n.poke_eventloop +local clear = n.clear +local insert = n.insert +local expect = n.expect +local command = n.command describe('search_mbyte', function() before_each(clear) diff --git a/test/functional/legacy/search_spec.lua b/test/functional/legacy/search_spec.lua index 2fda341123..d421a96579 100644 --- a/test/functional/legacy/search_spec.lua +++ b/test/functional/legacy/search_spec.lua @@ -1,13 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local eval = helpers.eval -local feed = helpers.feed -local fn = helpers.fn -local poke_eventloop = helpers.poke_eventloop -local exec = helpers.exec + +local clear = n.clear +local command = n.command +local eq = t.eq +local eval = n.eval +local feed = n.feed +local fn = n.fn +local poke_eventloop = n.poke_eventloop +local exec = n.exec describe('search cmdline', function() local screen @@ -745,11 +747,6 @@ describe('Search highlight', function() -- oldtest: Test_hlsearch_dump() it('beyond line end vim-patch:8.2.2542', function() local screen = Screen.new(50, 6) - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [2] = { background = Screen.colors.Yellow }, -- Search - [3] = { background = Screen.colors.Grey90 }, -- CursorLine - }) screen:attach() exec([[ set hlsearch noincsearch cursorline @@ -759,8 +756,8 @@ describe('Search highlight', function() ]]) feed([[/\_.*<CR>]]) screen:expect([[ - {2:xxx } |*2 - {2:^xxx }{3: }| + {10:xxx } |*2 + {10:^xxx }{21: }| {1:~ }|*2 /\_.* | ]]) diff --git a/test/functional/legacy/search_stat_spec.lua b/test/functional/legacy/search_stat_spec.lua index 378060d316..7779b8bef1 100644 --- a/test/functional/legacy/search_stat_spec.lua +++ b/test/functional/legacy/search_stat_spec.lua @@ -1,6 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, exec, command = helpers.clear, helpers.feed, helpers.exec, helpers.command + +local clear, feed, exec, command = n.clear, n.feed, n.exec, n.command describe('search stat', function() local screen diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua index 0e65edbcf8..614673ee3c 100644 --- a/test/functional/legacy/signs_spec.lua +++ b/test/functional/legacy/signs_spec.lua @@ -1,7 +1,8 @@ -- Tests for signs -local helpers = require('test.functional.helpers')(after_each) -local clear, command, expect = helpers.clear, helpers.command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, command, expect = n.clear, n.command, n.expect describe('signs', function() setup(clear) diff --git a/test/functional/legacy/source_spec.lua b/test/functional/legacy/source_spec.lua index 7a19541a77..a910dc3d43 100644 --- a/test/functional/legacy/source_spec.lua +++ b/test/functional/legacy/source_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local feed = helpers.feed -local write_file = helpers.write_file + +local clear = n.clear +local feed = n.feed +local write_file = t.write_file before_each(clear) @@ -16,16 +18,12 @@ describe(':source!', function() ]] ) local screen = Screen.new(75, 6) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - }) screen:attach() feed(':source! Xscript.vim\n') screen:expect([[ ^ | - {0:~ }|*4 - {1:E22: Scripts nested too deep} | + {1:~ }|*4 + {9:E22: Scripts nested too deep} | ]]) os.remove('Xscript.vim') end) diff --git a/test/functional/legacy/statusline_spec.lua b/test/functional/legacy/statusline_spec.lua index 567e829879..148166fdc3 100644 --- a/test/functional/legacy/statusline_spec.lua +++ b/test/functional/legacy/statusline_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed before_each(clear) @@ -15,11 +16,6 @@ describe('statusline', function() end) it('is updated in cmdline mode when using window-local statusline vim-patch:8.2.2737', function() - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [2] = { bold = true, reverse = true }, -- StatusLine - [3] = { reverse = true }, -- StatusLineNC - }) exec([[ setlocal statusline=-%{mode()}- split @@ -28,30 +24,25 @@ describe('statusline', function() screen:expect([[ ^ | {1:~ }| - {2:+n+ }| + {3:+n+ }| | {1:~ }| - {3:-n- }| + {2:-n- }| | ]]) feed(':') screen:expect([[ | {1:~ }| - {2:+c+ }| + {3:+c+ }| | {1:~ }| - {3:-c- }| + {2:-c- }| :^ | ]]) end) it('truncated item does not cause off-by-one highlight vim-patch:8.2.4929', function() - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [2] = { foreground = Screen.colors.Blue }, -- User1 - [3] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- User2 - }) exec([[ set laststatus=2 hi! link User1 Directory @@ -61,20 +52,13 @@ describe('statusline', function() screen:expect([[ ^ | {1:~ }|*4 - {3:<F}{2:GHI }| + {9:<F}{18:GHI }| | ]]) end) -- oldtest: Test_statusline_showcmd() it('showcmdloc=statusline works', function() - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - [2] = { bold = true }, -- MoreMsg - [3] = { bold = true, reverse = true }, -- StatusLine - [5] = { background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue }, -- Folded - }) exec([[ func MyStatusLine() return '%S' @@ -92,9 +76,9 @@ describe('statusline', function() feed('g') screen:expect([[ - {5:+-- 2 lines: a···································}| + {13:+-- 2 lines: a···································}| ^c | - {0:~ }|*3 + {1:~ }|*3 {3:g }| | ]]) @@ -105,19 +89,19 @@ describe('statusline', function() ^a | b | c | - {0:~ }|*2 + {1:~ }|*2 {3: }| | ]]) feed('<C-V>Gl') screen:expect([[ - {1:a} | - {1:b} | - {1:c}^ | - {0:~ }|*2 + {17:a} | + {17:b} | + {17:c}^ | + {1:~ }|*2 {3:3x2 }| - {2:-- VISUAL BLOCK --} | + {5:-- VISUAL BLOCK --} | ]]) feed('<Esc>1234') @@ -125,7 +109,7 @@ describe('statusline', function() a | b | ^c | - {0:~ }|*2 + {1:~ }|*2 {3:1234 }| | ]]) @@ -137,7 +121,7 @@ describe('statusline', function() a | b | ^c | - {0:~ }|*2 + {1:~ }|*2 {3:[No Name] [+] 1234 }| : | ]]) diff --git a/test/functional/legacy/substitute_spec.lua b/test/functional/legacy/substitute_spec.lua index b462c10202..647d62782c 100644 --- a/test/functional/legacy/substitute_spec.lua +++ b/test/functional/legacy/substitute_spec.lua @@ -2,12 +2,14 @@ -- Test for submatch() on substitute(). -- Test for *:s%* on :substitute. -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, insert = helpers.feed, helpers.insert -local exec = helpers.exec -local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect -local eq, eval = helpers.eq, helpers.eval + +local feed, insert = n.feed, n.insert +local exec = n.exec +local clear, feed_command, expect = n.clear, n.feed_command, n.expect +local eq, eval = t.eq, n.eval describe('substitute()', function() before_each(clear) @@ -209,11 +211,6 @@ describe(':substitute', function() it('first char is highlighted with confirmation dialog and empty match', function() local screen = Screen.new(60, 8) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { reverse = true }, -- IncSearch - [2] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - }) screen:attach() exec([[ set nohlsearch noincsearch @@ -221,11 +218,11 @@ describe(':substitute', function() ]]) feed(':%s/^/ /c<CR>') screen:expect([[ - {1:o}ne | + {2:o}ne | two | three | - {0:~ }|*4 - {2:replace with (y/n/a/q/l/^E/^Y)?}^ | + {1:~ }|*4 + {6:replace with (y/n/a/q/l/^E/^Y)?}^ | ]]) end) end) diff --git a/test/functional/legacy/syn_attr_spec.lua b/test/functional/legacy/syn_attr_spec.lua index ec47bdf9af..155eb9ce11 100644 --- a/test/functional/legacy/syn_attr_spec.lua +++ b/test/functional/legacy/syn_attr_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local eval = helpers.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local eq = t.eq +local eval = n.eval -- oldtest: Test_missing_attr() describe('synIDattr()', function() diff --git a/test/functional/legacy/tabline_spec.lua b/test/functional/legacy/tabline_spec.lua index 683c7d9bd7..4ce32f2fdd 100644 --- a/test/functional/legacy/tabline_spec.lua +++ b/test/functional/legacy/tabline_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed + +local clear = n.clear +local exec = n.exec +local feed = n.feed before_each(clear) @@ -16,14 +17,6 @@ describe('tabline', function() -- oldtest: Test_tabline_showcmd() it('showcmdloc=tabline works', function() - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - [2] = { bold = true }, -- MoreMsg, TabLineSel - [3] = { reverse = true }, -- TabLineFill - [4] = { background = Screen.colors.LightGrey, underline = true }, -- TabLine - [5] = { background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue }, -- Folded - }) exec([[ func MyTabLine() return '%S' @@ -41,41 +34,41 @@ describe('tabline', function() feed('g') screen:expect([[ - {3:g }| - {5:+-- 2 lines: a···································}| + {2:g }| + {13:+-- 2 lines: a···································}| ^c | - {0:~ }|*3 + {1:~ }|*3 | ]]) -- typing "gg" should open the fold feed('g') screen:expect([[ - {3: }| + {2: }| ^a | b | c | - {0:~ }|*2 + {1:~ }|*2 | ]]) feed('<C-V>Gl') screen:expect([[ - {3:3x2 }| - {1:a} | - {1:b} | - {1:c}^ | - {0:~ }|*2 - {2:-- VISUAL BLOCK --} | + {2:3x2 }| + {17:a} | + {17:b} | + {17:c}^ | + {1:~ }|*2 + {5:-- VISUAL BLOCK --} | ]]) feed('<Esc>1234') screen:expect([[ - {3:1234 }| + {2:1234 }| a | b | ^c | - {0:~ }|*2 + {1:~ }|*2 | ]]) @@ -83,11 +76,11 @@ describe('tabline', function() feed(':<CR>') feed('1234') screen:expect([[ - {2: + [No Name] }{3: }{4:1234}{3: }| + {5: + [No Name] }{2: }{24:1234}{2: }| a | b | ^c | - {0:~ }|*2 + {1:~ }|*2 : | ]]) end) diff --git a/test/functional/legacy/tagcase_spec.lua b/test/functional/legacy/tagcase_spec.lua index f84fc673cf..e5bdd4658a 100644 --- a/test/functional/legacy/tagcase_spec.lua +++ b/test/functional/legacy/tagcase_spec.lua @@ -1,12 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local eval = helpers.eval -local exc_exec = helpers.exc_exec -local expect = helpers.expect -local insert = helpers.insert -local source = helpers.source -local write_file = helpers.write_file +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eq = t.eq +local eval = n.eval +local exc_exec = n.exc_exec +local expect = n.expect +local insert = n.insert +local source = n.source +local write_file = t.write_file describe("'tagcase' option", function() setup(function() diff --git a/test/functional/legacy/textobjects_spec.lua b/test/functional/legacy/textobjects_spec.lua index 96f655cc41..9ed8716bff 100644 --- a/test/functional/legacy/textobjects_spec.lua +++ b/test/functional/legacy/textobjects_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local call = helpers.call -local clear = helpers.clear -local command = helpers.command -local expect = helpers.expect -local source = helpers.source +local n = require('test.functional.testnvim')() + +local call = n.call +local clear = n.clear +local command = n.command +local expect = n.expect +local source = n.source describe('Text object', function() before_each(function() diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua index e8badc6864..8453921669 100644 --- a/test/functional/legacy/undolevels_spec.lua +++ b/test/functional/legacy/undolevels_spec.lua @@ -1,6 +1,8 @@ -local helpers = require('test.functional.helpers')(after_each) -local source, clear = helpers.source, helpers.clear -local eq, nvim = helpers.eq, helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local source, clear = n.source, n.clear +local eq, api = t.eq, n.api describe('undolevel', function() setup(clear) @@ -57,6 +59,6 @@ describe('undolevel', function() call Test_global_local_undolevels() ]]) - eq({}, nvim.nvim_get_vvar('errors')) + eq({}, api.nvim_get_vvar('errors')) end) end) diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua index 67a4bec4c5..cdb0c2ca58 100644 --- a/test/functional/legacy/utf8_spec.lua +++ b/test/functional/legacy/utf8_spec.lua @@ -1,11 +1,13 @@ -- Tests for Unicode manipulations -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local command, expect = helpers.command, helpers.expect -local eq, eval = helpers.eq, helpers.eval -local source = helpers.source -local poke_eventloop = helpers.poke_eventloop +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed, insert = n.clear, n.feed, n.insert +local command, expect = n.command, n.expect +local eq, eval = t.eq, n.eval +local source = n.source +local poke_eventloop = n.poke_eventloop describe('utf8', function() before_each(clear) diff --git a/test/functional/legacy/vimscript_spec.lua b/test/functional/legacy/vimscript_spec.lua index 8b0a920a3e..66054810a6 100644 --- a/test/functional/legacy/vimscript_spec.lua +++ b/test/functional/legacy/vimscript_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local feed = helpers.feed -local api = helpers.api + +local clear = n.clear +local exec = n.exec +local feed = n.feed +local api = n.api before_each(clear) diff --git a/test/functional/legacy/visual_spec.lua b/test/functional/legacy/visual_spec.lua index 151e5874e1..ab2213b2fc 100644 --- a/test/functional/legacy/visual_spec.lua +++ b/test/functional/legacy/visual_spec.lua @@ -1,9 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) - +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local feed = helpers.feed -local exec = helpers.exec + +local clear = n.clear +local feed = n.feed +local exec = n.exec before_each(clear) @@ -12,11 +12,6 @@ describe('Visual highlight', function() before_each(function() screen = Screen.new(50, 6) - screen:set_default_attr_ids({ - [0] = { foreground = Screen.colors.Blue, bold = true }, -- NonText - [1] = { bold = true }, -- ModeMsg - [2] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, -- Visual - }) screen:attach() end) @@ -30,20 +25,20 @@ describe('Visual highlight', function() feed('<C-V>gg$') screen:expect([[ - {2:aaaaaa}^ | - {2:bbbb } | - {2:cc } | - {0:~ }|*2 - {1:-- VISUAL BLOCK --} | + {17:aaaaaa}^ | + {17:bbbb } | + {17:cc } | + {1:~ }|*2 + {5:-- VISUAL BLOCK --} | ]]) feed('<Esc>gg<C-V>G$') screen:expect([[ - {2:aaaaaa } | - {2:bbbb } | - {2:cc}^ {2: } | - {0:~ }|*2 - {1:-- VISUAL BLOCK --} | + {17:aaaaaa } | + {17:bbbb } | + {17:cc}^ {17: } | + {1:~ }|*2 + {5:-- VISUAL BLOCK --} | ]]) end) @@ -57,9 +52,9 @@ describe('Visual highlight', function() screen:expect([[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^a| - {0:+}{2:aaaa}aaaaaa | - {0:~ }|*3 - {1:-- VISUAL --} | + {1:+}{17:aaaa}aaaaaa | + {1:~ }|*3 + {5:-- VISUAL --} | ]]) end) end) diff --git a/test/functional/legacy/window_cmd_spec.lua b/test/functional/legacy/window_cmd_spec.lua index 7fe4ec8eb6..332240d04a 100644 --- a/test/functional/legacy/window_cmd_spec.lua +++ b/test/functional/legacy/window_cmd_spec.lua @@ -1,18 +1,16 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local exec = helpers.exec -local exec_lua = helpers.exec_lua -local command = helpers.command -local feed = helpers.feed + +local clear = n.clear +local exec = n.exec +local exec_lua = n.exec_lua +local command = n.command +local feed = n.feed -- oldtest: Test_window_cmd_ls0_split_scrolling() it('scrolling with laststatus=0 and :botright split', function() clear('--cmd', 'set ruler') local screen = Screen.new(40, 10) - screen:set_default_attr_ids({ - [1] = { reverse = true }, -- StatusLineNC - }) screen:attach() exec([[ set laststatus=0 @@ -25,7 +23,7 @@ it('scrolling with laststatus=0 and :botright split', function() 98 | 99 | 100 | - {1:[No Name] [+] 100,1 Bot}| + {2:[No Name] [+] 100,1 Bot}| 97 | 98 | 99 | @@ -65,10 +63,10 @@ describe('splitkeep', function() 99 | ^100 | 101 | - [No Name] [+] | + {3:[No Name] [+] }| 5 | 6 | - [No Name] [+] | + {2:[No Name] [+] }| | ]]) @@ -77,10 +75,10 @@ describe('splitkeep', function() 100 | ^101 | 102 | - [No Name] [+] | + {3:[No Name] [+] }| 5 | 6 | - [No Name] [+] | + {2:[No Name] [+] }| | ]]) @@ -90,10 +88,10 @@ describe('splitkeep', function() 198 | 199 | ^200 | - [No Name] [+] | + {3:[No Name] [+] }| 5 | 6 | - [No Name] [+] | + {2:[No Name] [+] }| | ]]) end) @@ -135,13 +133,13 @@ describe('splitkeep', function() 3 | 4 | 5 | - [No Name] [+] | + {2:[No Name] [+] }| ^7 | 8 | 9 | 10 | 11 | - [No Name] [+] | + {3:[No Name] [+] }| | ]]) feed(':quit<CR>Ht') @@ -152,13 +150,13 @@ describe('splitkeep', function() 3 | 4 | 5 | - [No Name] [+] | + {3:[No Name] [+] }| 7 | 8 | 9 | 10 | 11 | - [No Name] [+] | + {2:[No Name] [+] }| :quit | ]]) feed(':set sb<CR>:quit<CR>Gj') @@ -168,14 +166,14 @@ describe('splitkeep', function() 3 | 4 | ^5 | - [No Name] [+] | + {3:[No Name] [+] }| 7 | 8 | 9 | 10 | 11 | 12 | - [No Name] [+] | + {2:[No Name] [+] }| :quit | ]]) feed(':quit<CR>Gt') @@ -185,14 +183,14 @@ describe('splitkeep', function() 3 | 4 | 5 | - [No Name] [+] | + {2:[No Name] [+] }| 7 | 8 | 9 | 10 | 11 | ^12 | - [No Name] [+] | + {3:[No Name] [+] }| :quit | ]]) end) @@ -213,70 +211,70 @@ describe('splitkeep', function() ]]) feed('L:wincmd s<CR>') screen:expect([[ - 1 +-- 7 lines: int FuncName() {···················| - 8 after fold | - 9 +-- 7 lines: int FuncName() {···················| - 16 after fold | - 17 +-- 7 lines: int FuncName() {···················| - 24 ^after fold | - [No Name] [+] | - 32 after fold | - 33 +-- 7 lines: int FuncName() {···················| - 40 after fold | - 41 +-- 7 lines: int FuncName() {···················| - 48 after fold | - [No Name] [+] | + {8: 1 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 8 }after fold | + {8: 9 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 16 }after fold | + {8: 17 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 24 }^after fold | + {3:[No Name] [+] }| + {8: 32 }after fold | + {8: 33 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 40 }after fold | + {8: 41 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 48 }after fold | + {2:[No Name] [+] }| :wincmd s | ]]) feed(':quit<CR>') screen:expect([[ - 1 +-- 7 lines: int FuncName() {···················| - 8 after fold | - 9 +-- 7 lines: int FuncName() {···················| - 16 after fold | - 17 +-- 7 lines: int FuncName() {···················| - 24 after fold | - 25 +-- 7 lines: int FuncName() {···················| - 32 after fold | - 33 +-- 7 lines: int FuncName() {···················| - 40 after fold | - 41 +-- 7 lines: int FuncName() {···················| - 48 after fold | - 49 ^+-- 7 lines: int FuncName() {···················| + {8: 1 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 8 }after fold | + {8: 9 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 16 }after fold | + {8: 17 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 24 }after fold | + {8: 25 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 32 }after fold | + {8: 33 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 40 }after fold | + {8: 41 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 48 }after fold | + {8: 49 }{13:^+-- 7 lines: int FuncName() {···················}| :quit | ]]) feed('H:below split<CR>') screen:expect([[ - 1 +-- 7 lines: int FuncName() {···················| - 8 after fold | - 9 +-- 7 lines: int FuncName() {···················| - 16 after fold | - 17 +-- 7 lines: int FuncName() {···················| - [No Name] [+] | - 25 ^+-- 7 lines: int FuncName() {···················| - 32 after fold | - 33 +-- 7 lines: int FuncName() {···················| - 40 after fold | - 41 +-- 7 lines: int FuncName() {···················| - 48 after fold | - [No Name] [+] | + {8: 1 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 8 }after fold | + {8: 9 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 16 }after fold | + {8: 17 }{13:+-- 7 lines: int FuncName() {···················}| + {2:[No Name] [+] }| + {8: 25 }{13:^+-- 7 lines: int FuncName() {···················}| + {8: 32 }after fold | + {8: 33 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 40 }after fold | + {8: 41 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 48 }after fold | + {3:[No Name] [+] }| :below split | ]]) feed(':wincmd k<CR>:quit<CR>') screen:expect([[ - 1 +-- 7 lines: int FuncName() {···················| - 8 after fold | - 9 +-- 7 lines: int FuncName() {···················| - 16 after fold | - 17 +-- 7 lines: int FuncName() {···················| - 24 after fold | - 25 ^+-- 7 lines: int FuncName() {···················| - 32 after fold | - 33 +-- 7 lines: int FuncName() {···················| - 40 after fold | - 41 +-- 7 lines: int FuncName() {···················| - 48 after fold | - 49 +-- 7 lines: int FuncName() {···················| + {8: 1 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 8 }after fold | + {8: 9 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 16 }after fold | + {8: 17 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 24 }after fold | + {8: 25 }{13:^+-- 7 lines: int FuncName() {···················}| + {8: 32 }after fold | + {8: 33 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 40 }after fold | + {8: 41 }{13:+-- 7 lines: int FuncName() {···················}| + {8: 48 }after fold | + {8: 49 }{13:+-- 7 lines: int FuncName() {···················}| :quit | ]]) end) @@ -296,13 +294,13 @@ describe('splitkeep', function() a | b | c | - ~ |*4 - [No Name] | + {1:~ }|*4 + {2:[No Name] }| ^a | b | c | - ~ | - [No Name] | + {1:~ }| + {3:[No Name] }| | ]]) end) @@ -317,16 +315,16 @@ describe('splitkeep', function() wincmd s ]]) screen:expect([[ - <<<e line with lots of text in one line | + {1:<<<}e line with lots of text in one line | with lots of text in one line with lots | of text in one line | - ~ | - [No Name] [+] | - <<<e line with lots of text in one line | + {1:~ }| + {2:[No Name] [+] }| + {1:<<<}e line with lots of text in one line | ^with lots of text in one line with lots | of text in one line | - ~ |*2 - [No Name] [+] | + {1:~ }|*2 + {3:[No Name] [+] }| | ]]) end) diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua index 82021dd98d..85f2a1623c 100644 --- a/test/functional/legacy/wordcount_spec.lua +++ b/test/functional/legacy/wordcount_spec.lua @@ -1,10 +1,12 @@ -- Test for wordcount() function -local helpers = require('test.functional.helpers')(after_each) -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, command = helpers.clear, helpers.command -local eq, eval = helpers.eq, helpers.eval -local poke_eventloop = helpers.poke_eventloop +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local feed, insert, source = n.feed, n.insert, n.source +local clear, command = n.clear, n.command +local eq, eval = t.eq, n.eval +local poke_eventloop = n.poke_eventloop describe('wordcount', function() before_each(clear) diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua index 4d54e07d6a..a5a2c3c682 100644 --- a/test/functional/legacy/writefile_spec.lua +++ b/test/functional/legacy/writefile_spec.lua @@ -1,7 +1,8 @@ -- Tests for writefile() -local helpers = require('test.functional.helpers')(after_each) -local clear, command, expect = helpers.clear, helpers.command, helpers.expect +local n = require('test.functional.testnvim')() + +local clear, command, expect = n.clear, n.command, n.expect describe('writefile', function() setup(clear) |