aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy')
-rw-r--r--test/functional/legacy/002_filename_recognition_spec.lua2
-rw-r--r--test/functional/legacy/003_cindent_spec.lua2
-rw-r--r--test/functional/legacy/004_bufenter_with_modelines_spec.lua2
-rw-r--r--test/functional/legacy/005_bufleave_delete_buffer_spec.lua2
-rw-r--r--test/functional/legacy/006_argument_list_spec.lua2
-rw-r--r--test/functional/legacy/007_ball_buffer_list_spec.lua2
-rw-r--r--test/functional/legacy/009_bufleave_autocommand_spec.lua2
-rw-r--r--test/functional/legacy/011_autocommands_spec.lua5
-rw-r--r--test/functional/legacy/012_directory_spec.lua82
-rw-r--r--test/functional/legacy/015_alignment_spec.lua2
-rw-r--r--test/functional/legacy/018_unset_smart_indenting_spec.lua2
-rw-r--r--test/functional/legacy/019_smarttab_expandtab_spec.lua2
-rw-r--r--test/functional/legacy/020_blockwise_visual_spec.lua2
-rw-r--r--test/functional/legacy/021_control_wi_spec.lua2
-rw-r--r--test/functional/legacy/022_line_ending_spec.lua2
-rw-r--r--test/functional/legacy/023_edit_arguments_spec.lua2
-rw-r--r--test/functional/legacy/025_jump_tag_hidden_spec.lua4
-rw-r--r--test/functional/legacy/026_execute_while_if_spec.lua2
-rw-r--r--test/functional/legacy/027_expand_file_names_spec.lua37
-rw-r--r--test/functional/legacy/028_source_ctrl_v_spec.lua2
-rw-r--r--test/functional/legacy/029_join_spec.lua2
-rw-r--r--test/functional/legacy/030_fileformats_spec.lua377
-rw-r--r--test/functional/legacy/031_close_commands_spec.lua30
-rw-r--r--test/functional/legacy/033_lisp_indent_spec.lua2
-rw-r--r--test/functional/legacy/034_user_function_spec.lua102
-rw-r--r--test/functional/legacy/035_increment_and_decrement_spec.lua2
-rw-r--r--test/functional/legacy/036_regexp_character_classes_spec.lua25
-rw-r--r--test/functional/legacy/038_virtual_replace_spec.lua2
-rw-r--r--test/functional/legacy/039_visual_block_mode_commands_spec.lua2
-rw-r--r--test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua2
-rw-r--r--test/functional/legacy/043_magic_settings_spec.lua2
-rw-r--r--test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua14
-rw-r--r--test/functional/legacy/045_folding_spec.lua2
-rw-r--r--test/functional/legacy/046_multi_line_regexps_spec.lua2
-rw-r--r--test/functional/legacy/051_highlight_spec.lua4
-rw-r--r--test/functional/legacy/054_buffer_local_autocommands_spec.lua2
-rw-r--r--test/functional/legacy/055_list_and_dict_types_spec.lua922
-rw-r--r--test/functional/legacy/056_script_local_function_spec.lua2
-rw-r--r--test/functional/legacy/057_sort_spec.lua2
-rw-r--r--test/functional/legacy/059_utf8_spell_checking_spec.lua4
-rw-r--r--test/functional/legacy/060_exists_and_has_functions_spec.lua18
-rw-r--r--test/functional/legacy/061_undo_tree_spec.lua31
-rw-r--r--test/functional/legacy/062_tab_pages_spec.lua2
-rw-r--r--test/functional/legacy/063_match_and_matchadd_spec.lua2
-rw-r--r--test/functional/legacy/065_float_and_logic_operators_spec.lua2
-rw-r--r--test/functional/legacy/066_visual_block_tab_spec.lua2
-rw-r--r--test/functional/legacy/067_augroup_exists_spec.lua2
-rw-r--r--test/functional/legacy/068_text_formatting_spec.lua10
-rw-r--r--test/functional/legacy/072_undo_file_spec.lua2
-rw-r--r--test/functional/legacy/074_global_var_in_viminfo_spec.lua3
-rw-r--r--test/functional/legacy/075_maparg_spec.lua2
-rw-r--r--test/functional/legacy/076_completefunc_spec.lua68
-rw-r--r--test/functional/legacy/077_mf_hash_grow_spec.lua2
-rw-r--r--test/functional/legacy/078_swapfile_recover_spec.lua2
-rw-r--r--test/functional/legacy/080_substitute_spec.lua2
-rw-r--r--test/functional/legacy/081_coptions_movement_spec.lua2
-rw-r--r--test/functional/legacy/082_string_comparison_spec.lua2
-rw-r--r--test/functional/legacy/083_tag_search_with_file_encoding_spec.lua2
-rw-r--r--test/functional/legacy/084_curswant_spec.lua2
-rw-r--r--test/functional/legacy/088_conceal_tabs_spec.lua2
-rw-r--r--test/functional/legacy/089_number_relnumber_findfile_spec.lua2
-rw-r--r--test/functional/legacy/090_sha256_spec.lua2
-rw-r--r--test/functional/legacy/091_context_variables_spec.lua2
-rw-r--r--test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua2
-rw-r--r--test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua4
-rw-r--r--test/functional/legacy/094_visual_mode_operators_spec.lua2
-rw-r--r--test/functional/legacy/095_regexp_multibyte_spec.lua2
-rw-r--r--test/functional/legacy/096_location_list_spec.lua2
-rw-r--r--test/functional/legacy/097_glob_path_spec.lua4
-rw-r--r--test/functional/legacy/098_scrollbind_spec.lua2
-rw-r--r--test/functional/legacy/101_hlsearch_spec.lua4
-rw-r--r--test/functional/legacy/102_fnameescape_spec.lua2
-rw-r--r--test/functional/legacy/103_visual_mode_reset_spec.lua2
-rw-r--r--test/functional/legacy/104_let_assignment_spec.lua2
-rw-r--r--test/functional/legacy/106_errorformat_spec.lua2
-rw-r--r--test/functional/legacy/107_adjust_window_and_contents_spec.lua4
-rw-r--r--test/functional/legacy/108_backtrace_debug_commands_spec.lua2
-rw-r--r--test/functional/legacy/arglist_spec.lua270
-rw-r--r--test/functional/legacy/argument_0count_spec.lua28
-rw-r--r--test/functional/legacy/argument_count_spec.lua47
-rw-r--r--test/functional/legacy/assert_spec.lua124
-rw-r--r--test/functional/legacy/autochdir_spec.lua26
-rw-r--r--test/functional/legacy/autocmd_option_spec.lua2
-rw-r--r--test/functional/legacy/autoformat_join_spec.lua2
-rw-r--r--test/functional/legacy/backspace_opt_spec.lua2
-rw-r--r--test/functional/legacy/breakindent_spec.lua2
-rw-r--r--test/functional/legacy/cdo_spec.lua2
-rw-r--r--test/functional/legacy/changelist_spec.lua2
-rw-r--r--test/functional/legacy/charsearch_spec.lua2
-rw-r--r--test/functional/legacy/close_count_spec.lua2
-rw-r--r--test/functional/legacy/command_count_spec.lua22
-rw-r--r--test/functional/legacy/comparators_spec.lua2
-rw-r--r--test/functional/legacy/delete_spec.lua4
-rw-r--r--test/functional/legacy/erasebackword_spec.lua2
-rw-r--r--test/functional/legacy/eval_spec.lua20
-rw-r--r--test/functional/legacy/expand_spec.lua77
-rw-r--r--test/functional/legacy/file_perm_spec.lua6
-rw-r--r--test/functional/legacy/fixeol_spec.lua4
-rw-r--r--test/functional/legacy/fnamemodify_spec.lua4
-rw-r--r--test/functional/legacy/function_sort_spec.lua26
-rw-r--r--test/functional/legacy/getcwd_spec.lua88
-rw-r--r--test/functional/legacy/glob2regpat_spec.lua2
-rw-r--r--test/functional/legacy/increment_spec.lua15
-rw-r--r--test/functional/legacy/insertcount_spec.lua2
-rw-r--r--test/functional/legacy/join_spec.lua2
-rw-r--r--test/functional/legacy/lispwords_spec.lua2
-rw-r--r--test/functional/legacy/listchars_spec.lua2
-rw-r--r--test/functional/legacy/listlbr_spec.lua195
-rw-r--r--test/functional/legacy/listlbr_utf8_spec.lua2
-rw-r--r--test/functional/legacy/mapping_spec.lua2
-rw-r--r--test/functional/legacy/marks_spec.lua2
-rw-r--r--test/functional/legacy/match_conceal_spec.lua228
-rw-r--r--test/functional/legacy/nested_function_spec.lua2
-rw-r--r--test/functional/legacy/options_spec.lua2
-rw-r--r--test/functional/legacy/packadd_spec.lua356
-rw-r--r--test/functional/legacy/qf_title_spec.lua2
-rw-r--r--test/functional/legacy/quickfix_spec.lua17
-rw-r--r--test/functional/legacy/search_mbyte_spec.lua2
-rw-r--r--test/functional/legacy/searchpos_spec.lua2
-rw-r--r--test/functional/legacy/set_spec.lua2
-rw-r--r--test/functional/legacy/signs_spec.lua2
-rw-r--r--test/functional/legacy/tagcase_spec.lua2
-rw-r--r--test/functional/legacy/textobjects_spec.lua2
-rw-r--r--test/functional/legacy/undolevels_spec.lua8
-rw-r--r--test/functional/legacy/utf8_spec.lua2
-rw-r--r--test/functional/legacy/wordcount_spec.lua4
-rw-r--r--test/functional/legacy/writefile_spec.lua3
127 files changed, 2869 insertions, 623 deletions
diff --git a/test/functional/legacy/002_filename_recognition_spec.lua b/test/functional/legacy/002_filename_recognition_spec.lua
index 569e748631..5a833281e7 100644
--- a/test/functional/legacy/002_filename_recognition_spec.lua
+++ b/test/functional/legacy/002_filename_recognition_spec.lua
@@ -1,7 +1,7 @@
-- 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')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua
index 4b838eda1d..83388bd1eb 100644
--- a/test/functional/legacy/003_cindent_spec.lua
+++ b/test/functional/legacy/003_cindent_spec.lua
@@ -3,7 +3,7 @@
-- There are 50+ test command blocks (the stuff between STARTTEST and ENDTEST)
-- in the original test. These have been converted to "it" test cases here.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/004_bufenter_with_modelines_spec.lua b/test/functional/legacy/004_bufenter_with_modelines_spec.lua
index 34e702b798..3e5cdd2ff2 100644
--- a/test/functional/legacy/004_bufenter_with_modelines_spec.lua
+++ b/test/functional/legacy/004_bufenter_with_modelines_spec.lua
@@ -2,7 +2,7 @@
-- 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')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua
index e6989a6674..895f4ad181 100644
--- a/test/functional/legacy/005_bufleave_delete_buffer_spec.lua
+++ b/test/functional/legacy/005_bufleave_delete_buffer_spec.lua
@@ -1,7 +1,7 @@
-- 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')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/006_argument_list_spec.lua b/test/functional/legacy/006_argument_list_spec.lua
index 1266a876d4..764854314f 100644
--- a/test/functional/legacy/006_argument_list_spec.lua
+++ b/test/functional/legacy/006_argument_list_spec.lua
@@ -1,6 +1,6 @@
-- Test for autocommand that redefines the argument list, when doing ":all".
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, dedent, eq = helpers.execute, helpers.dedent, helpers.eq
local curbuf_contents = helpers.curbuf_contents
diff --git a/test/functional/legacy/007_ball_buffer_list_spec.lua b/test/functional/legacy/007_ball_buffer_list_spec.lua
index 295f63f044..07e3fe6e7a 100644
--- a/test/functional/legacy/007_ball_buffer_list_spec.lua
+++ b/test/functional/legacy/007_ball_buffer_list_spec.lua
@@ -1,6 +1,6 @@
-- Test for autocommand that changes the buffer list, when doing ":ball".
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/009_bufleave_autocommand_spec.lua b/test/functional/legacy/009_bufleave_autocommand_spec.lua
index 8c18639c8f..7481c639cf 100644
--- a/test/functional/legacy/009_bufleave_autocommand_spec.lua
+++ b/test/functional/legacy/009_bufleave_autocommand_spec.lua
@@ -1,6 +1,6 @@
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua
index 483e465cee..ba899f8119 100644
--- a/test/functional/legacy/011_autocommands_spec.lua
+++ b/test/functional/legacy/011_autocommands_spec.lua
@@ -12,11 +12,14 @@
-- Use a FileChangedShell autocommand to avoid a prompt for "Xtestfile.gz"
-- being modified outside of Vim (noticed on Solaris).
-local helpers, lfs = require('test.functional.helpers'), require('lfs')
+local helpers= require('test.functional.helpers')(after_each)
+local lfs = require('lfs')
local clear, execute, expect, eq, neq, dedent, write_file, feed =
helpers.clear, helpers.execute, helpers.expect, helpers.eq, helpers.neq,
helpers.dedent, helpers.write_file, helpers.feed
+if helpers.pending_win32(pending) then return end
+
local function has_gzip()
return os.execute('gzip --help >/dev/null 2>&1') == 0
end
diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua
new file mode 100644
index 0000000000..cef31ae405
--- /dev/null
+++ b/test/functional/legacy/012_directory_spec.lua
@@ -0,0 +1,82 @@
+-- Tests for 'directory' option.
+-- - ".", in same dir as file
+-- - "./dir", in directory relative to file
+-- - "dir", in directory relative to current dir
+
+local helpers = require('test.functional.helpers')(after_each)
+local lfs = require('lfs')
+local insert, eq = helpers.insert, helpers.eq
+local neq, eval = helpers.neq, helpers.eval
+local clear, execute = helpers.clear, helpers.execute
+local wait, write_file = helpers.wait, helpers.write_file
+
+local function ls_dir_sorted(dirname)
+ local files = {}
+ for f in lfs.dir(dirname) do
+ if f ~= "." and f~= ".." then
+ table.insert(files, f)
+ end
+ end
+ table.sort(files)
+ return files
+end
+
+describe("'directory' option", function()
+ setup(function()
+ local text = [[
+ start of testfile
+ line 2 Abcdefghij
+ line 3 Abcdefghij
+ end of testfile
+ ]]
+ write_file('Xtest1', text)
+ lfs.mkdir('Xtest.je')
+ lfs.mkdir('Xtest2')
+ write_file('Xtest2/Xtest3', text)
+ clear()
+ end)
+ teardown(function()
+ execute('qall!')
+ helpers.rmdir('Xtest.je')
+ helpers.rmdir('Xtest2')
+ os.remove('Xtest1')
+ end)
+
+ it('is working', function()
+ insert([[
+ start of testfile
+ line 2 Abcdefghij
+ line 3 Abcdefghij
+ end of testfile]])
+
+ execute('set swapfile')
+ execute('set dir=.,~')
+
+ -- sanity check: files should not exist yet.
+ eq(nil, lfs.attributes('.Xtest1.swp'))
+
+ execute('e! Xtest1')
+ wait()
+ eq('Xtest1', eval('buffer_name("%")'))
+ -- Verify that the swapfile exists. In the legacy test this was done by
+ -- reading the output from :!ls.
+ neq(nil, lfs.attributes('.Xtest1.swp'))
+
+ execute('set dir=./Xtest2,.,~')
+ execute('e Xtest1')
+ wait()
+
+ -- swapfile should no longer exist in CWD.
+ eq(nil, lfs.attributes('.Xtest1.swp'))
+
+ eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2"))
+
+ execute('set dir=Xtest.je,~')
+ execute('e Xtest2/Xtest3')
+ eq(1, eval('&swapfile'))
+ wait()
+
+ eq({ "Xtest3" }, ls_dir_sorted("Xtest2"))
+ eq({ "Xtest3.swp" }, ls_dir_sorted("Xtest.je"))
+ end)
+end)
diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua
index 3b19f4ff42..48d4042ff2 100644
--- a/test/functional/legacy/015_alignment_spec.lua
+++ b/test/functional/legacy/015_alignment_spec.lua
@@ -2,7 +2,7 @@
-- Also test formatting a paragraph.
-- Also test undo after ":%s" and formatting.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/018_unset_smart_indenting_spec.lua b/test/functional/legacy/018_unset_smart_indenting_spec.lua
index 6975cb7f26..ba1eac02cb 100644
--- a/test/functional/legacy/018_unset_smart_indenting_spec.lua
+++ b/test/functional/legacy/018_unset_smart_indenting_spec.lua
@@ -1,6 +1,6 @@
-- Tests for not doing smart indenting when it isn't set.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/019_smarttab_expandtab_spec.lua b/test/functional/legacy/019_smarttab_expandtab_spec.lua
index a33bd0c3ae..2287a9f786 100644
--- a/test/functional/legacy/019_smarttab_expandtab_spec.lua
+++ b/test/functional/legacy/019_smarttab_expandtab_spec.lua
@@ -1,7 +1,7 @@
-- Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set.
-- Also test that dv_ works correctly
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/020_blockwise_visual_spec.lua b/test/functional/legacy/020_blockwise_visual_spec.lua
index 95574a0957..660348a792 100644
--- a/test/functional/legacy/020_blockwise_visual_spec.lua
+++ b/test/functional/legacy/020_blockwise_visual_spec.lua
@@ -3,7 +3,7 @@
-- 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')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/021_control_wi_spec.lua b/test/functional/legacy/021_control_wi_spec.lua
index 9fd83fec5f..787a384fca 100644
--- a/test/functional/legacy/021_control_wi_spec.lua
+++ b/test/functional/legacy/021_control_wi_spec.lua
@@ -1,7 +1,7 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for [ CTRL-I with a count and CTRL-W CTRL-I with a count
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/022_line_ending_spec.lua b/test/functional/legacy/022_line_ending_spec.lua
index a841378a82..092440bb16 100644
--- a/test/functional/legacy/022_line_ending_spec.lua
+++ b/test/functional/legacy/022_line_ending_spec.lua
@@ -1,6 +1,6 @@
-- Tests for file with some lines ending in CTRL-M, some not
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua
index 15b30bfa3a..95ab983d24 100644
--- a/test/functional/legacy/023_edit_arguments_spec.lua
+++ b/test/functional/legacy/023_edit_arguments_spec.lua
@@ -1,6 +1,6 @@
-- Tests for complicated + argument to :edit command
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/025_jump_tag_hidden_spec.lua b/test/functional/legacy/025_jump_tag_hidden_spec.lua
index bd434c013c..99224f9e08 100644
--- a/test/functional/legacy/025_jump_tag_hidden_spec.lua
+++ b/test/functional/legacy/025_jump_tag_hidden_spec.lua
@@ -1,10 +1,12 @@
-- 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')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
+if helpers.pending_win32(pending) then return end
+
describe('jump to a tag with hidden set', function()
setup(clear)
diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua
index f17bb79702..74ef34bb20 100644
--- a/test/functional/legacy/026_execute_while_if_spec.lua
+++ b/test/functional/legacy/026_execute_while_if_spec.lua
@@ -1,6 +1,6 @@
-- Test for :execute, :while and :if
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
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
deleted file mode 100644
index 4778d16d43..0000000000
--- a/test/functional/legacy/027_expand_file_names_spec.lua
+++ /dev/null
@@ -1,37 +0,0 @@
--- Test for expanding file names
-
-local helpers = require('test.functional.helpers')
-local clear, feed = helpers.clear, helpers.feed
-local execute = helpers.execute
-local curbuf_contents = helpers.curbuf_contents
-local eq = helpers.eq
-
-describe('expand file name', function()
- setup(clear)
-
- it('is working', function()
- execute('!mkdir Xdir1')
- execute('!mkdir Xdir2')
- execute('!mkdir Xdir3')
- execute('cd Xdir3')
- execute('!mkdir Xdir4')
- execute('cd ..')
- execute('w Xdir1/file')
- execute('w Xdir3/Xdir4/file')
- execute('n Xdir?/*/file')
-
- -- Yank current file path to @a register
- feed('i<C-R>%<Esc>V"ad')
-
- -- Put @a and current file path in the current buffer
- execute('n! Xdir?/*/nofile')
- feed('V"ap')
- feed('o<C-R>%<Esc>')
-
- eq("Xdir3/Xdir4/file\nXdir?/*/nofile", curbuf_contents())
- end)
-
- teardown(function()
- os.execute('rm -rf Xdir1 Xdir2 Xdir3')
- end)
-end)
diff --git a/test/functional/legacy/028_source_ctrl_v_spec.lua b/test/functional/legacy/028_source_ctrl_v_spec.lua
index fc36b436ef..a8c43260be 100644
--- a/test/functional/legacy/028_source_ctrl_v_spec.lua
+++ b/test/functional/legacy/028_source_ctrl_v_spec.lua
@@ -1,6 +1,6 @@
-- Test for sourcing a file with CTRL-V's at the end of the line
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua
index 25a072ad6e..7a183fcbec 100644
--- a/test/functional/legacy/029_join_spec.lua
+++ b/test/functional/legacy/029_join_spec.lua
@@ -1,6 +1,6 @@
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/030_fileformats_spec.lua b/test/functional/legacy/030_fileformats_spec.lua
new file mode 100644
index 0000000000..5fd78b2c59
--- /dev/null
+++ b/test/functional/legacy/030_fileformats_spec.lua
@@ -0,0 +1,377 @@
+-- Test for a lot of variations of the 'fileformats' option
+
+local helpers = require('test.functional.helpers')(after_each)
+local feed, clear, execute = helpers.feed, helpers.clear, helpers.execute
+local eq, write_file = helpers.eq, helpers.write_file
+
+if helpers.pending_win32(pending) then return end
+
+describe('fileformats option', function()
+ setup(function()
+ clear()
+ local dos = 'dos\r\ndos\r\n'
+ local mac = 'mac\rmac\r'
+ local unix = 'unix\nunix\n'
+ local eol = 'noeol'
+ write_file('XXDos', dos)
+ write_file('XXMac', mac)
+ write_file('XXUnix', unix)
+ write_file('XXEol', eol)
+ write_file('XXDosMac', dos..mac)
+ write_file('XXMacEol', mac..eol)
+ write_file('XXUxDs', unix..dos)
+ write_file('XXUxDsMc', unix..dos..mac)
+ write_file('XXUxMac', unix..mac)
+ end)
+
+ teardown(function()
+ os.remove('test.out')
+ os.remove('XXDos')
+ os.remove('XXMac')
+ os.remove('XXUnix')
+ os.remove('XXEol')
+ os.remove('XXDosMac')
+ os.remove('XXMacEol')
+ os.remove('XXUxDs')
+ os.remove('XXUxDsMc')
+ os.remove('XXUxMac')
+ for i = 0, 9 do
+ for j = 1, 4 do
+ os.remove('XXtt'..i..j)
+ end
+ end
+ end)
+
+ it('is working', function()
+
+ -- Try reading and writing with 'fileformats' empty.
+ execute('set fileformats=')
+ execute('set fileformat=unix')
+ execute('e! XXUnix')
+ execute('w! test.out')
+ execute('e! XXDos')
+ execute('w! XXtt01')
+ execute('e! XXMac')
+ execute('w! XXtt02')
+ execute('bwipe XXUnix XXDos XXMac')
+ execute('set fileformat=dos')
+ execute('e! XXUnix')
+ execute('w! XXtt11')
+ execute('e! XXDos')
+ execute('w! XXtt12')
+ execute('e! XXMac')
+ execute('w! XXtt13')
+ execute('bwipe XXUnix XXDos XXMac')
+ execute('set fileformat=mac')
+ execute('e! XXUnix')
+ execute('w! XXtt21')
+ execute('e! XXDos')
+ execute('w! XXtt22')
+ execute('e! XXMac')
+ execute('w! XXtt23')
+ execute('bwipe XXUnix XXDos XXMac')
+
+ -- Try reading and writing with 'fileformats' set to one format.
+ execute('set fileformats=unix')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt31')
+ execute('bwipe XXUxDsMc')
+ execute('set fileformats=dos')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt32')
+ execute('bwipe XXUxDsMc')
+ execute('set fileformats=mac')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt33')
+ execute('bwipe XXUxDsMc')
+
+ -- Try reading and writing with 'fileformats' set to two formats.
+ execute('set fileformats=unix,dos')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt41')
+ execute('bwipe XXUxDsMc')
+ execute('e! XXUxMac')
+ execute('w! XXtt42')
+ execute('bwipe XXUxMac')
+ execute('e! XXDosMac')
+ execute('w! XXtt43')
+ execute('bwipe XXDosMac')
+ execute('set fileformats=unix,mac')
+ execute('e! XXUxDs')
+ execute('w! XXtt51')
+ execute('bwipe XXUxDs')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt52')
+ execute('bwipe XXUxDsMc')
+ execute('e! XXDosMac')
+ execute('w! XXtt53')
+ execute('bwipe XXDosMac')
+ execute('e! XXEol')
+ feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>')
+ execute('w! XXtt54')
+ execute('bwipe XXEol')
+ execute('set fileformats=dos,mac')
+ execute('e! XXUxDs')
+ execute('w! XXtt61')
+ execute('bwipe XXUxDs')
+ execute('e! XXUxMac')
+ feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>')
+ execute('w! XXtt62')
+ execute('bwipe XXUxMac')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt63')
+ execute('bwipe XXUxDsMc')
+ execute('e! XXMacEol')
+ feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>')
+ execute('w! XXtt64')
+ execute('bwipe XXMacEol')
+
+ -- Try reading and writing with 'fileformats' set to three formats.
+ execute('set fileformats=unix,dos,mac')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt71')
+ execute('bwipe XXUxDsMc')
+ execute('e! XXEol')
+ feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>')
+ execute('w! XXtt72')
+ execute('bwipe XXEol')
+ execute('set fileformats=mac,dos,unix')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt81')
+ execute('bwipe XXUxDsMc')
+ execute('e! XXEol')
+ feed('ggO<C-R>=&ffs<CR>:<C-R>=&ff<CR><ESC>')
+ execute('w! XXtt82')
+ execute('bwipe XXEol')
+ -- Try with 'binary' set.
+ execute('set fileformats=mac,unix,dos')
+ execute('set binary')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt91')
+ execute('bwipe XXUxDsMc')
+ execute('set fileformats=mac')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt92')
+ execute('bwipe XXUxDsMc')
+ execute('set fileformats=dos')
+ execute('e! XXUxDsMc')
+ execute('w! XXtt93')
+
+ -- Append "END" to each file so that we can see what the last written
+ -- char was.
+ execute('set fileformat=unix nobin')
+ feed('ggdGaEND<esc>')
+ execute('w >>XXtt01')
+ execute('w >>XXtt02')
+ execute('w >>XXtt11')
+ execute('w >>XXtt12')
+ execute('w >>XXtt13')
+ execute('w >>XXtt21')
+ execute('w >>XXtt22')
+ execute('w >>XXtt23')
+ execute('w >>XXtt31')
+ execute('w >>XXtt32')
+ execute('w >>XXtt33')
+ execute('w >>XXtt41')
+ execute('w >>XXtt42')
+ execute('w >>XXtt43')
+ execute('w >>XXtt51')
+ execute('w >>XXtt52')
+ execute('w >>XXtt53')
+ execute('w >>XXtt54')
+ execute('w >>XXtt61')
+ execute('w >>XXtt62')
+ execute('w >>XXtt63')
+ execute('w >>XXtt64')
+ execute('w >>XXtt71')
+ execute('w >>XXtt72')
+ execute('w >>XXtt81')
+ execute('w >>XXtt82')
+ execute('w >>XXtt91')
+ execute('w >>XXtt92')
+ execute('w >>XXtt93')
+
+ -- Concatenate the results.
+ -- Make fileformat of test.out the native fileformat.
+ -- Add a newline at the end.
+ execute('set binary')
+ execute('e! test.out')
+ execute('$r XXtt01')
+ execute('$r XXtt02')
+ feed('Go1<esc>')
+ execute('$r XXtt11')
+ execute('$r XXtt12')
+ execute('$r XXtt13')
+ feed('Go2<esc>')
+ execute('$r XXtt21')
+ execute('$r XXtt22')
+ execute('$r XXtt23')
+ feed('Go3<esc>')
+ execute('$r XXtt31')
+ execute('$r XXtt32')
+ execute('$r XXtt33')
+ feed('Go4<esc>')
+ execute('$r XXtt41')
+ execute('$r XXtt42')
+ execute('$r XXtt43')
+ feed('Go5<esc>')
+ execute('$r XXtt51')
+ execute('$r XXtt52')
+ execute('$r XXtt53')
+ execute('$r XXtt54')
+ feed('Go6<esc>')
+ execute('$r XXtt61')
+ execute('$r XXtt62')
+ execute('$r XXtt63')
+ execute('$r XXtt64')
+ feed('Go7<esc>')
+ execute('$r XXtt71')
+ execute('$r XXtt72')
+ feed('Go8<esc>')
+ execute('$r XXtt81')
+ execute('$r XXtt82')
+ feed('Go9<esc>')
+ execute('$r XXtt91')
+ execute('$r XXtt92')
+ execute('$r XXtt93')
+ feed('Go10<esc>')
+ execute('$r XXUnix')
+ execute('set nobinary ff&')
+
+ -- Assert buffer contents. This has to be done manually as
+ -- helpers.expect() calls helpers.dedent() which messes up the white space
+ -- and carrige returns.
+ eq(
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'END\n'..
+ 'mac\rmac\r\n'..
+ 'END\n'..
+ '1\n'..
+ 'unix\r\n'..
+ 'unix\r\n'..
+ 'END\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'END\n'..
+ 'mac\rmac\r\r\n'..
+ 'END\n'..
+ '2\n'..
+ 'unix\n'..
+ 'unix\n'..
+ '\rEND\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ '\rEND\n'..
+ 'mac\rmac\rEND\n'..
+ '3\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\n'..
+ 'END\n'..
+ 'unix\r\n'..
+ 'unix\r\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\r\n'..
+ 'END\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\rEND\n'..
+ '4\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\n'..
+ 'END\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'mac\rmac\r\n'..
+ 'END\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\r\n'..
+ 'END\n'..
+ '5\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'END\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\n'..
+ 'END\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\rEND\n'..
+ 'unix,mac:unix\n'..
+ 'noeol\n'..
+ 'END\n'..
+ '6\n'..
+ 'unix\r\n'..
+ 'unix\r\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'END\n'..
+ 'dos,mac:dos\r\n'..
+ 'unix\r\n'..
+ 'unix\r\n'..
+ 'mac\rmac\r\r\n'..
+ 'END\n'..
+ 'unix\r\n'..
+ 'unix\r\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\r\n'..
+ 'END\n'..
+ 'dos,mac:mac\rmac\rmac\rnoeol\rEND\n'..
+ '7\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\n'..
+ 'END\n'..
+ 'unix,dos,mac:unix\n'..
+ 'noeol\n'..
+ 'END\n'..
+ '8\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\r\n'..
+ 'END\n'..
+ 'mac,dos,unix:mac\rnoeol\rEND\n'..
+ '9\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\rEND\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\rEND\n'..
+ 'unix\n'..
+ 'unix\n'..
+ 'dos\r\n'..
+ 'dos\r\n'..
+ 'mac\rmac\rEND\n'..
+ '10\n'..
+ 'unix\n'..
+ 'unix',
+ helpers.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 b79b1903ba..d41eadaa00 100644
--- a/test/functional/legacy/031_close_commands_spec.lua
+++ b/test/functional/legacy/031_close_commands_spec.lua
@@ -9,12 +9,28 @@
-- :buf
-- :edit
-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 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 execute = helpers.execute
describe('Commands that close windows and/or buffers', function()
- setup(clear)
+ local function cleanup()
+ os.remove('Xtest1')
+ os.remove('Xtest2')
+ os.remove('Xtest3')
+ end
+ setup(function()
+ cleanup()
+ clear()
+ end)
+ teardown(function()
+ cleanup()
+ end)
it('is working', function()
insert('testtext')
@@ -107,10 +123,4 @@ describe('Commands that close windows and/or buffers', function()
" Now nvim should have exited
throw "Oh, Not finished yet."]])
end)
-
- teardown(function()
- os.remove('Xtest1')
- os.remove('Xtest2')
- os.remove('Xtest3')
- end)
end)
diff --git a/test/functional/legacy/033_lisp_indent_spec.lua b/test/functional/legacy/033_lisp_indent_spec.lua
index 0a5577fad3..b4abb02ac2 100644
--- a/test/functional/legacy/033_lisp_indent_spec.lua
+++ b/test/functional/legacy/033_lisp_indent_spec.lua
@@ -2,7 +2,7 @@
-- Test for 'lisp'
-- If the lisp feature is not enabled, this will fail!
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/034_user_function_spec.lua b/test/functional/legacy/034_user_function_spec.lua
new file mode 100644
index 0000000000..38989cd982
--- /dev/null
+++ b/test/functional/legacy/034_user_function_spec.lua
@@ -0,0 +1,102 @@
+-- Test for user functions.
+-- Also test an <expr> mapping calling a function.
+-- 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, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('user functions, expr-mappings, overwrite protected builtin functions and regression on calling expressions', function()
+ setup(clear)
+
+ it('are working', function()
+ insert('here')
+
+ source([[
+ function Table(title, ...)
+ let ret = a:title
+ let idx = 1
+ while idx <= a:0
+ exe "let ret = ret . a:" . idx
+ let idx = idx + 1
+ endwhile
+ return ret
+ endfunction
+ function Compute(n1, n2, divname)
+ if a:n2 == 0
+ return "fail"
+ endif
+ exe "let g:" . a:divname . " = ". a:n1 / a:n2
+ return "ok"
+ endfunction
+ func Expr1()
+ normal! v
+ return "111"
+ endfunc
+ func Expr2()
+ call search('XX', 'b')
+ return "222"
+ endfunc
+ func ListItem()
+ let g:counter += 1
+ return g:counter . '. '
+ endfunc
+ func ListReset()
+ let g:counter = 0
+ return ''
+ endfunc
+ func FuncWithRef(a)
+ unlet g:FuncRef
+ return a:a
+ endfunc
+ let g:FuncRef=function("FuncWithRef")
+ let counter = 0
+ inoremap <expr> ( ListItem()
+ inoremap <expr> [ ListReset()
+ imap <expr> + Expr1()
+ imap <expr> * Expr2()
+ let retval = "nop"
+ /^here
+ ]])
+ feed('C<C-R>=Table("xxx", 4, "asdf")<cr>')
+ -- Using a actual space will not work as feed() calls dedent on the input.
+ feed('<space><C-R>=Compute(45, 0, "retval")<cr>')
+ feed('<space><C-R>=retval<cr>')
+ feed('<space><C-R>=Compute(45, 5, "retval")<cr>')
+ feed('<space><C-R>=retval<cr>')
+ feed('<space><C-R>=g:FuncRef(333)<cr>')
+ feed('<cr>')
+ feed('XX+-XX<cr>')
+ feed('---*---<cr>')
+ feed('(one<cr>')
+ feed('(two<cr>')
+ feed('[(one again<esc>')
+ execute('call append(line("$"), max([1, 2, 3]))')
+ execute('call extend(g:, {"max": function("min")})')
+ execute('call append(line("$"), max([1, 2, 3]))')
+ execute('try')
+ -- Regression: the first line below used to throw "E110: Missing ')'"
+ -- Second is here just to prove that this line is correct when not
+ -- skipping rhs of &&.
+ execute([[ $put =(0&&(function('tr'))(1, 2, 3))]])
+ execute([[ $put =(1&&(function('tr'))(1, 2, 3))]])
+ execute('catch')
+ execute([[ $put ='!!! Unexpected exception:']])
+ execute(' $put =v:exception')
+ execute('endtry')
+
+ -- Assert buffer contents.
+ expect([[
+ xxx4asdf fail nop ok 9 333
+ XX111-XX
+ ---222---
+ 1. one
+ 2. two
+ 1. one again
+ 3
+ 3
+ 0
+ 1]])
+ end)
+end)
diff --git a/test/functional/legacy/035_increment_and_decrement_spec.lua b/test/functional/legacy/035_increment_and_decrement_spec.lua
index e6252c384b..3b9f7a9d85 100644
--- a/test/functional/legacy/035_increment_and_decrement_spec.lua
+++ b/test/functional/legacy/035_increment_and_decrement_spec.lua
@@ -1,7 +1,7 @@
-- Test Ctrl-A and Ctrl-X, which increment and decrement decimal, hexadecimal,
-- and octal numbers.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/036_regexp_character_classes_spec.lua b/test/functional/legacy/036_regexp_character_classes_spec.lua
index de080f4b43..15287b9901 100644
--- a/test/functional/legacy/036_regexp_character_classes_spec.lua
+++ b/test/functional/legacy/036_regexp_character_classes_spec.lua
@@ -1,9 +1,8 @@
-- Test character classes in regexp using regexpengine 0, 1, 2.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
local source, write_file = helpers.source, helpers.write_file
-local os_name = helpers.os_name
local function sixlines(text)
local result = ''
@@ -14,19 +13,16 @@ local function sixlines(text)
end
local function diff(text, nodedent)
- local tmpname = os.tmpname()
- if os_name() == 'osx' and string.match(tmpname, '^/tmp') then
- tmpname = '/private'..tmpname
- end
- execute('w! '..tmpname)
+ local fname = helpers.tmpname()
+ execute('w! '..fname)
helpers.wait()
- local data = io.open(tmpname):read('*all')
+ local data = io.open(fname):read('*all')
if nodedent then
helpers.eq(text, data)
else
helpers.eq(helpers.dedent(text), data)
end
- os.remove(tmpname)
+ os.remove(fname)
end
describe('character classes in regexp', function()
@@ -268,4 +264,15 @@ describe('character classes in regexp', function()
ABCDEFGHIXYZ
ABCDEFGHIXYZ]])
end)
+ it([["\%1l^#.*" does not match on a line starting with "#". (vim-patch:7.4.1305)]], function()
+ source([[
+ 1 s/\%#=0\%1l^\t...//g
+ 2 s/\%#=1\%2l^\t...//g
+ 3 s/\%#=2\%3l^\t...//g
+ 4 s/\%#=0\%4l^\t...//g
+ 5 s/\%#=1\%5l^\t...//g
+ 6 s/\%#=2\%6l^\t...//g]])
+ diff(sixlines(string.sub(punct1, 1)..digits..punct2..upper..punct3..
+ lower..punct4..ctrl2..iso_text))
+ end)
end)
diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua
index 10d42f0cea..dcbc9c39f7 100644
--- a/test/functional/legacy/038_virtual_replace_spec.lua
+++ b/test/functional/legacy/038_virtual_replace_spec.lua
@@ -1,6 +1,6 @@
-- Test Virtual replace mode.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
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 7195d7d11d..63335985cc 100644
--- a/test/functional/legacy/039_visual_block_mode_commands_spec.lua
+++ b/test/functional/legacy/039_visual_block_mode_commands_spec.lua
@@ -1,7 +1,7 @@
-- Test Visual block mode commands
-- And test "U" in Visual mode, also on German sharp S.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local nvim, eq = helpers.meths, helpers.eq
local insert, feed = helpers.insert, helpers.feed
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua b/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua
index 42fb5ed2b3..b6451eb720 100644
--- a/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua
+++ b/test/functional/legacy/041_writing_and_reading_hundred_kbyte_spec.lua
@@ -1,6 +1,6 @@
-- Test for writing and reading a file of over 100 Kbyte
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/043_magic_settings_spec.lua b/test/functional/legacy/043_magic_settings_spec.lua
index 27694e3754..f174751de2 100644
--- a/test/functional/legacy/043_magic_settings_spec.lua
+++ b/test/functional/legacy/043_magic_settings_spec.lua
@@ -1,7 +1,7 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for regexp with various magic settings.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
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 2a4c0149fa..c6883e4902 100644
--- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
+++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
@@ -3,7 +3,7 @@
--
-- This test contains both "test44" and "test99" from the old test suite.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
@@ -28,8 +28,6 @@ local function run_test_with_regexpengine(regexpengine)
e y
f z
g a啷bb
- h AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐẔ
- i aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑẕ
j 0123❤x
k combinations
l ä ö ü ᾱ̆́]])
@@ -68,14 +66,6 @@ local function run_test_with_regexpengine(regexpengine)
feed([[/\%U12345678<cr>x]])
feed([[/[\U1234abcd\u1234\uabcd]<cr>x]])
feed([[/\%d21879b<cr>x]])
- feed('/ [[=A=]]* [[=B=]]* [[=C=]]* [[=D=]]* [[=E=]]* [[=F=]]* ' ..
- '[[=G=]]* [[=H=]]* [[=I=]]* [[=J=]]* [[=K=]]* [[=L=]]* [[=M=]]* ' ..
- '[[=N=]]* [[=O=]]* [[=P=]]* [[=Q=]]* [[=R=]]* [[=S=]]* [[=T=]]* ' ..
- '[[=U=]]* [[=V=]]* [[=W=]]* [[=X=]]* [[=Y=]]* [[=Z=]]*/e<cr>x')
- feed('/ [[=a=]]* [[=b=]]* [[=c=]]* [[=d=]]* [[=e=]]* [[=f=]]* ' ..
- '[[=g=]]* [[=h=]]* [[=i=]]* [[=j=]]* [[=k=]]* [[=l=]]* [[=m=]]* ' ..
- '[[=n=]]* [[=o=]]* [[=p=]]* [[=q=]]* [[=r=]]* [[=s=]]* [[=t=]]* ' ..
- '[[=u=]]* [[=v=]]* [[=w=]]* [[=x=]]* [[=y=]]* [[=z=]]*/e<cr>x')
-- Line j. Test backwards search from a multi-byte character.
feed('/x<cr>x')
@@ -125,8 +115,6 @@ local function run_test_with_regexpengine(regexpengine)
e y
f z
g abb
- h AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐ
- i aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑ
j 012❤
k œ̄ṣ́m̥̄ᾱ̆́
l ä ö ü ᾱ̆́
diff --git a/test/functional/legacy/045_folding_spec.lua b/test/functional/legacy/045_folding_spec.lua
index 04b623ff3b..cefd7c0d42 100644
--- a/test/functional/legacy/045_folding_spec.lua
+++ b/test/functional/legacy/045_folding_spec.lua
@@ -1,6 +1,6 @@
-- Tests for folding.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, clear, execute, expect =
helpers.feed, helpers.insert, helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/046_multi_line_regexps_spec.lua b/test/functional/legacy/046_multi_line_regexps_spec.lua
index b17ab42fe3..30ec76ea3e 100644
--- a/test/functional/legacy/046_multi_line_regexps_spec.lua
+++ b/test/functional/legacy/046_multi_line_regexps_spec.lua
@@ -1,7 +1,7 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for multi-line regexps with ":s"
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local expect = helpers.expect
diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua
index 94c42b73e5..ef392d8c67 100644
--- a/test/functional/legacy/051_highlight_spec.lua
+++ b/test/functional/legacy/051_highlight_spec.lua
@@ -2,11 +2,13 @@
-- Tests for ":highlight".
local Screen = require('test.functional.ui.screen')
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
local wait = helpers.wait
+if helpers.pending_win32(pending) then return end
+
describe(':highlight', 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 bcedb26b7e..494ea8f927 100644
--- a/test/functional/legacy/054_buffer_local_autocommands_spec.lua
+++ b/test/functional/legacy/054_buffer_local_autocommands_spec.lua
@@ -1,6 +1,6 @@
-- Some tests for buffer-local autocommands
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, execute, eq = helpers.clear, helpers.execute, helpers.eq
local curbuf_contents = helpers.curbuf_contents
diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua
new file mode 100644
index 0000000000..dbe9e1bc7f
--- /dev/null
+++ b/test/functional/legacy/055_list_and_dict_types_spec.lua
@@ -0,0 +1,922 @@
+-- Tests for List and Dictionary types.
+
+local helpers = require('test.functional.helpers')(after_each)
+local feed, source = helpers.feed, helpers.source
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('list and dictionary types', function()
+ before_each(clear)
+
+ it('creating list directly with different types', function()
+ source([[
+ lang C
+ let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
+ $put =string(l)
+ $put =string(l[-1])
+ $put =string(l[-4])
+ try
+ $put =string(l[-5])
+ catch
+ $put =v:exception[:14]
+ endtry]])
+ expect([[
+
+ [1, 'as''d', [1, 2, function('strlen')], {'a': 1}]
+ {'a': 1}
+ 1
+ Vim(put):E684: ]])
+ end)
+
+ it('list slices', function()
+ source([[
+ lang C
+ " The list from the first test repeated after splitting the tests.
+ let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
+ $put =string(l[:])
+ $put =string(l[1:])
+ $put =string(l[:-2])
+ $put =string(l[0:8])
+ $put =string(l[8:-1])]])
+ expect([=[
+
+ [1, 'as''d', [1, 2, function('strlen')], {'a': 1}]
+ ['as''d', [1, 2, function('strlen')], {'a': 1}]
+ [1, 'as''d', [1, 2, function('strlen')]]
+ [1, 'as''d', [1, 2, function('strlen')], {'a': 1}]
+ []]=])
+ end)
+
+ it('list identity', function()
+ source([[
+ lang C
+ " The list from the first test repeated after splitting the tests.
+ let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
+ let ll = l
+ let lx = copy(l)
+ try
+ $put =(l == ll) . (l isnot ll) . (l is ll) . (l == lx) .
+ \ (l is lx) . (l isnot lx)
+ catch
+ $put =v:exception
+ endtry]])
+ expect('\n101101')
+ end)
+
+ it('creating dictionary directly with different types', function()
+ source([[
+ lang C
+ let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},}
+ $put =string(d) . d.1
+ $put =string(sort(keys(d)))
+ $put =string (values(d))
+ for [key, val] in items(d)
+ $put =key . ':' . string(val)
+ unlet key val
+ endfor
+ call extend (d, {3:33, 1:99})
+ call extend(d, {'b':'bbb', 'c':'ccc'}, "keep")
+ try
+ call extend(d, {3:333,4:444}, "error")
+ catch
+ $put =v:exception[:15] . v:exception[-1:-1]
+ endtry
+ $put =string(d)
+ call filter(d, 'v:key =~ ''[ac391]''')
+ $put =string(d)]])
+ expect([[
+
+ {'1': 'asd', 'b': [1, 2, function('strlen')], '-1': {'a': 1}}asd
+ ['-1', '1', 'b']
+ ['asd', [1, 2, function('strlen')], {'a': 1}]
+ 1:'asd'
+ b:[1, 2, function('strlen')]
+ -1:{'a': 1}
+ Vim(call):E737: 3
+ {'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}
+ {'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}}]])
+ end)
+
+ it('dictionary identity', function()
+ source([[
+ lang C
+ " The dict from the first test repeated after splitting the tests.
+ let d = {'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}}
+ let dd = d
+ let dx = copy(d)
+ try
+ $put =(d == dd) . (d isnot dd) . (d is dd) . (d == dx) . (d is dx) .
+ \ (d isnot dx)
+ catch
+ $put =v:exception
+ endtry]])
+ expect('\n101101')
+ end)
+
+ it('removing items with :unlet', function()
+ source([[
+ lang C
+ " The list from the first test repeated after splitting the tests.
+ let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
+ " The dict from the first test repeated after splitting the tests.
+ let d = {'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}}
+ unlet l[2]
+ $put =string(l)
+ let l = range(8)
+ try
+ unlet l[:3]
+ unlet l[1:]
+ catch
+ $put =v:exception
+ endtry
+ $put =string(l)
+
+ unlet d.c
+ unlet d[-1]
+ $put =string(d)]])
+ expect([[
+
+ [1, 'as''d', {'a': 1}]
+ [4]
+ {'1': 99, '3': 33}]])
+ end)
+
+ it("removing items out of range: silently skip items that don't exist", function()
+ -- We can not use source() here as we want to ignore all errors.
+ execute('lang C')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[2:1]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[2:2]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[2:3]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[2:4]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[2:5]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[-1:2]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[-2:2]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[-3:2]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[-4:2]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[-5:2]')
+ execute('$put =string(l)')
+ execute('let l = [0, 1, 2, 3]')
+ execute('unlet l[-6:2]')
+ execute('$put =string(l)')
+ expect([=[
+
+ [0, 1, 2, 3]
+ [0, 1, 3]
+ [0, 1]
+ [0, 1]
+ [0, 1]
+ [0, 1, 2, 3]
+ [0, 1, 3]
+ [0, 3]
+ [3]
+ [3]
+ [3]]=])
+ end)
+
+ it('assignment to a list', function()
+ source([[
+ let l = [0, 1, 2, 3]
+ let [va, vb] = l[2:3]
+ $put =va
+ $put =vb
+ try
+ let [va, vb] = l
+ catch
+ $put =v:exception[:14]
+ endtry
+ try
+ let [va, vb] = l[1:1]
+ catch
+ $put =v:exception[:14]
+ endtry]])
+ expect([[
+
+ 2
+ 3
+ Vim(let):E687:
+ Vim(let):E688: ]])
+ end)
+
+ it('manipulating a big dictionary', function()
+ -- Manipulating a big Dictionary (hashtable.c has a border of 1000
+ -- entries).
+ source([[
+ let d = {}
+ for i in range(1500)
+ let d[i] = 3000 - i
+ endfor
+ $put =d[0] . ' ' . d[100] . ' ' . d[999] . ' ' . d[1400] . ' ' .
+ \ d[1499]
+ try
+ let n = d[1500]
+ catch
+ $put =substitute(v:exception, '\v(.{14}).*( \d{4}).*', '\1\2', '')
+ endtry
+ " Lookup each items.
+ for i in range(1500)
+ if d[i] != 3000 - i
+ $put =d[i]
+ endif
+ endfor
+ let i += 1
+ " Delete even items.
+ while i >= 2
+ let i -= 2
+ unlet d[i]
+ endwhile
+ $put =get(d, 1500 - 100, 'NONE') . ' ' . d[1]
+ " Delete odd items, checking value, one intentionally wrong.
+ let d[33] = 999
+ let i = 1
+ while i < 1500
+ if d[i] != 3000 - i
+ $put =i . '=' . d[i]
+ else
+ unlet d[i]
+ endif
+ let i += 2
+ endwhile
+ " Must be almost empty now.
+ $put =string(d)]])
+ expect([[
+
+ 3000 2900 2001 1600 1501
+ Vim(let):E716: 1500
+ NONE 2999
+ 33=999
+ {'33': 999}]])
+ end)
+
+ it('dictionary function', function()
+ source([[
+ let dict = {}
+ func dict.func(a) dict
+ $put =a:a . len(self.data)
+ endfunc
+ let dict.data = [1,2,3]
+ call dict.func("len: ")
+ let x = dict.func("again: ")
+ let Fn = dict.func
+ call Fn('xxx')]])
+ expect([[
+
+ len: 3
+ again: 3
+ xxx3]])
+ end)
+
+ it('Function in script-local List or Dict', function()
+ source([[
+ let g:dict = {}
+ function g:dict.func() dict
+ $put ='g:dict.func'.self.foo[1].self.foo[0]('asdf')
+ endfunc
+ let g:dict.foo = ['-', 2, 3]
+ call insert(g:dict.foo, function('strlen'))
+ call g:dict.func()]])
+ expect('\ng:dict.func-4')
+ end)
+
+ it("remove func from dict that's being called (works)", function()
+ source([[
+ let d = {1:1}
+ func d.func(a)
+ return "a:". a:a
+ endfunc
+ $put =d.func(string(remove(d, 'func')))]])
+ -- The function number changed from 3 to 1 because we split the test.
+ -- There were two other functions in the old test before this.
+ expect("\na:function('1')")
+ end)
+
+ it('deepcopy() dict that refers to itself', function()
+ -- Nasty: deepcopy() dict that refers to itself (fails when noref used).
+ source([[
+ let d = {1:1, 2:2}
+ let l = [4, d, 6]
+ let d[3] = l
+ let dc = deepcopy(d)
+ try
+ let dc = deepcopy(d, 1)
+ catch
+ $put =v:exception[:14]
+ endtry
+ let l2 = [0, l, l, 3]
+ let l[1] = l2
+ let l3 = deepcopy(l2)
+ $put ='same list: ' . (l3[1] is l3[2])]])
+ expect([[
+
+ Vim(let):E698:
+ same list: 1]])
+ end)
+
+ it('locked variables (part 1)', function()
+ source([=[
+ let l = []
+ for depth in range(5)
+ $put ='depth is ' . depth
+ for u in range(3)
+ unlet l
+ let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]
+ exe "lockvar " . depth . " l"
+ if u == 1
+ exe "unlockvar l"
+ elseif u == 2
+ exe "unlockvar " . depth . " l"
+ endif
+ let ps = islocked("l") . islocked("l[1]") . islocked("l[1][1]") .
+ \ islocked("l[1][1][0]") . '-' . islocked("l[2]") .
+ \ islocked("l[2]['6']") . islocked("l[2]['6'][7]")
+ $put =ps
+ let ps = ''
+ try
+ let l[1][1][0] = 99
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ let l[1][1] = [99]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ let l[1] = [99]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ let l[2]['6'][7] = 99
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ let l[2][6] = {99: 99}
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ let l[2] = {99: 99}
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ let l = [99]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ $put =ps
+ endfor
+ endfor]=])
+ expect([[
+
+ depth is 0
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ depth is 1
+ 1000-000
+ ppppppF
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ depth is 2
+ 1100-100
+ ppFppFF
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ depth is 3
+ 1110-110
+ pFFpFFF
+ 0010-010
+ pFppFpp
+ 0000-000
+ ppppppp
+ depth is 4
+ 1111-111
+ FFFFFFF
+ 0011-011
+ FFpFFpp
+ 0000-000
+ ppppppp]])
+ end)
+
+ -- TODO In the original test the 5th line of this source() call was used.
+ -- But now the test only passes if I comment it.
+ it('unletting locked variables', function()
+ source([=[
+ let l = []
+ for depth in range(5)
+ $put ='depth is ' . depth
+ for u in range(3)
+ "unlet l
+ let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]
+ exe "lockvar " . depth . " l"
+ if u == 1
+ exe "unlockvar l"
+ elseif u == 2
+ exe "unlockvar " . depth . " l"
+ endif
+ let ps = islocked("l") . islocked("l[1]") . islocked("l[1][1]") .
+ \ islocked("l[1][1][0]") . '-' . islocked("l[2]") .
+ \ islocked("l[2]['6']") . islocked("l[2]['6'][7]")
+ $put =ps
+ let ps = ''
+ try
+ unlet l[2]['6'][7]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ unlet l[2][6]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ unlet l[2]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ unlet l[1][1][0]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ unlet l[1][1]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ unlet l[1]
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ try
+ unlet l
+ let ps .= 'p'
+ catch
+ let ps .= 'F'
+ endtry
+ $put =ps
+ endfor
+ endfor]=])
+ expect([[
+
+ depth is 0
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ depth is 1
+ 1000-000
+ ppFppFp
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ depth is 2
+ 1100-100
+ pFFpFFp
+ 0000-000
+ ppppppp
+ 0000-000
+ ppppppp
+ depth is 3
+ 1110-110
+ FFFFFFp
+ 0010-010
+ FppFppp
+ 0000-000
+ ppppppp
+ depth is 4
+ 1111-111
+ FFFFFFp
+ 0011-011
+ FppFppp
+ 0000-000
+ ppppppp]])
+ end)
+
+ it('locked variables and :unlet or list / dict functions', function()
+ source([[
+ $put ='Locks and commands or functions:'
+
+ $put ='No :unlet after lock on dict:'
+ unlet! d
+ let d = {'a': 99, 'b': 100}
+ lockvar 1 d
+ try
+ unlet d.a
+ $put ='did :unlet'
+ catch
+ $put =v:exception[:16]
+ endtry
+ $put =string(d)
+
+ $put =':unlet after lock on dict item:'
+ unlet! d
+ let d = {'a': 99, 'b': 100}
+ lockvar d.a
+ try
+ unlet d.a
+ $put ='did :unlet'
+ catch
+ $put =v:exception[:16]
+ endtry
+ $put =string(d)
+
+ $put ='filter() after lock on dict item:'
+ unlet! d
+ let d = {'a': 99, 'b': 100}
+ lockvar d.a
+ try
+ call filter(d, 'v:key != "a"')
+ $put ='did filter()'
+ catch
+ $put =v:exception[:16]
+ endtry
+ $put =string(d)
+
+ $put ='map() after lock on dict:'
+ unlet! d
+ let d = {'a': 99, 'b': 100}
+ lockvar 1 d
+ try
+ call map(d, 'v:val + 200')
+ $put ='did map()'
+ catch
+ $put =v:exception[:16]
+ endtry
+ $put =string(d)
+
+ $put ='No extend() after lock on dict item:'
+ unlet! d
+ let d = {'a': 99, 'b': 100}
+ lockvar d.a
+ try
+ $put =string(extend(d, {'a': 123}))
+ $put ='did extend()'
+ catch
+ $put =v:exception[:14]
+ endtry
+ $put =string(d)
+
+ $put ='No remove() of write-protected scope-level variable:'
+ fun! Tfunc(this_is_a_loooooooooong_parameter_name)
+ try
+ $put =string(remove(a:, 'this_is_a_loooooooooong_parameter_name'))
+ $put ='did remove()'
+ catch
+ $put =v:exception[:14]
+ endtry
+ endfun
+ call Tfunc('testval')
+
+ $put ='No extend() of write-protected scope-level variable:'
+ fun! Tfunc(this_is_a_loooooooooong_parameter_name)
+ try
+ $put =string(extend(a:, {'this_is_a_loooooooooong_parameter_name': 1234}))
+ $put ='did extend()'
+ catch
+ $put =v:exception[:14]
+ endtry
+ endfun
+ call Tfunc('testval')
+
+ $put ='No :unlet of variable in locked scope:'
+ let b:testvar = 123
+ lockvar 1 b:
+ try
+ unlet b:testvar
+ $put ='b:testvar was :unlet: '. (!exists('b:testvar'))
+ catch
+ $put =v:exception[:16]
+ endtry
+ unlockvar 1 b:
+ unlet! b:testvar
+
+ $put ='No :let += of locked list variable:'
+ let l = ['a', 'b', 3]
+ lockvar 1 l
+ try
+ let l += ['x']
+ $put ='did :let +='
+ catch
+ $put =v:exception[:14]
+ endtry
+ $put =string(l)]])
+
+ expect([=[
+
+ Locks and commands or functions:
+ No :unlet after lock on dict:
+ Vim(unlet):E741:
+ {'a': 99, 'b': 100}
+ :unlet after lock on dict item:
+ did :unlet
+ {'b': 100}
+ filter() after lock on dict item:
+ did filter()
+ {'b': 100}
+ map() after lock on dict:
+ did map()
+ {'a': 299, 'b': 300}
+ No extend() after lock on dict item:
+ Vim(put):E741:
+ {'a': 99, 'b': 100}
+ No remove() of write-protected scope-level variable:
+ Vim(put):E795:
+ No extend() of write-protected scope-level variable:
+ Vim(put):E742:
+ No :unlet of variable in locked scope:
+ Vim(unlet):E741:
+ No :let += of locked list variable:
+ Vim(let):E741:
+ ['a', 'b', 3]]=])
+ end)
+
+ it('locked variables (part 2)', function()
+ execute(
+ 'let l = [1, 2, 3, 4]',
+ 'lockvar! l',
+ '$put =string(l)',
+ 'unlockvar l[1]',
+ 'unlet l[0:1]',
+ '$put =string(l)',
+ 'unlet l[1:2]',
+ '$put =string(l)',
+ 'unlockvar l[1]',
+ 'let l[0:1] = [0, 1]',
+ '$put =string(l)',
+ 'let l[1:2] = [0, 1]',
+ '$put =string(l)')
+ expect([=[
+
+ [1, 2, 3, 4]
+ [1, 2, 3, 4]
+ [1, 2, 3, 4]
+ [1, 2, 3, 4]
+ [1, 2, 3, 4]]=])
+ end)
+
+ it(':lockvar/islocked() triggering script autoloading.', function()
+ source([[
+ set rtp+=test/functional/fixtures
+ lockvar g:footest#x
+ unlockvar g:footest#x
+ $put ='locked g:footest#x:'.islocked('g:footest#x')
+ $put ='exists g:footest#x:'.exists('g:footest#x')
+ $put ='g:footest#x: '.g:footest#x]])
+ expect([[
+
+ locked g:footest#x:-1
+ exists g:footest#x:0
+ g:footest#x: 1]])
+ end)
+
+ it('a:000 function argument', function()
+ source([[
+ function Test(...)
+ " First the tests that should fail.
+ try
+ let a:000 = [1, 2]
+ catch
+ $put ='caught a:000'
+ endtry
+ try
+ let a:000[0] = 9
+ catch
+ $put ='caught a:000[0]'
+ endtry
+ try
+ let a:000[2] = [9, 10]
+ catch
+ $put ='caught a:000[2]'
+ endtry
+ try
+ let a:000[3] = {9: 10}
+ catch
+ $put ='caught a:000[3]'
+ endtry
+ " Now the tests that should pass.
+ try
+ let a:000[2][1] = 9
+ call extend(a:000[2], [5, 6])
+ let a:000[3][5] = 8
+ let a:000[3]['a'] = 12
+ $put =string(a:000)
+ catch
+ $put ='caught ' . v:exception
+ endtry
+ endfunction]])
+ execute('call Test(1, 2, [3, 4], {5: 6})')
+ expect([=[
+
+ caught a:000
+ caught a:000[0]
+ caught a:000[2]
+ caught a:000[3]
+ [1, 2, [3, 9, 5, 6], {'a': 12, '5': 8}]]=])
+ end)
+
+ it('reverse(), sort(), uniq()', function()
+ source([=[
+ let l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo',
+ \ [0, 1, 2], 'x8', [0, 1, 2], 1.5]
+ $put =string(uniq(copy(l)))
+ $put =string(reverse(l))
+ $put =string(reverse(reverse(l)))
+ $put =string(sort(l))
+ $put =string(reverse(sort(l)))
+ $put =string(sort(reverse(sort(l))))
+ $put =string(uniq(sort(l)))
+ let l=[7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff,
+ \ 0.22, 'four']
+ $put =string(sort(copy(l), 'n'))
+ let l=[7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar',
+ \ 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []]
+ $put =string(sort(copy(l), 1))
+ $put =string(sort(copy(l), 'i'))
+ $put =string(sort(copy(l)))]=])
+ expect([=[
+
+ ['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
+ [1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0']
+ [1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0']
+ ['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]]
+ [[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0']
+ ['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]]
+ ['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]]
+ [-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255]
+ ['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}]
+ ['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}]
+ ['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}]]=])
+ end)
+
+ it('splitting a string to a list', function()
+ source([[
+ $put =string(split(' aa bb '))
+ $put =string(split(' aa bb ', '\W\+', 0))
+ $put =string(split(' aa bb ', '\W\+', 1))
+ $put =string(split(' aa bb ', '\W', 1))
+ $put =string(split(':aa::bb:', ':', 0))
+ $put =string(split(':aa::bb:', ':', 1))
+ $put =string(split('aa,,bb, cc,', ',\s*', 1))
+ $put =string(split('abc', '\zs'))
+ $put =string(split('abc', '\zs', 1))]])
+ expect([=[
+
+ ['aa', 'bb']
+ ['aa', 'bb']
+ ['', 'aa', 'bb', '']
+ ['', '', 'aa', '', 'bb', '', '']
+ ['aa', '', 'bb']
+ ['', 'aa', '', 'bb', '']
+ ['aa', '', 'bb', 'cc', '']
+ ['a', 'b', 'c']
+ ['', 'a', '', 'b', '', 'c', '']]=])
+ end)
+
+ it('compare recursively linked list and dict', function()
+ source([[
+ let l = [1, 2, 3, 4]
+ let d = {'1': 1, '2': l, '3': 3}
+ let l[1] = d
+ $put =(l == l)
+ $put =(d == d)
+ $put =(l != deepcopy(l))
+ $put =(d != deepcopy(d))]])
+ expect([[
+
+ 1
+ 1
+ 0
+ 0]])
+ end)
+
+ it('compare complex recursively linked list and dict', function()
+ source([[
+ let l = []
+ call add(l, l)
+ let dict4 = {"l": l}
+ call add(dict4.l, dict4)
+ let lcopy = deepcopy(l)
+ let dict4copy = deepcopy(dict4)
+ $put =(l == lcopy)
+ $put =(dict4 == dict4copy)]])
+ expect([[
+
+ 1
+ 1]])
+ end)
+
+ it('pass the same list to extend()', function()
+ source([[
+ let l = [1, 2, 3, 4, 5]
+ call extend(l, l)
+ $put =string(l)]])
+ expect([=[
+
+ [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]]=])
+ end)
+
+ it('pass the same dict to extend()', function()
+ source([[
+ let d = { 'a': {'b': 'B'}}
+ call extend(d, d)
+ $put =string(d)]])
+ expect([[
+
+ {'a': {'b': 'B'}}]])
+ end)
+
+ it('pass the same dict to extend() with "error"', function()
+ source([[
+ " Copy dict from previous test.
+ let d = { 'a': {'b': 'B'}}
+ try
+ call extend(d, d, "error")
+ catch
+ $put =v:exception[:15] . v:exception[-1:-1]
+ endtry
+ $put =string(d)]])
+ expect([[
+
+ Vim(call):E737: a
+ {'a': {'b': 'B'}}]])
+ end)
+
+ it('test for range assign', function()
+ source([[
+ let l = [0]
+ let l[:] = [1, 2]
+ $put =string(l)]])
+ expect([=[
+
+ [1, 2]]=])
+ end)
+
+ it('vim patch 7.3.637', function()
+ execute('let a = "No error caught"')
+ execute('try')
+ execute(' foldopen')
+ execute('catch')
+ execute(" let a = matchstr(v:exception,'^[^ ]*')")
+ execute('endtry')
+ feed('o<C-R>=a<CR><esc>')
+ execute('lang C')
+ execute('redir => a')
+ -- The test failes if this is not in one line.
+ execute("try|foobar|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry")
+ execute('redir END')
+ feed('o<C-R>=a<CR><esc>')
+ expect([[
+
+ Vim(foldopen):E490:
+
+
+ Error detected while processing :
+ E492: Not an editor command: foobar|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry
+ ]])
+ end)
+end)
diff --git a/test/functional/legacy/056_script_local_function_spec.lua b/test/functional/legacy/056_script_local_function_spec.lua
index dec88e8001..084817ad7a 100644
--- a/test/functional/legacy/056_script_local_function_spec.lua
+++ b/test/functional/legacy/056_script_local_function_spec.lua
@@ -1,7 +1,7 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Test for script-local function.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local expect = helpers.expect
diff --git a/test/functional/legacy/057_sort_spec.lua b/test/functional/legacy/057_sort_spec.lua
index 36062ded3a..6984ad0de2 100644
--- a/test/functional/legacy/057_sort_spec.lua
+++ b/test/functional/legacy/057_sort_spec.lua
@@ -1,6 +1,6 @@
-- Tests for :sort command.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, execute, clear, expect, eq, eval, source = helpers.insert,
helpers.execute, helpers.clear, helpers.expect, helpers.eq, helpers.eval,
helpers.source
diff --git a/test/functional/legacy/059_utf8_spell_checking_spec.lua b/test/functional/legacy/059_utf8_spell_checking_spec.lua
index 63df387be3..2fb8f3557d 100644
--- a/test/functional/legacy/059_utf8_spell_checking_spec.lua
+++ b/test/functional/legacy/059_utf8_spell_checking_spec.lua
@@ -1,10 +1,12 @@
-- Tests for spell checking with 'encoding' set to "utf-8".
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
local write_file, call = helpers.write_file, helpers.call
+if helpers.pending_win32(pending) then return end
+
local function write_latin1(name, text)
text = call('iconv', text, 'utf-8', 'latin-1')
write_file(name, 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 7f44b35a4e..3e99f6df57 100644
--- a/test/functional/legacy/060_exists_and_has_functions_spec.lua
+++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua
@@ -1,6 +1,6 @@
-- Tests for the exists() and has() functions.
-local helpers = require('test.functional.helpers')
+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
@@ -638,15 +638,6 @@ describe('exists() and has() functions', function()
call TestExists()
- function TestHas()
- redir >> test.out
- for pl in ['6.9.999', '7.1.999', '7.4.123', '9.1.0', '9.9.1']
- echo 'has patch ' . pl . ': ' . has('patch-' . pl)
- endfor
- redir END
- endfunc
- call TestHas()
-
edit! test.out
set ff=unix
]=])
@@ -858,12 +849,7 @@ describe('exists() and has() functions', function()
OK
g:footest#x = 1
footest#F() 0
- UndefFun() 0
- has patch 6.9.999: 1
- has patch 7.1.999: 1
- has patch 7.4.123: 1
- has patch 9.1.0: 0
- has patch 9.9.1: 0]])
+ UndefFun() 0]])
end)
end)
diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua
index 6db37bf1ff..aeb2001d11 100644
--- a/test/functional/legacy/061_undo_tree_spec.lua
+++ b/test/functional/legacy/061_undo_tree_spec.lua
@@ -1,10 +1,15 @@
-- Tests for undo tree and :earlier and :later.
+local helpers = require('test.functional.helpers')(after_each)
-local helpers = require('test.functional.helpers')
-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
+local write_file = helpers.write_file
+local execute = helpers.execute
+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 function expect_empty_buffer()
-- The space will be removed by helpers.dedent but is needed because dedent
@@ -57,8 +62,7 @@ describe('undo tree:', function()
-- Delete three other characters and go back in time step by step.
feed('$xxx')
expect_line('123456')
- execute('sleep 1')
- wait()
+ command('sleep 1')
feed('g-')
expect_line('1234567')
feed('g-')
@@ -79,8 +83,7 @@ describe('undo tree:', function()
expect_line('123456')
-- Delay for two seconds and go some seconds forward and backward.
- execute('sleep 2')
- wait()
+ command('sleep 2')
feed('Aa<esc>')
feed('Ab<esc>')
feed('Ac<esc>')
@@ -95,15 +98,7 @@ describe('undo tree:', function()
expect_line('123456abc')
end
- -- Retry up to 3 times. pcall() is _not_ used for the final attempt, so
- -- that failure messages can bubble up.
- for _ = 1, 2 do
- local success = pcall(test_earlier_later)
- if success then
- return
- end
- end
- test_earlier_later()
+ helpers.retry(2, nil, test_earlier_later)
end)
it('file-write specifications', function()
diff --git a/test/functional/legacy/062_tab_pages_spec.lua b/test/functional/legacy/062_tab_pages_spec.lua
index f1c8b8d58b..d5b10b160e 100644
--- a/test/functional/legacy/062_tab_pages_spec.lua
+++ b/test/functional/legacy/062_tab_pages_spec.lua
@@ -1,6 +1,6 @@
-- Tests for tab pages
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source, clear, execute, expect, eval, eq =
helpers.feed, helpers.insert, helpers.source, helpers.clear,
helpers.execute, helpers.expect, helpers.eval, helpers.eq
diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua
index 23b4f4551b..298e0a31ea 100644
--- a/test/functional/legacy/063_match_and_matchadd_spec.lua
+++ b/test/functional/legacy/063_match_and_matchadd_spec.lua
@@ -1,6 +1,6 @@
-- Tests for adjusting window and contents
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local feed, insert = helpers.feed, helpers.insert
local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute
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 e78b230956..d12ea502f3 100644
--- a/test/functional/legacy/065_float_and_logic_operators_spec.lua
+++ b/test/functional/legacy/065_float_and_logic_operators_spec.lua
@@ -1,6 +1,6 @@
-- Test for floating point and logical operators.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source = helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/066_visual_block_tab_spec.lua b/test/functional/legacy/066_visual_block_tab_spec.lua
index 82bb988c67..72fa7d881b 100644
--- a/test/functional/legacy/066_visual_block_tab_spec.lua
+++ b/test/functional/legacy/066_visual_block_tab_spec.lua
@@ -1,7 +1,7 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Test for visual block shift and tab characters.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua
index dc4c9c7eeb..8f6b881ed8 100644
--- a/test/functional/legacy/067_augroup_exists_spec.lua
+++ b/test/functional/legacy/067_augroup_exists_spec.lua
@@ -1,7 +1,7 @@
-- Test that groups and patterns are tested correctly when calling exists() for
-- autocommands.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/068_text_formatting_spec.lua b/test/functional/legacy/068_text_formatting_spec.lua
index cac8be77f3..e232e5073d 100644
--- a/test/functional/legacy/068_text_formatting_spec.lua
+++ b/test/functional/legacy/068_text_formatting_spec.lua
@@ -1,6 +1,10 @@
-local helpers = require('test.functional.helpers')
-local feed, insert = helpers.feed, helpers.insert
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local helpers = require('test.functional.helpers')(after_each)
+
+local feed = helpers.feed
+local clear = helpers.clear
+local insert = helpers.insert
+local execute = helpers.execute
+local expect = helpers.expect
describe('text formatting', function()
setup(clear)
diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua
index efcc2f2cc3..4682a82008 100644
--- a/test/functional/legacy/072_undo_file_spec.lua
+++ b/test/functional/legacy/072_undo_file_spec.lua
@@ -2,7 +2,7 @@
-- 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')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
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 49c4827613..2fc30c9d83 100644
--- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua
+++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua
@@ -1,6 +1,7 @@
-- Tests for storing global variables in the .shada file
-local helpers, lfs = require('test.functional.helpers'), require('lfs')
+local helpers = require('test.functional.helpers')(after_each)
+local lfs = require('lfs')
local clear, execute, eq, neq, eval, wait, spawn =
helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.eval,
helpers.wait, helpers.spawn
diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua
index 82965f5cb2..e9d2acdaf5 100644
--- a/test/functional/legacy/075_maparg_spec.lua
+++ b/test/functional/legacy/075_maparg_spec.lua
@@ -1,7 +1,7 @@
-- Tests for maparg().
-- Also test utf8 map with a 0x80 byte.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/076_completefunc_spec.lua b/test/functional/legacy/076_completefunc_spec.lua
deleted file mode 100644
index 8af3be003e..0000000000
--- a/test/functional/legacy/076_completefunc_spec.lua
+++ /dev/null
@@ -1,68 +0,0 @@
--- Tests for completefunc/omnifunc.
-
-local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, expect, execute = helpers.clear, helpers.expect, helpers.execute
-
-describe('completefunc', function()
- setup(clear)
-
- it('is working', function()
- insert([=[
- +++
- one
- two
- three]=])
-
- -- Test that nothing happens if the 'completefunc' opens
- -- a new window (no completion, no crash).
- source([=[
- function! DummyCompleteOne(findstart, base)
- if a:findstart
- return 0
- else
- wincmd n
- return ['onedef', 'oneDEF']
- endif
- endfunction
- setlocal completefunc=DummyCompleteOne
- /^one
- ]=])
- feed('A<C-X><C-U><C-N><esc>')
- execute('q!')
- source([=[
- function! DummyCompleteTwo(findstart, base)
- if a:findstart
- wincmd n
- return 0
- else
- return ['twodef', 'twoDEF']
- endif
- endfunction
- setlocal completefunc=DummyCompleteTwo
- /^two
- ]=])
- feed('A<C-X><C-U><C-N><esc>')
- execute('q!')
- -- Test that 'completefunc' works when it's OK.
- source([=[
- function! DummyCompleteThree(findstart, base)
- if a:findstart
- return 0
- else
- return ['threedef', 'threeDEF']
- endif
- endfunction
- setlocal completefunc=DummyCompleteThree
- /^three
- ]=])
- feed('A<C-X><C-U><C-N><esc>')
-
- -- Assert buffer contents.
- expect([=[
- +++
-
- two
- threeDEF]=])
- end)
-end)
diff --git a/test/functional/legacy/077_mf_hash_grow_spec.lua b/test/functional/legacy/077_mf_hash_grow_spec.lua
index 029fe98fe9..b43263300d 100644
--- a/test/functional/legacy/077_mf_hash_grow_spec.lua
+++ b/test/functional/legacy/077_mf_hash_grow_spec.lua
@@ -6,7 +6,7 @@
-- cksum is part of POSIX and so should be available on most Unixes.
-- If it isn't available then the test will be skipped.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua
index e48fddaac1..4390ba2ca8 100644
--- a/test/functional/legacy/078_swapfile_recover_spec.lua
+++ b/test/functional/legacy/078_swapfile_recover_spec.lua
@@ -3,7 +3,7 @@
-- restored. We need about 10000 lines of 100 characters to get two levels of
-- pointer blocks.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, expect, source = helpers.clear, helpers.expect, helpers.source
describe('78', function()
diff --git a/test/functional/legacy/080_substitute_spec.lua b/test/functional/legacy/080_substitute_spec.lua
index 96082364e0..1bdae9be59 100644
--- a/test/functional/legacy/080_substitute_spec.lua
+++ b/test/functional/legacy/080_substitute_spec.lua
@@ -2,7 +2,7 @@
-- Test for submatch() on substitue().
-- Test for *:s%* on :substitute.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
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/081_coptions_movement_spec.lua b/test/functional/legacy/081_coptions_movement_spec.lua
index f27667b976..2ac1332687 100644
--- a/test/functional/legacy/081_coptions_movement_spec.lua
+++ b/test/functional/legacy/081_coptions_movement_spec.lua
@@ -1,6 +1,6 @@
-- Test for t movement command and 'cpo-;' setting
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua
index 933c6c8fa3..d6f3c45e1f 100644
--- a/test/functional/legacy/082_string_comparison_spec.lua
+++ b/test/functional/legacy/082_string_comparison_spec.lua
@@ -1,7 +1,7 @@
-- Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c)
-- Also test "g~ap".
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, source = helpers.feed, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
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 6b5ee60568..e94b46ca66 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,6 +1,6 @@
-- Tests for tag search with !_TAG_FILE_ENCODING.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source, clear, expect, write_file = helpers.insert,
helpers.source, helpers.clear, helpers.expect, helpers.write_file
diff --git a/test/functional/legacy/084_curswant_spec.lua b/test/functional/legacy/084_curswant_spec.lua
index 946dd5e501..818914eeb9 100644
--- a/test/functional/legacy/084_curswant_spec.lua
+++ b/test/functional/legacy/084_curswant_spec.lua
@@ -1,6 +1,6 @@
-- Tests for curswant not changing when setting an option.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source = helpers.insert, helpers.source
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/088_conceal_tabs_spec.lua b/test/functional/legacy/088_conceal_tabs_spec.lua
index c78f4e5c3e..00e7312bf8 100644
--- a/test/functional/legacy/088_conceal_tabs_spec.lua
+++ b/test/functional/legacy/088_conceal_tabs_spec.lua
@@ -1,7 +1,7 @@
-- Tests for correct display (cursor column position) with +conceal and
-- tabulators.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, clear, execute =
helpers.feed, helpers.insert, helpers.clear, helpers.execute
diff --git a/test/functional/legacy/089_number_relnumber_findfile_spec.lua b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
index f72ebf3f72..7a87fc8603 100644
--- a/test/functional/legacy/089_number_relnumber_findfile_spec.lua
+++ b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
@@ -2,7 +2,7 @@
-- This is not all that useful now that the options are no longer reset when
-- setting the other.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed = helpers.feed
local clear, expect, source = helpers.clear, helpers.expect, helpers.source
diff --git a/test/functional/legacy/090_sha256_spec.lua b/test/functional/legacy/090_sha256_spec.lua
index 95e50063a1..e364af9400 100644
--- a/test/functional/legacy/090_sha256_spec.lua
+++ b/test/functional/legacy/090_sha256_spec.lua
@@ -1,6 +1,6 @@
-- Tests for sha256() function.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source = helpers.insert, helpers.source
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/091_context_variables_spec.lua b/test/functional/legacy/091_context_variables_spec.lua
index 2c46ef643c..edf497d397 100644
--- a/test/functional/legacy/091_context_variables_spec.lua
+++ b/test/functional/legacy/091_context_variables_spec.lua
@@ -1,6 +1,6 @@
-- Tests for getbufvar(), getwinvar(), gettabvar() and gettabwinvar().
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source = helpers.insert, helpers.source
local clear, expect = helpers.clear, helpers.expect
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 f76ba25d7a..f8564384e9 100644
--- a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
+++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
@@ -3,7 +3,7 @@
--
-- Same as legacy test 93 but using UTF-8 file encoding.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
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 bf3af1a827..40be7dcca4 100644
--- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
+++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
@@ -3,10 +3,12 @@
--
-- Same as legacy test 92 but using Latin-1 file encoding.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+if helpers.pending_win32(pending) then return end
+
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 4dce39b8d2..a52fa00672 100644
--- a/test/functional/legacy/094_visual_mode_operators_spec.lua
+++ b/test/functional/legacy/094_visual_mode_operators_spec.lua
@@ -4,7 +4,7 @@
-- 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')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/095_regexp_multibyte_spec.lua b/test/functional/legacy/095_regexp_multibyte_spec.lua
index a80a247612..845ebaaad7 100644
--- a/test/functional/legacy/095_regexp_multibyte_spec.lua
+++ b/test/functional/legacy/095_regexp_multibyte_spec.lua
@@ -3,7 +3,7 @@
-- A pattern that gives the expected result produces OK, so that we know it was
-- actually tried.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source = helpers.insert, helpers.source
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/096_location_list_spec.lua b/test/functional/legacy/096_location_list_spec.lua
index 6e2f22ea33..eac8d6356d 100644
--- a/test/functional/legacy/096_location_list_spec.lua
+++ b/test/functional/legacy/096_location_list_spec.lua
@@ -6,7 +6,7 @@
-- C. make sure that the location list window is not reused instead of the window
-- it belongs to.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local source = helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua
index 5c467fbb20..23f1427cb5 100644
--- a/test/functional/legacy/097_glob_path_spec.lua
+++ b/test/functional/legacy/097_glob_path_spec.lua
@@ -2,10 +2,12 @@
-- Test whether glob()/globpath() return correct results with certain escaped
-- characters.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
+if helpers.pending_win32(pending) then return end
+
describe('glob() and globpath()', function()
setup(clear)
diff --git a/test/functional/legacy/098_scrollbind_spec.lua b/test/functional/legacy/098_scrollbind_spec.lua
index 6850e373ab..d22aefdcbc 100644
--- a/test/functional/legacy/098_scrollbind_spec.lua
+++ b/test/functional/legacy/098_scrollbind_spec.lua
@@ -1,6 +1,6 @@
-- Test for 'scrollbind' causing an unexpected scroll of one of the windows.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local source = helpers.source
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua
index 335d275c2a..fa29e5fbe8 100644
--- a/test/functional/legacy/101_hlsearch_spec.lua
+++ b/test/functional/legacy/101_hlsearch_spec.lua
@@ -1,6 +1,6 @@
-- Test for v:hlsearch
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
@@ -61,6 +61,6 @@ describe('v:hlsearch', function()
0:not highlighted
1:highlighted
0:not highlighted
- Vim(let):E706:]])
+ Vim(let):E745:]])
end)
end)
diff --git a/test/functional/legacy/102_fnameescape_spec.lua b/test/functional/legacy/102_fnameescape_spec.lua
index a3b0313d7a..c1a6c57956 100644
--- a/test/functional/legacy/102_fnameescape_spec.lua
+++ b/test/functional/legacy/102_fnameescape_spec.lua
@@ -1,6 +1,6 @@
-- Test if fnameescape is correct for special chars like!
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua
index c1407ef10a..d05b47fa32 100644
--- a/test/functional/legacy/103_visual_mode_reset_spec.lua
+++ b/test/functional/legacy/103_visual_mode_reset_spec.lua
@@ -1,6 +1,6 @@
-- Test for visual mode not being reset causing E315 error.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, source = helpers.feed, helpers.source
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/104_let_assignment_spec.lua b/test/functional/legacy/104_let_assignment_spec.lua
index a2431da835..27c3715231 100644
--- a/test/functional/legacy/104_let_assignment_spec.lua
+++ b/test/functional/legacy/104_let_assignment_spec.lua
@@ -1,6 +1,6 @@
-- Tests for :let.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua
index 5958f1aa7b..2b17d63378 100644
--- a/test/functional/legacy/106_errorformat_spec.lua
+++ b/test/functional/legacy/106_errorformat_spec.lua
@@ -1,6 +1,6 @@
-- Tests for errorformat.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
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 7a6de3d748..610bac7f21 100644
--- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua
+++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua
@@ -1,10 +1,12 @@
-- Tests for adjusting window and contents
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local insert = helpers.insert
local clear, execute = helpers.clear, helpers.execute
+if helpers.pending_win32(pending) then return end
+
describe('107', function()
setup(clear)
diff --git a/test/functional/legacy/108_backtrace_debug_commands_spec.lua b/test/functional/legacy/108_backtrace_debug_commands_spec.lua
index 6df645d255..a03092e446 100644
--- a/test/functional/legacy/108_backtrace_debug_commands_spec.lua
+++ b/test/functional/legacy/108_backtrace_debug_commands_spec.lua
@@ -1,6 +1,6 @@
-- Tests for backtrace debug commands.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, clear = helpers.feed, helpers.clear
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua
new file mode 100644
index 0000000000..b86d3f0aea
--- /dev/null
+++ b/test/functional/legacy/arglist_spec.lua
@@ -0,0 +1,270 @@
+-- Test argument list commands
+
+local helpers = require('test.functional.helpers')(after_each)
+local clear, execute, eq = helpers.clear, helpers.execute, helpers.eq
+local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq
+
+if helpers.pending_win32(pending) then return end
+
+describe('argument list commands', function()
+ before_each(clear)
+
+ local function init_abc()
+ execute('args a b c')
+ execute('next')
+ end
+
+ local function reset_arglist()
+ execute('arga a | %argd')
+ end
+
+ local function assert_fails(cmd, err)
+ neq(exc_exec(cmd):find(err), nil)
+ end
+
+ it('test that argidx() works', function()
+ execute('args a b c')
+ execute('last')
+ eq(2, eval('argidx()'))
+ execute('%argdelete')
+ eq(0, eval('argidx()'))
+
+ execute('args a b c')
+ eq(0, eval('argidx()'))
+ execute('next')
+ eq(1, eval('argidx()'))
+ execute('next')
+ eq(2, eval('argidx()'))
+ execute('1argdelete')
+ eq(1, eval('argidx()'))
+ execute('1argdelete')
+ eq(0, eval('argidx()'))
+ execute('1argdelete')
+ eq(0, eval('argidx()'))
+ end)
+
+ it('test that argadd() works', function()
+ execute('%argdelete')
+ execute('argadd a b c')
+ eq(0, eval('argidx()'))
+
+ execute('%argdelete')
+ execute('argadd a')
+ eq(0, eval('argidx()'))
+ execute('argadd b c d')
+ eq(0, eval('argidx()'))
+
+ init_abc()
+ execute('argadd x')
+ eq({'a', 'b', 'x', 'c'}, eval('argv()'))
+ eq(1, eval('argidx()'))
+
+ init_abc()
+ execute('0argadd x')
+ eq({'x', 'a', 'b', 'c'}, eval('argv()'))
+ eq(2, eval('argidx()'))
+
+ init_abc()
+ execute('1argadd x')
+ eq({'a', 'x', 'b', 'c'}, eval('argv()'))
+ eq(2, eval('argidx()'))
+
+ init_abc()
+ execute('$argadd x')
+ eq({'a', 'b', 'c', 'x'}, eval('argv()'))
+ eq(1, eval('argidx()'))
+
+ init_abc()
+ execute('$argadd x')
+ execute('+2argadd y')
+ eq({'a', 'b', 'c', 'x', 'y'}, eval('argv()'))
+ eq(1, eval('argidx()'))
+
+ execute('%argd')
+ execute('edit d')
+ execute('arga')
+ eq(1, eval('len(argv())'))
+ eq('d', eval('get(argv(), 0, "")'))
+
+ execute('%argd')
+ execute('new')
+ execute('arga')
+ eq(0, eval('len(argv())'))
+ end)
+
+ it('test for [count]argument and [count]argdelete commands', function()
+ reset_arglist()
+ execute('let save_hidden = &hidden')
+ execute('set hidden')
+ execute('let g:buffers = []')
+ execute('augroup TEST')
+ execute([[au BufEnter * call add(buffers, expand('%:t'))]])
+ execute('augroup END')
+
+ execute('argadd a b c d')
+ execute('$argu')
+ execute('$-argu')
+ execute('-argu')
+ execute('1argu')
+ execute('+2argu')
+
+ execute('augroup TEST')
+ execute('au!')
+ execute('augroup END')
+
+ eq({'d', 'c', 'b', 'a', 'c'}, eval('g:buffers'))
+
+ execute('redir => result')
+ execute('ar')
+ execute('redir END')
+ eq(1, eval([[result =~# 'a b \[c] d']]))
+
+ execute('.argd')
+ eq({'a', 'b', 'd'}, eval('argv()'))
+
+ execute('-argd')
+ eq({'a', 'd'}, eval('argv()'))
+
+ execute('$argd')
+ eq({'a'}, eval('argv()'))
+
+ execute('1arga c')
+ execute('1arga b')
+ execute('$argu')
+ execute('$arga x')
+ eq({'a', 'b', 'c', 'x'}, eval('argv()'))
+
+ execute('0arga Y')
+ eq({'Y', 'a', 'b', 'c', 'x'}, eval('argv()'))
+
+ execute('%argd')
+ eq({}, eval('argv()'))
+
+ execute('arga a b c d e f')
+ execute('2,$-argd')
+ eq({'a', 'f'}, eval('argv()'))
+
+ execute('let &hidden = save_hidden')
+
+ -- Setting the argument list should fail when the current buffer has
+ -- unsaved changes
+ execute('%argd')
+ execute('enew!')
+ execute('set modified')
+ assert_fails('args x y z', 'E37:')
+ execute('args! x y z')
+ eq({'x', 'y', 'z'}, eval('argv()'))
+ eq('x', eval('expand("%:t")'))
+
+ execute('%argdelete')
+ assert_fails('argument', 'E163:')
+ end)
+
+ it('test for 0argadd and 0argedit', function()
+ reset_arglist()
+
+ execute('arga a b c d')
+ execute('2argu')
+ execute('0arga added')
+ eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()'))
+
+ execute('%argd')
+ execute('arga a b c d')
+ execute('2argu')
+ execute('0arge edited')
+ eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()'))
+
+ execute('2argu')
+ execute('arga third')
+ eq({'edited', 'a', 'third', 'b', 'c', 'd'}, eval('argv()'))
+ end)
+
+ it('test for argc()', function()
+ reset_arglist()
+ eq(0, eval('argc()'))
+ execute('argadd a b')
+ eq(2, eval('argc()'))
+ end)
+
+ it('test for arglistid()', function()
+ reset_arglist()
+ execute('arga a b')
+ eq(0, eval('arglistid()'))
+ execute('split')
+ execute('arglocal')
+ eq(1, eval('arglistid()'))
+ execute('tabnew | tabfirst')
+ eq(0, eval('arglistid(2)'))
+ eq(1, eval('arglistid(1, 1)'))
+ eq(0, eval('arglistid(2, 1)'))
+ eq(1, eval('arglistid(1, 2)'))
+ execute('tabonly | only | enew!')
+ execute('argglobal')
+ eq(0, eval('arglistid()'))
+ end)
+
+ it('test for argv()', function()
+ reset_arglist()
+ eq({}, eval('argv()'))
+ eq('', eval('argv(2)'))
+ execute('argadd a b c d')
+ eq('c', eval('argv(2)'))
+ end)
+
+ it('test for :argedit command', function()
+ reset_arglist()
+ execute('argedit a')
+ eq({'a'}, eval('argv()'))
+ eq('a', eval('expand("%:t")'))
+ execute('argedit b')
+ eq({'a', 'b'}, eval('argv()'))
+ eq('b', eval('expand("%:t")'))
+ execute('argedit a')
+ eq({'a', 'b'}, eval('argv()'))
+ eq('a', eval('expand("%:t")'))
+ assert_fails('argedit a b', 'E172:')
+ execute('argedit c')
+ eq({'a', 'c', 'b'}, eval('argv()'))
+ execute('0argedit x')
+ eq({'x', 'a', 'c', 'b'}, eval('argv()'))
+ execute('enew! | set modified')
+ assert_fails('argedit y', 'E37:')
+ execute('argedit! y')
+ eq({'x', 'y', 'a', 'c', 'b'}, eval('argv()'))
+ execute('%argd')
+ end)
+
+ it('test for :argdelete command', function()
+ reset_arglist()
+ execute('args aa a aaa b bb')
+ execute('argdelete a*')
+ eq({'b', 'bb'}, eval('argv()'))
+ eq('aa', eval('expand("%:t")'))
+ execute('last')
+ execute('argdelete %')
+ eq({'b'}, eval('argv()'))
+ assert_fails('argdelete', 'E471:')
+ assert_fails('1,100argdelete', 'E16:')
+ execute('%argd')
+ end)
+
+ it('test for the :next, :prev, :first, :last, :rewind commands', function()
+ reset_arglist()
+ execute('args a b c d')
+ execute('last')
+ eq(3, eval('argidx()'))
+ assert_fails('next', 'E165:')
+ execute('prev')
+ eq(2, eval('argidx()'))
+ execute('Next')
+ eq(1, eval('argidx()'))
+ execute('first')
+ eq(0, eval('argidx()'))
+ assert_fails('prev', 'E164:')
+ execute('3next')
+ eq(3, eval('argidx()'))
+ execute('rewind')
+ eq(0, eval('argidx()'))
+ execute('%argd')
+ end)
+end)
diff --git a/test/functional/legacy/argument_0count_spec.lua b/test/functional/legacy/argument_0count_spec.lua
deleted file mode 100644
index 6e8b60547b..0000000000
--- a/test/functional/legacy/argument_0count_spec.lua
+++ /dev/null
@@ -1,28 +0,0 @@
--- Tests for :0argadd and :0argedit
-
-local helpers = require('test.functional.helpers')
-local eq, eval, clear, execute =
- helpers.eq, helpers.eval, helpers.clear, helpers.execute
-
-describe('argument_0count', function()
- setup(clear)
-
- it('is working', function()
- execute('arga a b c d')
- eq({'a', 'b', 'c', 'd'}, eval('argv()'))
- execute('2argu')
- execute('0arga added')
- eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()'))
- execute('2argu')
- execute('arga third')
- eq({'added', 'a', 'third', 'b', 'c', 'd'}, eval('argv()'))
- execute('%argd')
- execute('arga a b c d')
- execute('2argu')
- execute('0arge edited')
- eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()'))
- execute('2argu')
- execute('arga third')
- eq({'edited', 'a', 'third', 'b', 'c', 'd'}, eval('argv()'))
- end)
-end)
diff --git a/test/functional/legacy/argument_count_spec.lua b/test/functional/legacy/argument_count_spec.lua
deleted file mode 100644
index 182cce9475..0000000000
--- a/test/functional/legacy/argument_count_spec.lua
+++ /dev/null
@@ -1,47 +0,0 @@
--- Tests for :[count]argument! and :[count]argdelete
-
-local helpers = require('test.functional.helpers')
-local clear, execute, eq, eval =
- helpers.clear, helpers.execute, helpers.eq, helpers.eval
-
-describe('argument_count', function()
- setup(clear)
-
- it('is working', function()
- execute('%argd')
- execute('argadd a b c d')
- eq({'a', 'b', 'c', 'd'}, eval('argv()'))
- execute('set hidden')
- execute('let buffers = []')
- execute('augroup TEST')
- execute([[au BufEnter * call add(buffers, expand('%:t'))]])
- execute('augroup END')
- execute('$argu')
- execute('$-argu')
- execute('-argu')
- execute('1argu')
- execute('+2argu')
- execute('augroup TEST')
- execute('au!')
- execute('augroup END')
- eq({'d', 'c', 'b', 'a', 'c'}, eval('buffers'))
- execute('.argd')
- eq({'a', 'b', 'd'}, eval('argv()'))
- execute('-argd')
- eq({'a', 'd'}, eval('argv()'))
- execute('$argd')
- eq({'a'}, eval('argv()'))
- execute('1arga c')
- execute('1arga b')
- execute('$argu')
- execute('$arga x')
- eq({'a', 'b', 'c', 'x'}, eval('argv()'))
- execute('0arga Y')
- eq({'Y', 'a', 'b', 'c', 'x'}, eval('argv()'))
- execute('%argd')
- eq({}, eval('argv()'))
- execute('arga a b c d e f')
- execute('2,$-argd')
- eq({'a', 'f'}, eval('argv()'))
- end)
-end)
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua
index 1ce665360d..8a042be7f7 100644
--- a/test/functional/legacy/assert_spec.lua
+++ b/test/functional/legacy/assert_spec.lua
@@ -1,7 +1,8 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local nvim, call = helpers.meths, helpers.call
local clear, eq = helpers.clear, helpers.eq
local source, execute = helpers.source, helpers.execute
+local exc_exec = helpers.exc_exec
local function expected_errors(errors)
eq(errors, nvim.get_vvar('errors'))
@@ -62,6 +63,34 @@ describe('assert function:', function()
call('assert_equal', 'true', 'false')
expected_errors({"Expected 'true' but got 'false'"})
end)
+
+ it('should change v:errors when expected is not equal to actual', function()
+ source([[
+ function CheckAssert()
+ let s:v = {}
+ let s:x = {"a": s:v}
+ let s:v["b"] = s:x
+ let s:w = {"c": s:x, "d": ''}
+ call assert_equal(s:w, '')
+ endfunction
+ ]])
+ eq('Vim(call):E724: unable to correctly dump variable with self-referencing container',
+ exc_exec('call CheckAssert()'))
+ end)
+ end)
+
+ -- assert_notequal({expected}, {actual}[, {msg}])
+ describe('assert_notequal', function()
+ it('should not change v:errors when expected differs from actual', function()
+ call('assert_notequal', 'foo', 4)
+ call('assert_notequal', {1, 2, 3}, 'foo')
+ expected_empty()
+ end)
+
+ it('should change v:errors when expected is equal to actual', function()
+ call('assert_notequal', 'foo', 'foo')
+ expected_errors({"Expected 'foo' differs from 'foo'"})
+ end)
end)
-- assert_false({actual}, [, {msg}])
@@ -141,5 +170,98 @@ describe('assert function:', function()
tmpname_two .. " line 1: 'file two'",
})
end)
+
+ it('is reset to a list by assert functions', function()
+ source([[
+ let save_verrors = v:errors
+ let v:['errors'] = {'foo': 3}
+ call assert_equal('yes', 'no')
+ let verrors = v:errors
+ let v:errors = save_verrors
+ call assert_equal(type([]), type(verrors))
+ ]])
+ expected_empty()
+ end)
+ end)
+
+ -- assert_match({pat}, {text}[, {msg}])
+ describe('assert_match', function()
+ it('should not change v:errors when pat matches text', function()
+ call('assert_match', '^f.*b.*r$', 'foobar')
+ expected_empty()
+ end)
+
+ it('should change v:errors when pat does not match text', function()
+ call('assert_match', 'bar.*foo', 'foobar')
+ expected_errors({"Pattern 'bar.*foo' does not match 'foobar'"})
+ end)
+
+ it('should set v:errors to msg when given and match fails', function()
+ call('assert_match', 'bar.*foo', 'foobar', 'wrong')
+ expected_errors({"'wrong'"})
+ end)
+ end)
+
+ -- assert_notmatch({pat}, {text}[, {msg}])
+ describe('assert_notmatch', function()
+ it('should not change v:errors when pat does not match text', function()
+ call('assert_notmatch', 'foo', 'bar')
+ call('assert_notmatch', '^foobar$', 'foobars')
+ expected_empty()
+ end)
+
+ it('should change v:errors when pat matches text', function()
+ call('assert_notmatch', 'foo', 'foobar')
+ expected_errors({"Pattern 'foo' does match 'foobar'"})
+ end)
+ end)
+
+ -- assert_fails({cmd}, [, {error}])
+ describe('assert_fails', function()
+ it('should change v:errors when error does not match v:errmsg', function()
+ execute([[call assert_fails('xxx', {})]])
+ execute([[call assert_match("Expected {} but got 'E731:", v:errors[0])]])
+ expected_errors({"Expected {} but got 'E731: using Dictionary as a String'"})
+ end)
+
+ it('should not change v:errors when cmd errors', function()
+ call('assert_fails', 'NonexistentCmd')
+ expected_empty()
+ end)
+
+ it('should change v:errors when cmd succeeds', function()
+ call('assert_fails', 'call empty("")')
+ expected_errors({'command did not fail: call empty("")'})
+ end)
+ end)
+
+ -- assert_exception({cmd}, [, {error}])
+ describe('assert_exception()', function()
+ it('should assert thrown exceptions properly', function()
+ source([[
+ try
+ nocommand
+ catch
+ call assert_exception('E492')
+ endtry
+ ]])
+ expected_empty()
+ end)
+
+ it('should work properly when nested', function()
+ source([[
+ try
+ nocommand
+ catch
+ try
+ " illegal argument, get NULL for error
+ call assert_exception([])
+ catch
+ call assert_exception('E730')
+ endtry
+ endtry
+ ]])
+ expected_empty()
+ end)
end)
end)
diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua
new file mode 100644
index 0000000000..06f7c1dd11
--- /dev/null
+++ b/test/functional/legacy/autochdir_spec.lua
@@ -0,0 +1,26 @@
+local lfs = require('lfs')
+local helpers = require('test.functional.helpers')(after_each)
+local clear, eq = helpers.clear, helpers.eq
+local eval, execute = helpers.eval, helpers.execute
+
+describe('autochdir behavior', function()
+ local dir = 'Xtest-functional-legacy-autochdir'
+
+ before_each(function()
+ lfs.mkdir(dir)
+ clear()
+ end)
+
+ after_each(function()
+ helpers.rmdir(dir)
+ end)
+
+ -- Tests vim/vim/777 without test_autochdir().
+ it('sets filename', function()
+ execute('set acd')
+ execute('new')
+ execute('w '..dir..'/Xtest')
+ eq('Xtest', eval("expand('%')"))
+ eq(dir, eval([[substitute(getcwd(), '.*[/\\]\(\k*\)', '\1', '')]]))
+ end)
+end)
diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua
index 6349371808..28037e17c5 100644
--- a/test/functional/legacy/autocmd_option_spec.lua
+++ b/test/functional/legacy/autocmd_option_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local nvim = helpers.meths
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
local curbuf, buf = helpers.curbuf, helpers.bufmeths
diff --git a/test/functional/legacy/autoformat_join_spec.lua b/test/functional/legacy/autoformat_join_spec.lua
index a99cabca24..4110d66f5b 100644
--- a/test/functional/legacy/autoformat_join_spec.lua
+++ b/test/functional/legacy/autoformat_join_spec.lua
@@ -1,7 +1,7 @@
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Tests for setting the '[,'] marks when joining lines.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/backspace_opt_spec.lua b/test/functional/legacy/backspace_opt_spec.lua
index b40019a410..90bc6f74f0 100644
--- a/test/functional/legacy/backspace_opt_spec.lua
+++ b/test/functional/legacy/backspace_opt_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local call, clear = helpers.call, helpers.clear
local source, eq, nvim = helpers.source, helpers.eq, helpers.meths
diff --git a/test/functional/legacy/breakindent_spec.lua b/test/functional/legacy/breakindent_spec.lua
index a12d4add10..2504fe8e51 100644
--- a/test/functional/legacy/breakindent_spec.lua
+++ b/test/functional/legacy/breakindent_spec.lua
@@ -1,6 +1,6 @@
-- Test for breakindent
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/cdo_spec.lua b/test/functional/legacy/cdo_spec.lua
index 4b313ede3f..5e46431cc1 100644
--- a/test/functional/legacy/cdo_spec.lua
+++ b/test/functional/legacy/cdo_spec.lua
@@ -1,6 +1,6 @@
-- Tests for the :cdo, :cfdo, :ldo and :lfdo commands
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local nvim, clear = helpers.meths, helpers.clear
local call, feed = helpers.call, helpers.feed
local source, eq = helpers.source, helpers.eq
diff --git a/test/functional/legacy/changelist_spec.lua b/test/functional/legacy/changelist_spec.lua
index 7c696369d4..c718da3736 100644
--- a/test/functional/legacy/changelist_spec.lua
+++ b/test/functional/legacy/changelist_spec.lua
@@ -1,7 +1,7 @@
-- Test changelist position after splitting window
-- Set 'undolevels' to make changelist for sourced file
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/charsearch_spec.lua b/test/functional/legacy/charsearch_spec.lua
index 4a83801cfc..ef3369728d 100644
--- a/test/functional/legacy/charsearch_spec.lua
+++ b/test/functional/legacy/charsearch_spec.lua
@@ -1,6 +1,6 @@
-- Test for character searches
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/close_count_spec.lua b/test/functional/legacy/close_count_spec.lua
index ee6b29c618..ad1812f22e 100644
--- a/test/functional/legacy/close_count_spec.lua
+++ b/test/functional/legacy/close_count_spec.lua
@@ -1,6 +1,6 @@
-- Tests for :[count]close! and :[count]hide
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, eval, eq, clear, execute =
helpers.feed, helpers.eval, helpers.eq, helpers.clear, helpers.execute
diff --git a/test/functional/legacy/command_count_spec.lua b/test/functional/legacy/command_count_spec.lua
index d9b4f09263..c463ada968 100644
--- a/test/functional/legacy/command_count_spec.lua
+++ b/test/functional/legacy/command_count_spec.lua
@@ -1,25 +1,20 @@
-- Test for user command counts
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, source, expect = helpers.clear, helpers.source, helpers.expect
-local execute, spawn = helpers.execute, helpers.spawn
-local nvim_prog = helpers.nvim_prog
+local execute = helpers.execute
describe('command_count', function()
- setup(clear)
- teardown(function()
- os.remove('test.out')
- end)
-
it('is working', function()
-- It is relevant for the test to load a file initially. If this is
-- emulated with :arg the buffer count is wrong as nvim creates an empty
-- buffer if it was started without a filename.
- local nvim2 = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
- 'test_command_count.in'})
- helpers.set_session(nvim2)
+ clear('test_command_count.in')
source([[
+ let g:tmpname = tempname()
+ call mkdir(g:tmpname)
+ execute "cd ".g:tmpname
lang C
let g:lines = []
com -range=% RangeLines
@@ -239,5 +234,10 @@ describe('command_count', function()
bufdo: 2 3 4 5 6 7 8 9 10 15
bufdo: 4 5 6 7
tabdo: 2 3 4]])
+
+ source([[
+ cd ..
+ call delete(g:tmpname, 'rf')
+ ]])
end)
end)
diff --git a/test/functional/legacy/comparators_spec.lua b/test/functional/legacy/comparators_spec.lua
index e3fa3eea23..27879b0f65 100644
--- a/test/functional/legacy/comparators_spec.lua
+++ b/test/functional/legacy/comparators_spec.lua
@@ -1,6 +1,6 @@
-- " Test for expression comparators.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, eq = helpers.clear, helpers.eq
local eval, execute = helpers.eval, helpers.execute
diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua
index cd18a8f750..cd19e31a79 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')
+local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
local eq, eval, execute = helpers.eq, helpers.eval, helpers.execute
+if helpers.pending_win32(pending) then return end
+
describe('Test for delete()', function()
before_each(clear)
diff --git a/test/functional/legacy/erasebackword_spec.lua b/test/functional/legacy/erasebackword_spec.lua
index cb3967b763..33b7704b65 100644
--- a/test/functional/legacy/erasebackword_spec.lua
+++ b/test/functional/legacy/erasebackword_spec.lua
@@ -1,6 +1,6 @@
-- Test for CTRL-W in Insert mode
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, expect = helpers.clear, helpers.feed, helpers.expect
describe('CTRL-W in Insert mode', function()
diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua
index 3ff1092a4b..3684fe714d 100644
--- a/test/functional/legacy/eval_spec.lua
+++ b/test/functional/legacy/eval_spec.lua
@@ -1,15 +1,10 @@
-- Test for various eval features.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
local eq, eval, write_file = helpers.eq, helpers.eval, helpers.write_file
-local function has_clipboard()
- clear()
- return 1 == eval("has('clipboard')")
-end
-
describe('eval', function()
setup(function()
write_file('test_eval_setup.vim', [[
@@ -539,8 +534,13 @@ describe('eval', function()
=: type v; value: abc/]].."\000 (['abc/\000"..[[']), expr: "abc/]]..'\000'..[[" (['"abc/]]..'\000'..[["'])]])
end)
- if has_clipboard() then
- it('system clipboard', function()
+ describe('system clipboard', function()
+ before_each(function()
+ execute('let &runtimepath = "test/functional/fixtures,".&runtimepath')
+ execute('call getreg("*")') -- force load of provider
+ end)
+
+ it('works', function()
insert([[
Some first line (this text was at the top of the old test_eval.in).
@@ -570,9 +570,7 @@ describe('eval', function()
*: type V; value: clipboard contents]]..'\00'..[[ (['clipboard contents']), expr: clipboard contents]]..'\00'..[[ (['clipboard contents'])
*: type V; value: something else]]..'\00'..[[ (['something else']), expr: something else]]..'\00'..[[ (['something else'])]])
end)
- else
- pending('system clipboard not available', function() end)
- end
+ end)
it('errors', function()
source([[
diff --git a/test/functional/legacy/expand_spec.lua b/test/functional/legacy/expand_spec.lua
new file mode 100644
index 0000000000..7bf6fb67dc
--- /dev/null
+++ b/test/functional/legacy/expand_spec.lua
@@ -0,0 +1,77 @@
+-- Test for expanding file names
+
+local helpers = require('test.functional.helpers')(after_each)
+local eq = helpers.eq
+local call = helpers.call
+local nvim = helpers.meths
+local clear = helpers.clear
+local source = helpers.source
+
+local function expected_empty()
+ eq({}, nvim.get_vvar('errors'))
+end
+
+describe('expand file name', function()
+ after_each(function()
+ helpers.rmdir('Xdir1')
+ helpers.rmdir('Xdir2')
+ helpers.rmdir('Xdir3')
+ helpers.rmdir('Xdir4')
+ end)
+
+ before_each(function()
+ clear()
+
+ source([[
+ func Test_with_directories()
+ call mkdir('Xdir1')
+ call mkdir('Xdir2')
+ call mkdir('Xdir3')
+ cd Xdir3
+ call mkdir('Xdir4')
+ cd ..
+
+ split Xdir1/file
+ call setline(1, ['a', 'b'])
+ w
+ w Xdir3/Xdir4/file
+ close
+
+ next Xdir?/*/file
+ call assert_equal('Xdir3/Xdir4/file', expand('%'))
+ if has('unix')
+ next! Xdir?/*/nofile
+ call assert_equal('Xdir?/*/nofile', expand('%'))
+ endif
+ " Edit another file, on MS-Windows the swap file would be in use and can't
+ " be deleted
+ edit foo
+
+ call assert_equal(0, delete('Xdir1', 'rf'))
+ call assert_equal(0, delete('Xdir2', 'rf'))
+ call assert_equal(0, delete('Xdir3', 'rf'))
+ endfunc
+
+ func Test_with_tilde()
+ let dir = getcwd()
+ call mkdir('Xdir ~ dir')
+ call assert_true(isdirectory('Xdir ~ dir'))
+ cd Xdir\ ~\ dir
+ call assert_true(getcwd() =~ 'Xdir \~ dir')
+ exe 'cd ' . fnameescape(dir)
+ call delete('Xdir ~ dir', 'd')
+ call assert_false(isdirectory('Xdir ~ dir'))
+ endfunc
+ ]])
+ end)
+
+ it('works with directories', function()
+ call('Test_with_directories')
+ expected_empty()
+ end)
+
+ it('works with tilde', function()
+ call('Test_with_tilde')
+ expected_empty()
+ end)
+end)
diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua
index cabeecdc9c..77e82352c5 100644
--- a/test/functional/legacy/file_perm_spec.lua
+++ b/test/functional/legacy/file_perm_spec.lua
@@ -1,12 +1,12 @@
-- Test getting and setting file permissions.
require('os')
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, call, eq = helpers.clear, helpers.call, helpers.eq
local neq, exc_exec = helpers.neq, helpers.exc_exec
describe('Test getting and setting file permissions', function()
- local tempfile = os.tmpname()
+ local tempfile = helpers.tmpname()
before_each(function()
os.remove(tempfile)
@@ -21,7 +21,7 @@ describe('Test getting and setting file permissions', function()
eq(9, call('len', call('getfperm', tempfile)))
eq(1, call('setfperm', tempfile, 'rwx------'))
- if helpers.os_name == 'windows' then
+ if helpers.os_name() == 'windows' then
eq('rw-rw-rw-', call('getfperm', tempfile))
else
eq('rwx------', call('getfperm', tempfile))
diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua
index 2d1824c8cd..1e9e832536 100644
--- a/test/functional/legacy/fixeol_spec.lua
+++ b/test/functional/legacy/fixeol_spec.lua
@@ -1,9 +1,11 @@
-- Tests for 'fixeol'
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+if helpers.pending_win32(pending) then return end
+
describe('fixeol', function()
local function rmtestfiles()
os.remove('test.out')
diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua
index 2a32aea127..d8ecbfe058 100644
--- a/test/functional/legacy/fnamemodify_spec.lua
+++ b/test/functional/legacy/fnamemodify_spec.lua
@@ -1,9 +1,11 @@
-- Test filename modifiers.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
+if helpers.pending_win32(pending) then return end
+
local function expected_empty()
eq({}, nvim.get_vvar('errors'))
end
diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua
index 9083911021..1b65f1ce95 100644
--- a/test/functional/legacy/function_sort_spec.lua
+++ b/test/functional/legacy/function_sort_spec.lua
@@ -1,7 +1,10 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
+local execute = helpers.execute
+local exc_exec = helpers.exc_exec
+local neq = helpers.neq
describe('sort', function()
before_each(clear)
@@ -26,4 +29,25 @@ describe('sort', function()
it('numbers compared as float', function()
eq({0.28, 3, 13.5}, eval("sort([13.5, 0.28, 3], 'f')"))
end)
+
+ it('ability to call sort() from a compare function', function()
+ execute('func Compare1(a, b) abort')
+ execute([[call sort(range(3), 'Compare2')]])
+ execute('return a:a - a:b')
+ execute('endfunc')
+
+ execute('func Compare2(a, b) abort')
+ execute('return a:a - a:b')
+ execute('endfunc')
+ eq({1, 3, 5}, eval("sort([3, 1, 5], 'Compare1')"))
+ end)
+
+ it('default sort', function()
+ -- docs say omitted, empty or zero argument sorts on string representation
+ eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"])'))
+ eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval([[sort([3.3, 1, "2", "A", "a", "AA"], '')]]))
+ eq({'2', 'A', 'AA', 'a', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 0)'))
+ eq({'2', 'A', 'a', 'AA', 1, 3.3}, eval('sort([3.3, 1, "2", "A", "a", "AA"], 1)'))
+ neq(exc_exec('call sort([3.3, 1, "2"], 3)'):find('E474:'), nil)
+ end)
end)
diff --git a/test/functional/legacy/getcwd_spec.lua b/test/functional/legacy/getcwd_spec.lua
new file mode 100644
index 0000000000..dcb56eb242
--- /dev/null
+++ b/test/functional/legacy/getcwd_spec.lua
@@ -0,0 +1,88 @@
+-- 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, execute = helpers.call, helpers.clear, helpers.execute
+
+if helpers.pending_win32(pending) then return end
+
+describe('getcwd', function()
+ before_each(clear)
+
+ after_each(function()
+ helpers.rmdir('Xtopdir')
+ end)
+
+ it('is working', function()
+ source([[
+ function! GetCwdInfo(win, tab)
+ let tab_changed = 0
+ let mod = ":t"
+ if a:tab > 0 && a:tab != tabpagenr()
+ let tab_changed = 1
+ exec "tabnext " . a:tab
+ endif
+ let bufname = fnamemodify(bufname(winbufnr(a:win)), mod)
+ if tab_changed
+ tabprevious
+ endif
+ if a:win == 0 && a:tab == 0
+ let dirname = fnamemodify(getcwd(), mod)
+ let lflag = haslocaldir()
+ elseif a:tab == 0
+ let dirname = fnamemodify(getcwd(a:win), mod)
+ let lflag = haslocaldir(a:win)
+ else
+ let dirname = fnamemodify(getcwd(a:win, a:tab), mod)
+ let lflag = haslocaldir(a:win, a:tab)
+ endif
+ return bufname . ' ' . dirname . ' ' . lflag
+ endfunction
+ ]])
+ execute('new')
+ execute('let cwd=getcwd()')
+ call('mkdir', 'Xtopdir')
+ execute('silent cd Xtopdir')
+ call('mkdir', 'Xdir1')
+ call('mkdir', 'Xdir2')
+ call('mkdir', 'Xdir3')
+ execute('new a')
+ execute('new b')
+ execute('new c')
+ execute('3wincmd w')
+ execute('silent lcd Xdir1')
+ eq('a Xdir1 1', eval('GetCwdInfo(0, 0)'))
+ execute('wincmd W')
+ eq('b Xtopdir 0', eval('GetCwdInfo(0, 0)'))
+ execute('wincmd W')
+ execute('silent lcd Xdir3')
+ eq('c Xdir3 1', eval('GetCwdInfo(0, 0)'))
+ eq('a Xdir1 1', eval('GetCwdInfo(bufwinnr("a"), 0)'))
+ eq('b Xtopdir 0', eval('GetCwdInfo(bufwinnr("b"), 0)'))
+ eq('c Xdir3 1', eval('GetCwdInfo(bufwinnr("c"), 0)'))
+ execute('wincmd W')
+ eq('a Xdir1 1', eval('GetCwdInfo(bufwinnr("a"), tabpagenr())'))
+ eq('b Xtopdir 0', eval('GetCwdInfo(bufwinnr("b"), tabpagenr())'))
+ eq('c Xdir3 1', eval('GetCwdInfo(bufwinnr("c"), tabpagenr())'))
+
+ execute('tabnew x')
+ execute('new y')
+ execute('new z')
+ execute('3wincmd w')
+ eq('x Xtopdir 0', eval('GetCwdInfo(0, 0)'))
+ execute('wincmd W')
+ execute('silent lcd Xdir2')
+ eq('y Xdir2 1', eval('GetCwdInfo(0, 0)'))
+ execute('wincmd W')
+ execute('silent lcd Xdir3')
+ eq('z Xdir3 1', eval('GetCwdInfo(0, 0)'))
+ eq('x Xtopdir 0', eval('GetCwdInfo(bufwinnr("x"), 0)'))
+ eq('y Xdir2 1', eval('GetCwdInfo(bufwinnr("y"), 0)'))
+ eq('z Xdir3 1', eval('GetCwdInfo(bufwinnr("z"), 0)'))
+ execute('let tp_nr = tabpagenr()')
+ execute('tabrewind')
+ eq('x Xtopdir 0', eval('GetCwdInfo(3, tp_nr)'))
+ eq('y Xdir2 1', eval('GetCwdInfo(2, tp_nr)'))
+ eq('z Xdir3 1', eval('GetCwdInfo(1, tp_nr)'))
+ end)
+end)
diff --git a/test/functional/legacy/glob2regpat_spec.lua b/test/functional/legacy/glob2regpat_spec.lua
index 0492143616..82e7e3010f 100644
--- a/test/functional/legacy/glob2regpat_spec.lua
+++ b/test/functional/legacy/glob2regpat_spec.lua
@@ -1,6 +1,6 @@
-- Tests for signs
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, execute = helpers.clear, helpers.execute
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
diff --git a/test/functional/legacy/increment_spec.lua b/test/functional/legacy/increment_spec.lua
index 4aa24c0d53..a76718ed8e 100644
--- a/test/functional/legacy/increment_spec.lua
+++ b/test/functional/legacy/increment_spec.lua
@@ -1,6 +1,6 @@
-- Tests for using Ctrl-A/Ctrl-X on visual selections
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local source, execute = helpers.source, helpers.execute
local call, clear = helpers.call, helpers.clear
local eq, nvim = helpers.eq, helpers.meths
@@ -727,6 +727,14 @@ describe('Ctrl-A/Ctrl-X on visual selections', function()
exec "norm! gg$\<C-A>"
call assert_equal("002", getline(1))
endfunc
+
+ " Test a regression of patch 7.4.1087 fixed.
+ func Test_normal_increment_02()
+ call setline(1, ["hello 10", "world"])
+ exec "norm! ggl\<C-A>jx"
+ call assert_equal(["hello 11", "worl"], getline(1, '$'))
+ call assert_equal([0, 2, 4, 0], getpos('.'))
+ endfunc
]=])
end)
@@ -745,4 +753,9 @@ describe('Ctrl-A/Ctrl-X on visual selections', function()
call('Test_normal_increment_01')
eq({}, nvim.get_vvar('errors'))
end)
+
+ it('maintains correct column after CTRL-A', function()
+ call('Test_normal_increment_02')
+ eq({}, nvim.get_vvar('errors'))
+ end)
end)
diff --git a/test/functional/legacy/insertcount_spec.lua b/test/functional/legacy/insertcount_spec.lua
index 01236e1afe..3142f040b3 100644
--- a/test/functional/legacy/insertcount_spec.lua
+++ b/test/functional/legacy/insertcount_spec.lua
@@ -1,6 +1,6 @@
-- Tests for repeating insert and replace.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
diff --git a/test/functional/legacy/join_spec.lua b/test/functional/legacy/join_spec.lua
index 17ff2e71ad..3c4da8119c 100644
--- a/test/functional/legacy/join_spec.lua
+++ b/test/functional/legacy/join_spec.lua
@@ -1,6 +1,6 @@
-- Test for joining lines
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, eq = helpers.clear, helpers.eq
local eval, execute = helpers.eval, helpers.execute
diff --git a/test/functional/legacy/lispwords_spec.lua b/test/functional/legacy/lispwords_spec.lua
index 48df4de55e..2ec51dca1b 100644
--- a/test/functional/legacy/lispwords_spec.lua
+++ b/test/functional/legacy/lispwords_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
diff --git a/test/functional/legacy/listchars_spec.lua b/test/functional/legacy/listchars_spec.lua
index 89ed90178b..d2838cddb6 100644
--- a/test/functional/legacy/listchars_spec.lua
+++ b/test/functional/legacy/listchars_spec.lua
@@ -1,6 +1,6 @@
-- Tests for 'listchars' display with 'list' and :list.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/listlbr_spec.lua b/test/functional/legacy/listlbr_spec.lua
new file mode 100644
index 0000000000..eb979edc69
--- /dev/null
+++ b/test/functional/legacy/listlbr_spec.lua
@@ -0,0 +1,195 @@
+-- Test for linebreak and list option (non-utf8)
+
+local helpers = require('test.functional.helpers')(after_each)
+local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('listlbr', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ dummy text]])
+
+ execute('set wildchar=^E')
+ execute('10new')
+ execute('vsp')
+ execute('vert resize 20')
+ execute([[put =\"\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP \"]])
+ execute('norm! zt')
+ execute('set ts=4 sw=4 sts=4 linebreak sbr=+ wrap')
+ source([[
+ fu! ScreenChar(width)
+ let c=''
+ for j in range(1,4)
+ for i in range(1,a:width)
+ let c.=nr2char(screenchar(j, i))
+ endfor
+ let c.="\n"
+ endfor
+ return c
+ endfu
+ fu! DoRecordScreen()
+ wincmd l
+ $put =printf(\"\n%s\", g:test)
+ $put =g:line
+ wincmd p
+ endfu
+ ]])
+ execute('let g:test="Test 1: set linebreak"')
+ execute('redraw!')
+ execute('let line=ScreenChar(winwidth(0))')
+ execute('call DoRecordScreen()')
+
+ execute('let g:test="Test 2: set linebreak + set list"')
+ execute('set linebreak list listchars=')
+ execute('redraw!')
+ execute('let line=ScreenChar(winwidth(0))')
+ execute('call DoRecordScreen()')
+
+ execute('let g:test ="Test 3: set linebreak nolist"')
+ execute('set nolist linebreak')
+ execute('redraw!')
+ execute('let line=ScreenChar(winwidth(0))')
+ execute('call DoRecordScreen()')
+
+ execute('let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"')
+ execute('set nolist linebreak ts=8')
+ execute([[let line="1\t".repeat('a', winwidth(0)-2)]])
+ execute('$put =line')
+ execute('$')
+ execute('norm! zt')
+ execute('redraw!')
+ execute('let line=ScreenChar(winwidth(0))')
+ execute('call DoRecordScreen()')
+ execute([[let line="_S_\t bla"]])
+ execute('$put =line')
+ execute('$')
+ execute('norm! zt')
+
+ execute('let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"')
+ execute('set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab')
+ execute('syn match ConcealVar contained /_/ conceal')
+ execute('syn match All /.*/ contains=ConcealVar')
+ execute('let line=ScreenChar(winwidth(0))')
+ execute('call DoRecordScreen()')
+ execute('set cpo&vim linebreak')
+
+ execute('let g:test ="Test 6: set linebreak with visual block mode"')
+ execute('let line="REMOVE: this not"')
+ execute('$put =g:test')
+ execute('$put =line')
+ execute('let line="REMOVE: aaaaaaaaaaaaa"')
+ execute('$put =line')
+ execute('1/^REMOVE:')
+ feed('0<C-V>jf x')
+ execute('$put')
+ execute('set cpo&vim linebreak')
+
+ execute('let g:test ="Test 7: set linebreak with visual block mode and v_b_A"')
+ execute('$put =g:test')
+ feed('Golong line: <esc>40afoobar <esc>aTARGET at end<esc>')
+ execute([[exe "norm! $3B\<C-v>eAx\<Esc>"]])
+ execute('set cpo&vim linebreak sbr=')
+
+ execute('let g:test ="Test 8: set linebreak with visual char mode and changing block"')
+ execute('$put =g:test')
+ feed('Go1111-1111-1111-11-1111-1111-1111<esc>0f-lv3lc2222<esc>bgj.')
+
+ execute('let g:test ="Test 9: using redo after block visual mode"')
+ execute('$put =g:test')
+ feed('Go<CR>')
+ feed('aaa<CR>')
+ feed('aaa<CR>')
+ feed('a<ESC>2k<C-V>2j~e.<CR>')
+
+ execute('let g:test ="Test 10: using normal commands after block-visual"')
+ execute('$put =g:test')
+ execute('set linebreak')
+ feed('Go<cr>')
+ feed('abcd{ef<cr>')
+ feed('ghijklm<cr>')
+ feed('no}pqrs<esc>2k0f{<C-V><C-V>c%<esc>')
+
+ execute('let g:test ="Test 11: using block replace mode after wrapping"')
+ execute('$put =g:test')
+ execute('set linebreak wrap')
+ feed('Go<esc>150aa<esc>yypk147|<C-V>jr0<cr>')
+
+ execute('let g:test ="Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$"')
+ execute('set list listchars=space:_,trail:-,tab:>-,eol:$')
+ execute('$put =g:test')
+ execute([[let line="a aaaaaaaaaaaaaaaaaaaaaa\ta "]])
+ execute('$put =line')
+ execute('$')
+ execute('norm! zt')
+ execute('redraw!')
+ execute('let line=ScreenChar(winwidth(0))')
+ execute('call DoRecordScreen()')
+
+ -- Assert buffer contents.
+ expect([[
+
+ abcdef hijklmn pqrstuvwxyz_1060ABCDEFGHIJKLMNOP
+
+ Test 1: set linebreak
+ abcdef
+ +hijklmn
+ +pqrstuvwxyz_1060ABC
+ +DEFGHIJKLMNOP
+
+ Test 2: set linebreak + set list
+ ^Iabcdef hijklmn^I
+ +pqrstuvwxyz_1060ABC
+ +DEFGHIJKLMNOP
+
+
+ Test 3: set linebreak nolist
+ abcdef
+ +hijklmn
+ +pqrstuvwxyz_1060ABC
+ +DEFGHIJKLMNOP
+ 1 aaaaaaaaaaaaaaaaaa
+
+ Test 4: set linebreak with tab and 1 line as long as screen: should break!
+ 1
+ +aaaaaaaaaaaaaaaaaa
+ ~
+ ~
+ _S_ bla
+
+ Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)
+ Sabbbbbb bla
+ ~
+ ~
+ ~
+ Test 6: set linebreak with visual block mode
+ this not
+ aaaaaaaaaaaaa
+ REMOVE:
+ REMOVE:
+ Test 7: set linebreak with visual block mode and v_b_A
+ long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETx at end
+ Test 8: set linebreak with visual char mode and changing block
+ 1111-2222-1111-11-1111-2222-1111
+ Test 9: using redo after block visual mode
+
+ AaA
+ AaA
+ A
+ Test 10: using normal commands after block-visual
+
+ abcdpqrs
+ Test 11: using block replace mode after wrapping
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
+ Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
+ a aaaaaaaaaaaaaaaaaaaaaa a
+
+ Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
+ a_
+ aaaaaaaaaaaaaaaaaaaa
+ aa>-----a-$
+ ~ ]])
+ end)
+end)
diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua
index df0e817533..f06bca72ba 100644
--- a/test/functional/legacy/listlbr_utf8_spec.lua
+++ b/test/functional/legacy/listlbr_utf8_spec.lua
@@ -1,6 +1,6 @@
-- Test for linebreak and list option in utf-8 mode
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local source = helpers.source
local feed = helpers.feed
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua
index a0d19926cb..1712219d04 100644
--- a/test/functional/legacy/mapping_spec.lua
+++ b/test/functional/legacy/mapping_spec.lua
@@ -1,6 +1,6 @@
-- Test for mappings and abbreviations
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect, wait = helpers.execute, helpers.expect, helpers.wait
diff --git a/test/functional/legacy/marks_spec.lua b/test/functional/legacy/marks_spec.lua
index 8e9ceb1653..6ecba70f08 100644
--- a/test/functional/legacy/marks_spec.lua
+++ b/test/functional/legacy/marks_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/match_conceal_spec.lua b/test/functional/legacy/match_conceal_spec.lua
deleted file mode 100644
index 0ffa3cae7a..0000000000
--- a/test/functional/legacy/match_conceal_spec.lua
+++ /dev/null
@@ -1,228 +0,0 @@
--- Test for matchadd() and conceal feature
-
-local helpers = require('test.functional.helpers')
-local clear = helpers.clear
-local expect = helpers.expect
-local source = helpers.source
-
-describe('match_conceal', function()
- before_each(function()
- clear()
-
- source([[
- set wildchar=^E
- 10new
- vsp
- vert resize 20
- put =\"\#\ This\ is\ a\ Test\"
- norm! mazt
-
- fu! ScreenChar(width, lines)
- let c=''
- for j in range(1,a:lines)
- for i in range(1,a:width)
- let c.=nr2char(screenchar(j, i))
- endfor
- let c.="\n"
- endfor
- return c
- endfu
-
- fu! ScreenAttr(line, pos, eval)
- let g:attr=[]
- for col in a:pos
- call add(g:attr, screenattr(a:line,col))
- endfor
- " In case all values are zero, probably the terminal
- " isn't set correctly, so catch that case
- let null = (eval(join(g:attr, '+')) == 0)
- let str=substitute(a:eval, '\d\+', 'g:attr[&]', 'g')
- if null || eval(str)
- let g:attr_test="OK: ". str
- else
- let g:attr_test="FAILED: ".str
- let g:attr_test.="\n". join(g:attr, ' ')
- let g:attr_test.="\n TERM: ". &term
- endif
- endfu
-
- fu! DoRecordScreen()
- wincmd l
- $put =printf(\"\n%s\", g:test)
- $put =g:line
- $put =g:attr_test
- wincmd p
- endfu
- ]])
- end)
-
- it('is working', function()
- source([=[
- let g:test ="Test 1: simple addmatch()"
- call matchadd('Conceal', '\%2l ')
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
-
- let g:test ="Test 2: simple addmatch() and conceal (should be: #XThisXisXaXTest)"
- norm! 'azt
- call clearmatches()
- syntax on
- set concealcursor=n conceallevel=1
- call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'})
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
-
- let g:test ="Test 3: addmatch() and conceallevel=3 (should be: #ThisisaTest)"
- norm! 'azt
- set conceallevel=3
- call clearmatches()
- call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'})
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 1==2 && 1==3 && 1==4 && 0!=5")
- call DoRecordScreen()
-
- let g:test ="Test 4: more match() (should be: #Thisisa Test)"
- norm! 'azt
- call matchadd('ErrorMsg', '\%2l Test', 20, -1, {'conceal': 'X'})
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 1==2 && 0!=3 && 3==4 && 0!=5 && 3!=5")
- call DoRecordScreen()
-
- let g:test ="Test 5/1: default conceal char (should be: # This is a Test)"
- norm! 'azt
- call clearmatches()
- set conceallevel=1
- call matchadd('Conceal', '\%2l ', 10, -1, {})
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
- let g:test ="Test 5/2: default conceal char (should be: #+This+is+a+Test)"
- norm! 'azt
- set listchars=conceal:+
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
- set listchars&vi
-
- let g:test ="Test 6/1: syn and match conceal (should be: #ZThisZisZaZTest)"
- norm! 'azt
- call clearmatches()
- set conceallevel=1
- call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'})
- syn match MyConceal /\%2l / conceal containedin=ALL cchar=*
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
- let g:test ="Test 6/2: syn and match conceal (should be: #*This*is*a*Test)"
- norm! 'azt
- call clearmatches()
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
-
- let g:test ="Test 7/1: clear matches"
- norm! 'azt
- syn on
- call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'})
- let a=getmatches()
- call clearmatches()
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 0==2 && 0==3 && 0==4 && 0==5")
- call DoRecordScreen()
- $put =a
- call setmatches(a)
- norm! 'azt
- let g:test ="Test 7/2: reset match using setmatches()"
- norm! 'azt
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
-
- let g:test ="Test 8: using matchaddpos() (should be #Pis a Test"
- norm! 'azt
- call clearmatches()
- call matchaddpos('Conceal', [[2,2,6]], 10, -1, {'conceal': 'P'})
- let a=getmatches()
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1!=2 && 0==2 && 0==3 && 0!=4 && 0!=5 && 4==5")
- call DoRecordScreen()
- $put =a
-
- let g:test ="Test 9: match using multibyte conceal char (should be: #ˑThisˑisˑaˑTest)"
- norm! 'azt
- call clearmatches()
- call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"})
- redraw!
- let line=ScreenChar(winwidth(0),1)
- call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5")
- call DoRecordScreen()
- ]=])
-
- expect([=[
-
- # This is a Test
-
- Test 1: simple addmatch()
- # This is a Test
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]
-
- Test 2: simple addmatch() and conceal (should be: #XThisXisXaXTest)
- #XThisXisXaXTest
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]
-
- Test 3: addmatch() and conceallevel=3 (should be: #ThisisaTest)
- #ThisisaTest
- OK: g:attr[0]==g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]!=g:attr[5]
-
- Test 4: more match() (should be: #Thisisa Test)
- #Thisisa Test
- OK: g:attr[0]==g:attr[1] && g:attr[1]==g:attr[2] && g:attr[0]!=g:attr[3] && g:attr[3]==g:attr[4] && g:attr[0]!=g:attr[5] && g:attr[3]!=g:attr[5]
-
- Test 5/1: default conceal char (should be: # This is a Test)
- # This is a Test
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]
-
- Test 5/2: default conceal char (should be: #+This+is+a+Test)
- #+This+is+a+Test
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]
-
- Test 6/1: syn and match conceal (should be: #ZThisZisZaZTest)
- #ZThisZisZaZTest
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]
-
- Test 6/2: syn and match conceal (should be: #*This*is*a*Test)
- #*This*is*a*Test
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]
-
- Test 7/1: clear matches
- # This is a Test
- OK: g:attr[0]==g:attr[1] && g:attr[0]==g:attr[2] && g:attr[0]==g:attr[3] && g:attr[0]==g:attr[4] && g:attr[0]==g:attr[5]
- {'group': 'Conceal', 'pattern': '\%2l ', 'priority': 10, 'id': 10, 'conceal': 'Z'}
-
- Test 7/2: reset match using setmatches()
- #ZThisZisZaZTest
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]
-
- Test 8: using matchaddpos() (should be #Pis a Test
- #Pis a Test
- OK: g:attr[0]!=g:attr[1] && g:attr[1]!=g:attr[2] && g:attr[0]==g:attr[2] && g:attr[0]==g:attr[3] && g:attr[0]!=g:attr[4] && g:attr[0]!=g:attr[5] && g:attr[4]==g:attr[5]
- {'group': 'Conceal', 'id': 11, 'priority': 10, 'pos1': [2, 2, 6], 'conceal': 'P'}
-
- Test 9: match using multibyte conceal char (should be: #ˑThisˑisˑaˑTest)
- #ˑThisˑisˑaˑTest
- OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]]=])
- end)
-end)
diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua
index fac3b03191..be9b66ee38 100644
--- a/test/functional/legacy/nested_function_spec.lua
+++ b/test/functional/legacy/nested_function_spec.lua
@@ -1,6 +1,6 @@
-- Tests for nested function.
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, insert = helpers.clear, helpers.insert
local execute, expect, source = helpers.execute, helpers.expect, helpers.source
diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua
index 21e99c4aa1..4f4d4ceaf9 100644
--- a/test/functional/legacy/options_spec.lua
+++ b/test/functional/legacy/options_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local command, clear = helpers.command, helpers.clear
local source, expect = helpers.source, helpers.expect
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
new file mode 100644
index 0000000000..2d851819e3
--- /dev/null
+++ b/test/functional/legacy/packadd_spec.lua
@@ -0,0 +1,356 @@
+-- Tests for 'packpath' and :packadd
+
+local helpers = require('test.functional.helpers')(after_each)
+local clear, source, execute = helpers.clear, helpers.source, helpers.execute
+local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
+local feed = helpers.feed
+
+local function expected_empty()
+ eq({}, nvim.get_vvar('errors'))
+end
+
+if helpers.pending_win32(pending) then return end
+
+describe('packadd', function()
+ before_each(function()
+ clear()
+
+ source([=[
+ func SetUp()
+ let s:topdir = expand('%:p:h') . '/Xdir'
+ exe 'set packpath=' . s:topdir
+ let s:plugdir = s:topdir . '/pack/mine/opt/mytest'
+ endfunc
+
+ func TearDown()
+ call delete(s:topdir, 'rf')
+ endfunc
+
+ func Test_packadd()
+ call mkdir(s:plugdir . '/plugin/also', 'p')
+ call mkdir(s:plugdir . '/ftdetect', 'p')
+ call mkdir(s:plugdir . '/after', 'p')
+ set rtp&
+ let rtp = &rtp
+ filetype on
+
+ exe 'split ' . s:plugdir . '/plugin/test.vim'
+ call setline(1, 'let g:plugin_works = 42')
+ wq
+
+ exe 'split ' . s:plugdir . '/plugin/also/loaded.vim'
+ call setline(1, 'let g:plugin_also_works = 77')
+ wq
+
+ exe 'split ' . s:plugdir . '/ftdetect/test.vim'
+ call setline(1, 'let g:ftdetect_works = 17')
+ wq
+
+ packadd mytest
+
+ call assert_true(42, g:plugin_works)
+ call assert_equal(77, g:plugin_also_works)
+ call assert_true(17, g:ftdetect_works)
+ call assert_true(len(&rtp) > len(rtp))
+ call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
+ call assert_true(&rtp =~ (s:plugdir . '/after$'))
+
+ " Check exception
+ call assert_fails("packadd directorynotfound", 'E919:')
+ call assert_fails("packadd", 'E471:')
+ endfunc
+
+ func Test_packadd_noload()
+ call mkdir(s:plugdir . '/plugin', 'p')
+ call mkdir(s:plugdir . '/syntax', 'p')
+ set rtp&
+ let rtp = &rtp
+
+ exe 'split ' . s:plugdir . '/plugin/test.vim'
+ call setline(1, 'let g:plugin_works = 42')
+ wq
+ let g:plugin_works = 0
+
+ packadd! mytest
+
+ call assert_true(len(&rtp) > len(rtp))
+ call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
+ call assert_equal(0, g:plugin_works)
+
+ " check the path is not added twice
+ let new_rtp = &rtp
+ packadd! mytest
+ call assert_equal(new_rtp, &rtp)
+ endfunc
+
+ func Test_packloadall()
+ " plugin foo with an autoload directory
+ let fooplugindir = &packpath . '/pack/mine/start/foo/plugin'
+ call mkdir(fooplugindir, 'p')
+ call writefile(['let g:plugin_foo_number = 1234',
+ \ 'let g:plugin_foo_auto = bbb#value',
+ \ 'let g:plugin_extra_auto = extra#value'], fooplugindir . '/bar.vim')
+ let fooautodir = &packpath . '/pack/mine/start/foo/autoload'
+ call mkdir(fooautodir, 'p')
+ call writefile(['let bar#value = 77'], fooautodir . '/bar.vim')
+
+ " plugin aaa with an autoload directory
+ let aaaplugindir = &packpath . '/pack/mine/start/aaa/plugin'
+ call mkdir(aaaplugindir, 'p')
+ call writefile(['let g:plugin_aaa_number = 333',
+ \ 'let g:plugin_aaa_auto = bar#value'], aaaplugindir . '/bbb.vim')
+ let aaaautodir = &packpath . '/pack/mine/start/aaa/autoload'
+ call mkdir(aaaautodir, 'p')
+ call writefile(['let bbb#value = 55'], aaaautodir . '/bbb.vim')
+
+ " plugin extra with only an autoload directory
+ let extraautodir = &packpath . '/pack/mine/start/extra/autoload'
+ call mkdir(extraautodir, 'p')
+ call writefile(['let extra#value = 99'], extraautodir . '/extra.vim')
+
+ packloadall
+ call assert_equal(1234, g:plugin_foo_number)
+ call assert_equal(55, g:plugin_foo_auto)
+ call assert_equal(99, g:plugin_extra_auto)
+ call assert_equal(333, g:plugin_aaa_number)
+ call assert_equal(77, g:plugin_aaa_auto)
+
+ " only works once
+ call writefile(['let g:plugin_bar_number = 4321'],
+ \ fooplugindir . '/bar2.vim')
+ packloadall
+ call assert_false(exists('g:plugin_bar_number'))
+
+ " works when ! used
+ packloadall!
+ call assert_equal(4321, g:plugin_bar_number)
+ endfunc
+
+ func Test_helptags()
+ let docdir1 = &packpath . '/pack/mine/start/foo/doc'
+ let docdir2 = &packpath . '/pack/mine/start/bar/doc'
+ call mkdir(docdir1, 'p')
+ call mkdir(docdir2, 'p')
+ call writefile(['look here: *look-here*'], docdir1 . '/bar.txt')
+ call writefile(['look away: *look-away*'], docdir2 . '/foo.txt')
+ exe 'set rtp=' . &packpath . '/pack/mine/start/foo,' . &packpath . '/pack/mine/start/bar'
+
+ helptags ALL
+
+ let tags1 = readfile(docdir1 . '/tags')
+ call assert_true(tags1[0] =~ 'look-here')
+ let tags2 = readfile(docdir2 . '/tags')
+ call assert_true(tags2[0] =~ 'look-away')
+ endfunc
+
+ func Test_colorscheme()
+ let colordirrun = &packpath . '/runtime/colors'
+ let colordirstart = &packpath . '/pack/mine/start/foo/colors'
+ let colordiropt = &packpath . '/pack/mine/opt/bar/colors'
+ call mkdir(colordirrun, 'p')
+ call mkdir(colordirstart, 'p')
+ call mkdir(colordiropt, 'p')
+ call writefile(['let g:found_one = 1'], colordirrun . '/one.vim')
+ call writefile(['let g:found_two = 1'], colordirstart . '/two.vim')
+ call writefile(['let g:found_three = 1'], colordiropt . '/three.vim')
+ exe 'set rtp=' . &packpath . '/runtime'
+
+ colorscheme one
+ call assert_equal(1, g:found_one)
+ colorscheme two
+ call assert_equal(1, g:found_two)
+ colorscheme three
+ call assert_equal(1, g:found_three)
+ endfunc
+
+ func Test_runtime()
+ let rundir = &packpath . '/runtime/extra'
+ let startdir = &packpath . '/pack/mine/start/foo/extra'
+ let optdir = &packpath . '/pack/mine/opt/bar/extra'
+ call mkdir(rundir, 'p')
+ call mkdir(startdir, 'p')
+ call mkdir(optdir, 'p')
+ call writefile(['let g:sequence .= "run"'], rundir . '/bar.vim')
+ call writefile(['let g:sequence .= "start"'], startdir . '/bar.vim')
+ call writefile(['let g:sequence .= "foostart"'], startdir . '/foo.vim')
+ call writefile(['let g:sequence .= "opt"'], optdir . '/bar.vim')
+ call writefile(['let g:sequence .= "xxxopt"'], optdir . '/xxx.vim')
+ exe 'set rtp=' . &packpath . '/runtime'
+
+ let g:sequence = ''
+ runtime extra/bar.vim
+ call assert_equal('run', g:sequence)
+ let g:sequence = ''
+ runtime START extra/bar.vim
+ call assert_equal('start', g:sequence)
+ let g:sequence = ''
+ runtime OPT extra/bar.vim
+ call assert_equal('opt', g:sequence)
+ let g:sequence = ''
+ runtime PACK extra/bar.vim
+ call assert_equal('start', g:sequence)
+ let g:sequence = ''
+ runtime! PACK extra/bar.vim
+ call assert_equal('startopt', g:sequence)
+ let g:sequence = ''
+ runtime PACK extra/xxx.vim
+ call assert_equal('xxxopt', g:sequence)
+
+ let g:sequence = ''
+ runtime ALL extra/bar.vim
+ call assert_equal('run', g:sequence)
+ let g:sequence = ''
+ runtime ALL extra/foo.vim
+ call assert_equal('foostart', g:sequence)
+ let g:sequence = ''
+ runtime! ALL extra/xxx.vim
+ call assert_equal('xxxopt', g:sequence)
+ let g:sequence = ''
+ runtime! ALL extra/bar.vim
+ call assert_equal('runstartopt', g:sequence)
+ endfunc
+ ]=])
+ call('SetUp')
+ end)
+
+ after_each(function()
+ call('TearDown')
+ end)
+
+ it('is working', function()
+ call('Test_packadd')
+ expected_empty()
+ end)
+
+ it('works with packadd!', function()
+ call('Test_packadd_noload')
+ expected_empty()
+ end)
+
+ it('works with :packloadall', function()
+ call('Test_packloadall')
+ expected_empty()
+ end)
+
+ it('works with helptags', function()
+ call('Test_helptags')
+ expected_empty()
+ end)
+
+ it('works with colorschemes', function()
+ call('Test_colorscheme')
+ expected_empty()
+ end)
+
+ it('works with :runtime [what]', function()
+ call('Test_runtime')
+ expected_empty()
+ end)
+
+ describe('command line completion', function()
+ local Screen = require('test.functional.ui.screen')
+ local screen
+
+ before_each(function()
+ screen = Screen.new(30, 5)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [0] = {bold=true, foreground=Screen.colors.Blue},
+ [1] = {
+ foreground = Screen.colors.Black,
+ background = Screen.colors.Yellow,
+ },
+ [2] = {bold = true, reverse = true}
+ })
+
+ execute([[let optdir1 = &packpath . '/pack/mine/opt']])
+ execute([[let optdir2 = &packpath . '/pack/candidate/opt']])
+ execute([[call mkdir(optdir1 . '/pluginA', 'p')]])
+ execute([[call mkdir(optdir1 . '/pluginC', 'p')]])
+ execute([[call mkdir(optdir2 . '/pluginB', 'p')]])
+ execute([[call mkdir(optdir2 . '/pluginC', 'p')]])
+ end)
+
+ it('works', function()
+ feed(':packadd <Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {1:pluginA}{2: pluginB pluginC }|
+ :packadd pluginA^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {2:pluginA }{1:pluginB}{2: pluginC }|
+ :packadd pluginB^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {2:pluginA pluginB }{1:pluginC}{2: }|
+ :packadd pluginC^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {2:pluginA pluginB pluginC }|
+ :packadd ^ |
+ ]=])
+ end)
+
+ it('works for colorschemes', function()
+ source([[
+ let colordirrun = &packpath . '/runtime/colors'
+ let colordirstart = &packpath . '/pack/mine/start/foo/colors'
+ let colordiropt = &packpath . '/pack/mine/opt/bar/colors'
+ call mkdir(colordirrun, 'p')
+ call mkdir(colordirstart, 'p')
+ call mkdir(colordiropt, 'p')
+ call writefile(['let g:found_one = 1'], colordirrun . '/one.vim')
+ call writefile(['let g:found_two = 1'], colordirstart . '/two.vim')
+ call writefile(['let g:found_three = 1'], colordiropt . '/three.vim')
+ exe 'set rtp=' . &packpath . '/runtime']])
+
+ feed(':colorscheme <Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {1:one}{2: three two }|
+ :colorscheme one^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {2:one }{1:three}{2: two }|
+ :colorscheme three^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {2:one three }{1:two}{2: }|
+ :colorscheme two^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ {0:~ }|
+ {0:~ }|
+ {2:one three two }|
+ :colorscheme ^ |
+ ]=])
+ end)
+ end)
+end)
diff --git a/test/functional/legacy/qf_title_spec.lua b/test/functional/legacy/qf_title_spec.lua
index 01c781cc05..9f97eb27b2 100644
--- a/test/functional/legacy/qf_title_spec.lua
+++ b/test/functional/legacy/qf_title_spec.lua
@@ -1,6 +1,6 @@
-- Tests for quickfix window's title
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert, source = helpers.insert, helpers.source
local clear, expect = helpers.clear, helpers.expect
diff --git a/test/functional/legacy/quickfix_spec.lua b/test/functional/legacy/quickfix_spec.lua
deleted file mode 100644
index 88f86815b3..0000000000
--- a/test/functional/legacy/quickfix_spec.lua
+++ /dev/null
@@ -1,17 +0,0 @@
--- Test for the quickfix commands.
-
-local helpers = require('test.functional.helpers')
-local source, clear = helpers.source, helpers.clear
-
-describe('helpgrep', function()
- before_each(clear)
-
- it('works', function()
- source([[
- helpgrep quickfix
- copen
- " This wipes out the buffer, make sure that doesn't cause trouble.
- cclose
- ]])
- end)
-end)
diff --git a/test/functional/legacy/search_mbyte_spec.lua b/test/functional/legacy/search_mbyte_spec.lua
index 075b24b897..a5a5822a45 100644
--- a/test/functional/legacy/search_mbyte_spec.lua
+++ b/test/functional/legacy/search_mbyte_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local insert = helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
diff --git a/test/functional/legacy/searchpos_spec.lua b/test/functional/legacy/searchpos_spec.lua
index 1c9b1ccee6..7d4b7a3734 100644
--- a/test/functional/legacy/searchpos_spec.lua
+++ b/test/functional/legacy/searchpos_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local call = helpers.call
local clear = helpers.clear
local execute = helpers.execute
diff --git a/test/functional/legacy/set_spec.lua b/test/functional/legacy/set_spec.lua
index f2c907084e..11f371569d 100644
--- a/test/functional/legacy/set_spec.lua
+++ b/test/functional/legacy/set_spec.lua
@@ -1,6 +1,6 @@
-- Tests for :set
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, execute, eval, eq =
helpers.clear, helpers.execute, helpers.eval, helpers.eq
diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua
index 5a834c39e3..e80a32455a 100644
--- a/test/functional/legacy/signs_spec.lua
+++ b/test/functional/legacy/signs_spec.lua
@@ -1,6 +1,6 @@
-- Tests for signs
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('signs', function()
diff --git a/test/functional/legacy/tagcase_spec.lua b/test/functional/legacy/tagcase_spec.lua
index 9a8c6fbe42..ed2876a375 100644
--- a/test/functional/legacy/tagcase_spec.lua
+++ b/test/functional/legacy/tagcase_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
diff --git a/test/functional/legacy/textobjects_spec.lua b/test/functional/legacy/textobjects_spec.lua
index 1e8e0b0bcb..15a93e3819 100644
--- a/test/functional/legacy/textobjects_spec.lua
+++ b/test/functional/legacy/textobjects_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local call = helpers.call
local clear = helpers.clear
local execute = helpers.execute
diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua
index 41274b3a04..1dfc4c17ba 100644
--- a/test/functional/legacy/undolevels_spec.lua
+++ b/test/functional/legacy/undolevels_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local source, clear = helpers.source, helpers.clear
local eq, nvim = helpers.eq, helpers.meths
@@ -10,7 +10,7 @@ describe('undolevel', function()
func FillBuffer()
for i in range(1,13)
put=i
- " Set 'undolevels' to split undo.
+ " Set 'undolevels' to split undo.
exe "setg ul=" . &g:ul
endfor
endfunc
@@ -48,6 +48,10 @@ describe('undolevel', function()
call assert_equal(50, &g:undolevels)
call assert_equal(-123456, &l:undolevels)
+ " Drop created windows
+ set ul&
+ new
+ only!
endfunc
call Test_global_local_undolevels()
diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua
index d33ba6b5fd..4d4f55b9eb 100644
--- a/test/functional/legacy/utf8_spec.lua
+++ b/test/functional/legacy/utf8_spec.lua
@@ -1,6 +1,6 @@
-- Tests for Unicode manipulations
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
local eq, eval = helpers.eq, helpers.eval
diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua
index ba7be8f21b..171ec3de92 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')
+local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute = helpers.clear, helpers.execute
local eq, eval = helpers.eq, helpers.eval
+if helpers.pending_win32(pending) then return end
+
describe('wordcount', function()
before_each(clear)
diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua
index efdfc1d09f..765d373b82 100644
--- a/test/functional/legacy/writefile_spec.lua
+++ b/test/functional/legacy/writefile_spec.lua
@@ -1,6 +1,6 @@
-- Tests for writefile()
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('writefile', function()
@@ -17,6 +17,7 @@ describe('writefile', function()
execute('bwipeout!')
execute('$put =readfile(f)')
execute('1 delete _')
+ execute('call delete(f)')
-- Assert buffer contents.
expect([[