diff options
Diffstat (limited to 'test/functional/legacy')
49 files changed, 342 insertions, 72 deletions
diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua index 1857721563..39de3e8280 100644 --- a/test/functional/legacy/003_cindent_spec.lua +++ b/test/functional/legacy/003_cindent_spec.lua @@ -4,7 +4,7 @@ -- in the original test. These have been converted to "it" test cases here. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect -- Inserts text as usual, and additionally positions the cursor on line 1 and diff --git a/test/functional/legacy/009_bufleave_autocommand_spec.lua b/test/functional/legacy/009_bufleave_autocommand_spec.lua index 0fc1b5b657..8c18639c8f 100644 --- a/test/functional/legacy/009_bufleave_autocommand_spec.lua +++ b/test/functional/legacy/009_bufleave_autocommand_spec.lua @@ -1,7 +1,7 @@ -- Test for Bufleave autocommand that deletes the buffer we are about to edit. local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear, insert = helpers.clear, helpers.insert local execute, expect = helpers.execute, helpers.expect describe('BufLeave autocommand', function() diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua index e71f9d1c90..3b19f4ff42 100644 --- a/test/functional/legacy/015_alignment_spec.lua +++ b/test/functional/legacy/015_alignment_spec.lua @@ -3,7 +3,7 @@ -- Also test undo after ":%s" and formatting. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('alignment', function() diff --git a/test/functional/legacy/022_line_ending_spec.lua b/test/functional/legacy/022_line_ending_spec.lua index 4b897a7c95..a841378a82 100644 --- a/test/functional/legacy/022_line_ending_spec.lua +++ b/test/functional/legacy/022_line_ending_spec.lua @@ -1,7 +1,7 @@ -- Tests for file with some lines ending in CTRL-M, some not local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear, feed = helpers.clear, helpers.feed local execute, expect = helpers.execute, helpers.expect describe('line ending', function() diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua index e68af9758d..15b30bfa3a 100644 --- a/test/functional/legacy/023_edit_arguments_spec.lua +++ b/test/functional/legacy/023_edit_arguments_spec.lua @@ -1,7 +1,7 @@ -- Tests for complicated + argument to :edit command local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear, insert = helpers.clear, helpers.insert local execute, expect = helpers.execute, helpers.expect describe(':edit', function() diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua index ffe37819de..f17bb79702 100644 --- a/test/functional/legacy/026_execute_while_if_spec.lua +++ b/test/functional/legacy/026_execute_while_if_spec.lua @@ -1,7 +1,7 @@ -- Test for :execute, :while and :if local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear = helpers.clear local execute, expect = helpers.execute, helpers.expect local source = helpers.source diff --git a/test/functional/legacy/027_expand_file_names_spec.lua b/test/functional/legacy/027_expand_file_names_spec.lua index d31f29d38a..4778d16d43 100644 --- a/test/functional/legacy/027_expand_file_names_spec.lua +++ b/test/functional/legacy/027_expand_file_names_spec.lua @@ -1,10 +1,10 @@ -- Test for expanding file names local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local clear, feed = helpers.clear, helpers.feed +local execute = helpers.execute local curbuf_contents = helpers.curbuf_contents -local eq, eval = helpers.eq, helpers.eval +local eq = helpers.eq describe('expand file name', function() setup(clear) diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua index eafa50d88c..25a072ad6e 100644 --- a/test/functional/legacy/029_join_spec.lua +++ b/test/functional/legacy/029_join_spec.lua @@ -1,7 +1,7 @@ -- Test for joining lines with marks in them (and with 'joinspaces' set/reset) local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('joining lines', function() diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua index 78e71b5fb1..3597cba12a 100644 --- a/test/functional/legacy/031_close_commands_spec.lua +++ b/test/functional/legacy/031_close_commands_spec.lua @@ -10,7 +10,7 @@ -- :edit local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('Commands that close windows and/or buffers', function() diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua index 94503bd42a..10d42f0cea 100644 --- a/test/functional/legacy/038_virtual_replace_spec.lua +++ b/test/functional/legacy/038_virtual_replace_spec.lua @@ -1,7 +1,7 @@ -- Test Virtual replace mode. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed = helpers.feed local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('Virtual replace mode', function() 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 efe61aa354..1359b45228 100644 --- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua +++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua @@ -4,7 +4,7 @@ -- This test contains both "test44" and "test99" from the old test suite. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect -- Runs the test protocol with the given 'regexpengine' setting. In the old test diff --git a/test/functional/legacy/046_multi_line_regexps_spec.lua b/test/functional/legacy/046_multi_line_regexps_spec.lua index f8a6143b18..b17ab42fe3 100644 --- a/test/functional/legacy/046_multi_line_regexps_spec.lua +++ b/test/functional/legacy/046_multi_line_regexps_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local expect = helpers.expect describe('multi-line regexp', function() setup(clear) diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua index 620df97aac..94c42b73e5 100644 --- a/test/functional/legacy/051_highlight_spec.lua +++ b/test/functional/legacy/051_highlight_spec.lua @@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear, feed = helpers.clear, helpers.feed local execute, expect = helpers.execute, helpers.expect local wait = helpers.wait diff --git a/test/functional/legacy/056_script_local_function_spec.lua b/test/functional/legacy/056_script_local_function_spec.lua index 147391ceb1..dec88e8001 100644 --- a/test/functional/legacy/056_script_local_function_spec.lua +++ b/test/functional/legacy/056_script_local_function_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local expect = helpers.expect describe('source function', function() setup(clear) 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 e9b79b490d..7f44b35a4e 100644 --- a/test/functional/legacy/060_exists_and_has_functions_spec.lua +++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua @@ -1,8 +1,8 @@ -- Tests for the exists() and has() functions. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local source = helpers.source +local clear, expect = helpers.clear, helpers.expect local write_file = helpers.write_file describe('exists() and has() functions', function() diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua index 8cc2a371bb..ceb114b2a7 100644 --- a/test/functional/legacy/061_undo_tree_spec.lua +++ b/test/functional/legacy/061_undo_tree_spec.lua @@ -1,8 +1,8 @@ -- Tests for undo tree and :earlier and :later. local helpers = require('test.functional.helpers') -local feed, insert, source, eq, eval, clear, execute, expect, wait, write_file - = helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval, +local feed, source, eq, eval, clear, execute, expect, wait, write_file = + helpers.feed, helpers.source, helpers.eq, helpers.eval, helpers.clear, helpers.execute, helpers.expect, helpers.wait, helpers.write_file @@ -97,9 +97,8 @@ describe('undo tree:', function() -- Retry up to 3 times. pcall() is _not_ used for the final attempt, so -- that failure messages can bubble up. - local success, result = false, '' - for i = 1, 2 do - success, result = pcall(test_earlier_later) + for _ = 1, 2 do + local success = pcall(test_earlier_later) if success then return end diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua index d819db7812..a354d4d328 100644 --- a/test/functional/legacy/063_match_and_matchadd_spec.lua +++ b/test/functional/legacy/063_match_and_matchadd_spec.lua @@ -2,10 +2,9 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local eval, clear, execute, expect = helpers.eval, helpers.clear, helpers.execute -local expect, eq, neq = helpers.expect, helpers.eq, helpers.neq -local command = helpers.command +local feed, insert = helpers.feed, helpers.insert +local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute +local eq, neq = helpers.eq, helpers.neq describe('063: Test for ":match", "matchadd()" and related functions', function() setup(clear) @@ -86,7 +85,7 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( execute("2match MyGroup2 /HUMPPA/") execute("3match MyGroup3 /VIM/") execute("let ml = getmatches()") - ml = eval("ml") + local ml = eval("ml") execute("call clearmatches()") execute("call setmatches(ml)") eq(ml, eval('getmatches()')) 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 5cdb0b7f58..e78b230956 100644 --- a/test/functional/legacy/065_float_and_logic_operators_spec.lua +++ b/test/functional/legacy/065_float_and_logic_operators_spec.lua @@ -1,7 +1,7 @@ -- Test for floating point and logical operators. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local insert, source = helpers.insert, helpers.source local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('floating point and logical operators', function() diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua index 6d89ad6d55..dc4c9c7eeb 100644 --- a/test/functional/legacy/067_augroup_exists_spec.lua +++ b/test/functional/legacy/067_augroup_exists_spec.lua @@ -2,7 +2,7 @@ -- autocommands. local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear = helpers.clear local execute, expect = helpers.execute, helpers.expect describe('augroup when calling exists()', function() diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua index ce9129ff43..efcc2f2cc3 100644 --- a/test/functional/legacy/072_undo_file_spec.lua +++ b/test/functional/legacy/072_undo_file_spec.lua @@ -3,7 +3,7 @@ -- undo-able pieces. Do that by setting 'undolevels'. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('72', function() 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 2428b7f74d..49c4827613 100644 --- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua +++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua @@ -13,7 +13,7 @@ describe('storing global variables in ShaDa files', function() end) it('is working', function() - local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE', + local nvim2 = spawn({helpers.nvim_prog, '-u', 'NONE', '-i', 'Xviminfo', '--embed'}) helpers.set_session(nvim2) diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua index 418abb14d4..82965f5cb2 100644 --- a/test/functional/legacy/075_maparg_spec.lua +++ b/test/functional/legacy/075_maparg_spec.lua @@ -2,7 +2,7 @@ -- Also test utf8 map with a 0x80 byte. local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear, feed = helpers.clear, helpers.feed local execute, expect = helpers.execute, helpers.expect describe('maparg()', function() diff --git a/test/functional/legacy/077_mf_hash_grow_spec.lua b/test/functional/legacy/077_mf_hash_grow_spec.lua index 825f08e968..029fe98fe9 100644 --- a/test/functional/legacy/077_mf_hash_grow_spec.lua +++ b/test/functional/legacy/077_mf_hash_grow_spec.lua @@ -7,7 +7,7 @@ -- If it isn't available then the test will be skipped. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed = helpers.feed local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('mf_hash_grow()', function() diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua index 33115c1317..e48fddaac1 100644 --- a/test/functional/legacy/078_swapfile_recover_spec.lua +++ b/test/functional/legacy/078_swapfile_recover_spec.lua @@ -4,9 +4,7 @@ -- pointer blocks. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source -local eval = helpers.eval +local clear, expect, source = helpers.clear, helpers.expect, helpers.source describe('78', function() setup(clear) diff --git a/test/functional/legacy/080_substitute_spec.lua b/test/functional/legacy/080_substitute_spec.lua index 89ef7a713c..96082364e0 100644 --- a/test/functional/legacy/080_substitute_spec.lua +++ b/test/functional/legacy/080_substitute_spec.lua @@ -3,7 +3,7 @@ -- Test for *:s%* on :substitute. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect local eq, eval = helpers.eq, helpers.eval diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua index 1615828ca0..933c6c8fa3 100644 --- a/test/functional/legacy/082_string_comparison_spec.lua +++ b/test/functional/legacy/082_string_comparison_spec.lua @@ -2,7 +2,7 @@ -- Also test "g~ap". local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, source = helpers.feed, helpers.source local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('case-insensitive string comparison in UTF-8', function() diff --git a/test/functional/legacy/084_curswant_spec.lua b/test/functional/legacy/084_curswant_spec.lua index 55df5d3e73..946dd5e501 100644 --- a/test/functional/legacy/084_curswant_spec.lua +++ b/test/functional/legacy/084_curswant_spec.lua @@ -1,8 +1,8 @@ -- Tests for curswant not changing when setting an option. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local insert, source = helpers.insert, helpers.source +local clear, expect = helpers.clear, helpers.expect describe('curswant', function() setup(clear) diff --git a/test/functional/legacy/089_number_relnumber_findfile_spec.lua b/test/functional/legacy/089_number_relnumber_findfile_spec.lua index 1f8e49cc81..f72ebf3f72 100644 --- a/test/functional/legacy/089_number_relnumber_findfile_spec.lua +++ b/test/functional/legacy/089_number_relnumber_findfile_spec.lua @@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers') local feed = helpers.feed -local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source +local clear, expect, source = helpers.clear, helpers.expect, helpers.source describe("setting 'number' and 'relativenumber'", function() setup(clear) diff --git a/test/functional/legacy/090_sha256_spec.lua b/test/functional/legacy/090_sha256_spec.lua index 35fbd5752e..95e50063a1 100644 --- a/test/functional/legacy/090_sha256_spec.lua +++ b/test/functional/legacy/090_sha256_spec.lua @@ -1,8 +1,8 @@ -- Tests for sha256() function. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local insert, source = helpers.insert, helpers.source +local clear, expect = helpers.clear, helpers.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 bb9c32b84f..ffeb0c657e 100644 --- a/test/functional/legacy/091_context_variables_spec.lua +++ b/test/functional/legacy/091_context_variables_spec.lua @@ -1,8 +1,8 @@ -- Tests for getbufvar(), getwinvar(), gettabvar() and gettabwinvar(). local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local insert, source = helpers.insert, helpers.source +local clear, expect = helpers.clear, helpers.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 e0cc39dc40..f76ba25d7a 100644 --- a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua +++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua @@ -4,7 +4,7 @@ -- Same as legacy test 93 but using UTF-8 file encoding. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('store cursor position in session file in UTF-8', function() 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 659e716721..bf3af1a827 100644 --- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua +++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua @@ -4,7 +4,7 @@ -- Same as legacy test 92 but using Latin-1 file encoding. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local feed, insert = helpers.feed, helpers.insert local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('store cursor position in session file in Latin-1', function() diff --git a/test/functional/legacy/095_regexp_multibyte_spec.lua b/test/functional/legacy/095_regexp_multibyte_spec.lua index 559222e2ff..a80a247612 100644 --- a/test/functional/legacy/095_regexp_multibyte_spec.lua +++ b/test/functional/legacy/095_regexp_multibyte_spec.lua @@ -4,8 +4,8 @@ -- actually tried. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local insert, source = helpers.insert, helpers.source +local clear, expect = helpers.clear, helpers.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 2ccfd3530d..6e2f22ea33 100644 --- a/test/functional/legacy/096_location_list_spec.lua +++ b/test/functional/legacy/096_location_list_spec.lua @@ -7,7 +7,7 @@ -- it belongs to. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local source = helpers.source local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('location list', function() diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua index 84f26478ac..5c467fbb20 100644 --- a/test/functional/legacy/097_glob_path_spec.lua +++ b/test/functional/legacy/097_glob_path_spec.lua @@ -3,7 +3,7 @@ -- characters. local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear = helpers.clear local execute, expect = helpers.execute, helpers.expect describe('glob() and globpath()', function() diff --git a/test/functional/legacy/098_scrollbind_spec.lua b/test/functional/legacy/098_scrollbind_spec.lua index 7b2059e38b..6850e373ab 100644 --- a/test/functional/legacy/098_scrollbind_spec.lua +++ b/test/functional/legacy/098_scrollbind_spec.lua @@ -1,8 +1,8 @@ -- Test for 'scrollbind' causing an unexpected scroll of one of the windows. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local source = helpers.source +local clear, expect = helpers.clear, helpers.expect describe('scrollbind', function() setup(clear) diff --git a/test/functional/legacy/100_undo_level_spec.lua b/test/functional/legacy/100_undo_level_spec.lua index 9143d9e540..3bf72341d6 100644 --- a/test/functional/legacy/100_undo_level_spec.lua +++ b/test/functional/legacy/100_undo_level_spec.lua @@ -1,8 +1,8 @@ -- Tests for 'undolevel' setting being global-local local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local source = helpers.source +local clear, expect = helpers.clear, helpers.expect describe('undolevel', function() setup(clear) diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua index 4b8b1cef50..335d275c2a 100644 --- a/test/functional/legacy/101_hlsearch_spec.lua +++ b/test/functional/legacy/101_hlsearch_spec.lua @@ -1,9 +1,8 @@ -- Test for v:hlsearch local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear, feed = helpers.clear, helpers.feed local execute, expect = helpers.execute, helpers.expect -local eval = helpers.eval 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 251ce68430..a3b0313d7a 100644 --- a/test/functional/legacy/102_fnameescape_spec.lua +++ b/test/functional/legacy/102_fnameescape_spec.lua @@ -1,7 +1,7 @@ -- Test if fnameescape is correct for special chars like! local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear = helpers.clear local execute, expect = helpers.execute, helpers.expect describe('fnameescape', function() diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua index 6b2f3bc1b6..c1407ef10a 100644 --- a/test/functional/legacy/103_visual_mode_reset_spec.lua +++ b/test/functional/legacy/103_visual_mode_reset_spec.lua @@ -1,8 +1,8 @@ -- Test for visual mode not being reset causing E315 error. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local feed, source = helpers.feed, helpers.source +local clear, expect = helpers.clear, helpers.expect describe('E315 error', function() setup(clear) diff --git a/test/functional/legacy/105_filename_modifiers_spec.lua b/test/functional/legacy/105_filename_modifiers_spec.lua index 3b417a88eb..3413667022 100644 --- a/test/functional/legacy/105_filename_modifiers_spec.lua +++ b/test/functional/legacy/105_filename_modifiers_spec.lua @@ -1,7 +1,7 @@ -- Test filename modifiers. local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear = helpers.clear local execute, expect = helpers.execute, helpers.expect describe('filename modifiers', function() diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua index 5b6037f928..5958f1aa7b 100644 --- a/test/functional/legacy/106_errorformat_spec.lua +++ b/test/functional/legacy/106_errorformat_spec.lua @@ -1,7 +1,7 @@ -- Tests for errorformat. local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear = helpers.clear local execute, expect = helpers.execute, helpers.expect describe('errorformat', function() 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 f6ea7e5a6c..7a6de3d748 100644 --- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua +++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua @@ -2,8 +2,8 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local insert = helpers.insert +local clear, execute = helpers.clear, helpers.execute describe('107', function() setup(clear) diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua new file mode 100644 index 0000000000..855e9c6271 --- /dev/null +++ b/test/functional/legacy/autocmd_option_spec.lua @@ -0,0 +1,277 @@ +local helpers = require('test.functional.helpers') +local nvim = helpers.meths +local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq +local curbuf, buf = helpers.curbuf, helpers.bufmeths +local source, execute = helpers.source, helpers.execute + +local function declare_hook_function() + source([[ + fu! AutoCommand(match, bufnr, winnr) + let l:acc = { + \ 'option' : a:match, + \ 'oldval' : v:option_old, + \ 'newval' : v:option_new, + \ 'scope' : v:option_type, + \ 'attr' : { + \ 'bufnr' : a:bufnr, + \ 'winnr' : a:winnr, + \ } + \ } + call add(g:ret, l:acc) + endfu + ]]) +end + +local function set_hook(pattern) + execute( + 'au OptionSet ' + .. pattern .. + ' :call AutoCommand(expand("<amatch>"), bufnr("%"), winnr())' + ) +end + +local function init_var() + execute('let g:ret = []') +end + +local function get_result() + local ret = nvim.get_var('ret') + init_var() + return ret +end + +local function expected_table(option, oldval, newval, scope, attr) + return { + option = option, + oldval = tostring(oldval), + newval = tostring(newval), + scope = scope, + attr = attr, + } +end + +local function expected_combination(...) + local args = {...} + local ret = get_result() + + if not (#args == #ret) then + local expecteds = {} + for _, v in pairs(args) do + table.insert(expecteds, expected_table(unpack(v))) + end + eq(expecteds, ret) + return + end + + for i, v in ipairs(args) do + local attr = v[5] + if not attr then + -- remove attr entries + ret[i].attr = nil + else + -- remove attr entries which are not required + for k in pairs(ret[i].attr) do + if not attr[k] then + ret[i].attr[k] = nil + end + end + end + eq(expected_table(unpack(v)), ret[i]) + end +end + +local function expected_empty() + eq({}, get_result()) +end + +local function make_buffer() + local old_buf = curbuf() + execute('new') + local new_buf = curbuf() + execute('wincmd p') -- move previous window + + neq(old_buf, new_buf) + eq(old_buf, curbuf()) + + return new_buf +end + +describe('au OptionSet', function() + describe('with any opton (*)', function() + + before_each(function() + clear() + declare_hook_function() + init_var() + set_hook('*') + end) + + it('should be called in setting number option', function() + execute('set nu') + expected_combination({'number', 0, 1, 'global'}) + + execute('setlocal nonu') + expected_combination({'number', 1, 0, 'local'}) + + execute('setglobal nonu') + expected_combination({'number', 1, 0, 'global'}) + end) + + it('should be called in setting autoindent option',function() + execute('setlocal ai') + expected_combination({'autoindent', 0, 1, 'local'}) + + execute('setglobal ai') + expected_combination({'autoindent', 0, 1, 'global'}) + + execute('set noai') + expected_combination({'autoindent', 1, 0, 'global'}) + end) + + it('should be called in inverting global autoindent option',function() + execute('set ai!') + expected_combination({'autoindent', 0, 1, 'global'}) + end) + + it('should be called in being unset local autoindent option',function() + execute('setlocal ai') + expected_combination({'autoindent', 0, 1, 'local'}) + + execute('setlocal ai<') + expected_combination({'autoindent', 1, 0, 'local'}) + end) + + it('should be called in setting global list and number option at the same time',function() + execute('set list nu') + expected_combination( + {'list', 0, 1, 'global'}, + {'number', 0, 1, 'global'} + ) + end) + + it('should not print anything, use :noa', function() + execute('noa set nolist nonu') + expected_empty() + end) + + it('should be called in setting local acd', function() + execute('setlocal acd') + expected_combination({'autochdir', 0, 1, 'local'}) + end) + + it('should be called in setting autoread', function() + execute('set noar') + expected_combination({'autoread', 1, 0, 'global'}) + + execute('setlocal ar') + expected_combination({'autoread', 0, 1, 'local'}) + end) + + it('should be called in inverting global autoread', function() + execute('setglobal invar') + expected_combination({'autoread', 1, 0, 'global'}) + end) + + it('should be called in setting backspace option through :let', function() + execute('let &bs=""') + expected_combination({'backspace', 'indent,eol,start', '', 'global'}) + end) + + describe('being set by setbufvar()', function() + it('should not trigger because option name is invalid', function() + execute('call setbufvar(1, "&l:bk", 1)') + expected_empty() + end) + + it('should trigger using correct option name', function() + execute('call setbufvar(1, "&backup", 1)') + expected_combination({'backup', 0, 1, 'local'}) + end) + + it('should trigger if the current buffer is different from the targetted buffer', function() + local new_buffer = make_buffer() + local new_bufnr = buf.get_number(new_buffer) + + execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")') + expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}}) + end) + end) + end) + + describe('with specific option', function() + + before_each(function() + clear() + declare_hook_function() + init_var() + end) + + it('should be called iff setting readonly', function() + set_hook('readonly') + + execute('set nu') + expected_empty() + + execute('setlocal ro') + expected_combination({'readonly', 0, 1, 'local'}) + + execute('setglobal ro') + expected_combination({'readonly', 0, 1, 'global'}) + + execute('set noro') + expected_combination({'readonly', 1, 0, 'global'}) + end) + + describe('being set by setbufvar()', function() + it('should not trigger because option name does not match with backup', function() + set_hook('backup') + + execute('call setbufvar(1, "&l:bk", 1)') + expected_empty() + end) + + it('should trigger, use correct option name backup', function() + set_hook('backup') + + execute('call setbufvar(1, "&backup", 1)') + expected_combination({'backup', 0, 1, 'local'}) + end) + + it('should trigger if the current buffer is different from the targetted buffer', function() + set_hook('buftype') + + local new_buffer = make_buffer() + local new_bufnr = buf.get_number(new_buffer) + + execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")') + expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}}) + end) + end) + + describe('being set by neovim api', function() + it('should trigger if a boolean option be set globally', function() + set_hook('autochdir') + + nvim.set_option('autochdir', true) + eq(true, nvim.get_option('autochdir')) + expected_combination({'autochdir', '0', '1', 'global'}) + end) + + it('should trigger if a number option be set globally', function() + set_hook('cmdheight') + + nvim.set_option('cmdheight', 5) + eq(5, nvim.get_option('cmdheight')) + expected_combination({'cmdheight', 1, 5, 'global'}) + end) + + it('should trigger if a string option be set globally', function() + set_hook('ambiwidth') + + nvim.set_option('ambiwidth', 'double') + eq('double', nvim.get_option('ambiwidth')) + expected_combination({'ambiwidth', 'single', 'double', 'global'}) + end) + end) + end) +end) diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua index 15d12ac4af..69e7b87a21 100644 --- a/test/functional/legacy/listlbr_utf8_spec.lua +++ b/test/functional/legacy/listlbr_utf8_spec.lua @@ -1,8 +1,8 @@ -- Test for linebreak and list option in utf-8 mode local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local source = helpers.source +local clear, expect = helpers.clear, helpers.expect describe('linebreak', function() setup(clear) diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua index 87371c8294..fac3b03191 100644 --- a/test/functional/legacy/nested_function_spec.lua +++ b/test/functional/legacy/nested_function_spec.lua @@ -1,7 +1,7 @@ -- Tests for nested function. local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local clear, insert = helpers.clear, helpers.insert local execute, expect, source = helpers.execute, helpers.expect, helpers.source describe('test_nested_function', function() diff --git a/test/functional/legacy/qf_title_spec.lua b/test/functional/legacy/qf_title_spec.lua index aa005117be..01c781cc05 100644 --- a/test/functional/legacy/qf_title_spec.lua +++ b/test/functional/legacy/qf_title_spec.lua @@ -1,8 +1,8 @@ -- Tests for quickfix window's title local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local insert, source = helpers.insert, helpers.source +local clear, expect = helpers.clear, helpers.expect describe('qf_title', function() setup(clear) diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua index 89b2bf3b73..5a834c39e3 100644 --- a/test/functional/legacy/signs_spec.lua +++ b/test/functional/legacy/signs_spec.lua @@ -1,7 +1,6 @@ -- Tests for signs local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('signs', function() diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua index e7a260bcd9..efdfc1d09f 100644 --- a/test/functional/legacy/writefile_spec.lua +++ b/test/functional/legacy/writefile_spec.lua @@ -1,7 +1,6 @@ -- Tests for writefile() local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('writefile', function() |