aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy')
-rw-r--r--test/functional/legacy/003_cindent_spec.lua465
-rw-r--r--test/functional/legacy/009_bufleave_autocommand_spec.lua2
-rw-r--r--test/functional/legacy/011_autocommands_spec.lua230
-rw-r--r--test/functional/legacy/015_alignment_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/026_execute_while_if_spec.lua2
-rw-r--r--test/functional/legacy/027_expand_file_names_spec.lua6
-rw-r--r--test/functional/legacy/029_join_spec.lua2
-rw-r--r--test/functional/legacy/031_close_commands_spec.lua22
-rw-r--r--test/functional/legacy/035_increment_and_decrement_spec.lua26
-rw-r--r--test/functional/legacy/036_regexp_character_classes_spec.lua271
-rw-r--r--test/functional/legacy/038_virtual_replace_spec.lua2
-rw-r--r--test/functional/legacy/039_visual_block_mode_commands_spec.lua234
-rw-r--r--test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua11
-rw-r--r--test/functional/legacy/045_folding_spec.lua139
-rw-r--r--test/functional/legacy/046_multi_line_regexps_spec.lua2
-rw-r--r--test/functional/legacy/051_highlight_spec.lua2
-rw-r--r--test/functional/legacy/056_script_local_function_spec.lua2
-rw-r--r--test/functional/legacy/057_sort_spec.lua86
-rw-r--r--test/functional/legacy/059_utf8_spell_checking_spec.lua70
-rw-r--r--test/functional/legacy/060_exists_and_has_functions_spec.lua4
-rw-r--r--test/functional/legacy/061_undo_tree_spec.lua11
-rw-r--r--test/functional/legacy/062_tab_pages_spec.lua22
-rw-r--r--test/functional/legacy/063_match_and_matchadd_spec.lua13
-rw-r--r--test/functional/legacy/065_float_and_logic_operators_spec.lua2
-rw-r--r--test/functional/legacy/067_augroup_exists_spec.lua2
-rw-r--r--test/functional/legacy/068_text_formatting_spec.lua207
-rw-r--r--test/functional/legacy/072_undo_file_spec.lua2
-rw-r--r--test/functional/legacy/074_global_var_in_viminfo_spec.lua2
-rw-r--r--test/functional/legacy/075_maparg_spec.lua2
-rw-r--r--test/functional/legacy/077_mf_hash_grow_spec.lua2
-rw-r--r--test/functional/legacy/078_swapfile_recover_spec.lua4
-rw-r--r--test/functional/legacy/080_substitute_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.lua110
-rw-r--r--test/functional/legacy/084_curswant_spec.lua4
-rw-r--r--test/functional/legacy/088_conceal_tabs_spec.lua96
-rw-r--r--test/functional/legacy/089_number_relnumber_findfile_spec.lua2
-rw-r--r--test/functional/legacy/090_sha256_spec.lua4
-rw-r--r--test/functional/legacy/091_context_variables_spec.lua9
-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.lua2
-rw-r--r--test/functional/legacy/094_visual_mode_operators_spec.lua245
-rw-r--r--test/functional/legacy/095_regexp_multibyte_spec.lua4
-rw-r--r--test/functional/legacy/096_location_list_spec.lua2
-rw-r--r--test/functional/legacy/097_glob_path_spec.lua2
-rw-r--r--test/functional/legacy/098_scrollbind_spec.lua4
-rw-r--r--test/functional/legacy/100_undo_level_spec.lua142
-rw-r--r--test/functional/legacy/101_hlsearch_spec.lua3
-rw-r--r--test/functional/legacy/102_fnameescape_spec.lua2
-rw-r--r--test/functional/legacy/103_visual_mode_reset_spec.lua4
-rw-r--r--test/functional/legacy/105_filename_modifiers_spec.lua81
-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/assert_spec.lua145
-rw-r--r--test/functional/legacy/autocmd_option_spec.lua318
-rw-r--r--test/functional/legacy/backspace_opt_spec.lua67
-rw-r--r--test/functional/legacy/cdo_spec.lua226
-rw-r--r--test/functional/legacy/charsearch_spec.lua42
-rw-r--r--test/functional/legacy/command_count_spec.lua243
-rw-r--r--test/functional/legacy/comparators_spec.lua14
-rw-r--r--test/functional/legacy/delete_spec.lua99
-rw-r--r--test/functional/legacy/erasebackword_spec.lua24
-rw-r--r--test/functional/legacy/eval_spec.lua736
-rw-r--r--test/functional/legacy/fixeol_spec.lua72
-rw-r--r--test/functional/legacy/fnamemodify_spec.lua75
-rw-r--r--test/functional/legacy/function_sort_spec.lua29
-rw-r--r--test/functional/legacy/glob2regpat_spec.lua22
-rw-r--r--test/functional/legacy/increment_spec.lua748
-rw-r--r--test/functional/legacy/lispwords_spec.lua25
-rw-r--r--test/functional/legacy/listlbr_utf8_spec.lua108
-rw-r--r--test/functional/legacy/mapping_spec.lua64
-rw-r--r--test/functional/legacy/marks_spec.lua53
-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.lua22
-rw-r--r--test/functional/legacy/qf_title_spec.lua4
-rw-r--r--test/functional/legacy/quickfix_spec.lua17
-rw-r--r--test/functional/legacy/search_mbyte_spec.lua26
-rw-r--r--test/functional/legacy/searchpos_spec.lua35
-rw-r--r--test/functional/legacy/set_spec.lua15
-rw-r--r--test/functional/legacy/signs_spec.lua1
-rw-r--r--test/functional/legacy/tagcase_spec.lua150
-rw-r--r--test/functional/legacy/textobjects_spec.lua61
-rw-r--r--test/functional/legacy/undolevels_spec.lua58
-rw-r--r--test/functional/legacy/utf8_spec.lua55
-rw-r--r--test/functional/legacy/wordcount_spec.lua171
-rw-r--r--test/functional/legacy/writefile_spec.lua1
89 files changed, 6214 insertions, 323 deletions
diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua
index 1857721563..4b838eda1d 100644
--- a/test/functional/legacy/003_cindent_spec.lua
+++ b/test/functional/legacy/003_cindent_spec.lua
@@ -4,7 +4,7 @@
-- in the original test. These have been converted to "it" test cases here.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
-- Inserts text as usual, and additionally positions the cursor on line 1 and
@@ -674,6 +674,13 @@ describe('cindent', function()
{
}
+ A::A(int a, int b)
+ : aa(a),
+ bb(b),
+ cc(c)
+ {
+ }
+
class CAbc :
public BaseClass1,
protected BaseClass2
@@ -901,6 +908,72 @@ describe('cindent', function()
{
111111111111111111;
}
+ void getstring() {
+ /* Raw strings */
+ const char* s = R"(
+ test {
+ # comment
+ field: 123
+ }
+ )";
+ }
+ void getstring() {
+ const char* s = R"foo(
+ test {
+ # comment
+ field: 123
+ }
+ )foo";
+ }
+
+ {
+ int a[4] = {
+ [0] = 0,
+ [1] = 1,
+ [2] = 2,
+ [3] = 3,
+ };
+ }
+
+ {
+ a = b[2]
+ + 3;
+ }
+
+ {
+ if (1)
+ /* aaaaa
+ * bbbbb
+ */
+ a = 1;
+ }
+
+ void func()
+ {
+ switch (foo)
+ {
+ case (bar):
+ if (baz())
+ quux();
+ break;
+ case (shmoo):
+ if (!bar)
+ {
+ }
+ case (foo1):
+ switch (bar)
+ {
+ case baz:
+ baz_f();
+ break;
+ }
+ break;
+ default:
+ baz();
+ baz();
+ break;
+ }
+ }
/* end of AUTO */
]=])
@@ -1563,6 +1636,13 @@ describe('cindent', function()
{
}
+ A::A(int a, int b)
+ : aa(a),
+ bb(b),
+ cc(c)
+ {
+ }
+
class CAbc :
public BaseClass1,
protected BaseClass2
@@ -1790,6 +1870,72 @@ describe('cindent', function()
{
111111111111111111;
}
+ void getstring() {
+ /* Raw strings */
+ const char* s = R"(
+ test {
+ # comment
+ field: 123
+ }
+ )";
+ }
+ void getstring() {
+ const char* s = R"foo(
+ test {
+ # comment
+ field: 123
+ }
+ )foo";
+ }
+
+ {
+ int a[4] = {
+ [0] = 0,
+ [1] = 1,
+ [2] = 2,
+ [3] = 3,
+ };
+ }
+
+ {
+ a = b[2]
+ + 3;
+ }
+
+ {
+ if (1)
+ /* aaaaa
+ * bbbbb
+ */
+ a = 1;
+ }
+
+ void func()
+ {
+ switch (foo)
+ {
+ case (bar):
+ if (baz())
+ quux();
+ break;
+ case (shmoo):
+ if (!bar)
+ {
+ }
+ case (foo1):
+ switch (bar)
+ {
+ case baz:
+ baz_f();
+ break;
+ }
+ break;
+ default:
+ baz();
+ baz();
+ break;
+ }
+ }
/* end of AUTO */
]=])
@@ -4213,4 +4359,321 @@ describe('cindent', function()
JSEND
]=])
end)
+
+ it('javascript indent / vim-patch 7.4.670', function()
+ insert_([=[
+
+ JSSTART
+ // Results of JavaScript indent
+ // 1
+ (function(){
+ var a = [
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 2
+ (function(){
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 3
+ (function(){
+ var a = [
+ 0 +
+ // comment 1
+ 5 *
+ /* comment 2 */
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 4
+ {
+ var a = [
+ 0,
+ 1
+ ];
+ var b;
+ var c;
+ }
+
+ // 5
+ {
+ var a = [
+ [
+ 0
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 6
+ {
+ var a = [
+ [
+ 0,
+ 1
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 7
+ {
+ var a = [
+ // [
+ 0,
+ // 1
+ // ],
+ 2,
+ 3
+ ];
+ }
+
+ // 8
+ var x = [
+ (function(){
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ })
+ ];
+
+ // 9
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+
+ // 10
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ JSEND
+ ]=])
+
+ -- :set cino=j1,J1,+2
+ execute('set cino=j1,J1,+2')
+ execute('/^JSSTART')
+ feed('=/^JSEND<cr>')
+
+ expect([=[
+
+ JSSTART
+ // Results of JavaScript indent
+ // 1
+ (function(){
+ var a = [
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 2
+ (function(){
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 3
+ (function(){
+ var a = [
+ 0 +
+ // comment 1
+ 5 *
+ /* comment 2 */
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+ }())
+
+ // 4
+ {
+ var a = [
+ 0,
+ 1
+ ];
+ var b;
+ var c;
+ }
+
+ // 5
+ {
+ var a = [
+ [
+ 0
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 6
+ {
+ var a = [
+ [
+ 0,
+ 1
+ ],
+ 2,
+ 3
+ ];
+ }
+
+ // 7
+ {
+ var a = [
+ // [
+ 0,
+ // 1
+ // ],
+ 2,
+ 3
+ ];
+ }
+
+ // 8
+ var x = [
+ (function(){
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ })
+ ];
+
+ // 9
+ var a = [
+ 0 +
+ 5 *
+ 9 *
+ 'a',
+ 'b',
+ 0 +
+ 5 *
+ 9 *
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i'
+ ];
+
+ // 10
+ var a,
+ b,
+ c,
+ d,
+ e,
+ f,
+ g,
+ h,
+ i;
+ JSEND
+ ]=])
+ end)
end)
diff --git a/test/functional/legacy/009_bufleave_autocommand_spec.lua b/test/functional/legacy/009_bufleave_autocommand_spec.lua
index 0fc1b5b657..8c18639c8f 100644
--- a/test/functional/legacy/009_bufleave_autocommand_spec.lua
+++ b/test/functional/legacy/009_bufleave_autocommand_spec.lua
@@ -1,7 +1,7 @@
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('BufLeave autocommand', function()
diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua
new file mode 100644
index 0000000000..483e465cee
--- /dev/null
+++ b/test/functional/legacy/011_autocommands_spec.lua
@@ -0,0 +1,230 @@
+-- Tests for autocommands
+-- - FileWritePre writing a compressed file
+-- - FileReadPost reading a compressed file
+-- - BufNewFile reading a file template
+-- - BufReadPre decompressing the file to be read
+-- - FilterReadPre substituting characters in the temp file
+-- - FilterReadPost substituting characters after filtering
+-- - FileReadPre set options for decompression
+-- - FileReadPost decompress the file
+-- Note: This test is skipped if "gzip" is not available.
+-- $GZIP is made empty, "-v" would cause trouble.
+-- 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 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
+
+local function has_gzip()
+ return os.execute('gzip --help >/dev/null 2>&1') == 0
+end
+
+local function prepare_gz_file(name, text)
+ write_file(name, text..'\n')
+ -- Compress the file with gzip.
+ os.execute('gzip --force '..name)
+ -- This should create the .gz file and delete the original.
+ neq(nil, lfs.attributes(name..'.gz'))
+ eq(nil, lfs.attributes(name))
+end
+
+describe('file reading, writing and bufnew and filter autocommands', function()
+ local text1 = dedent([[
+ start of testfile
+ line 2 Abcdefghijklmnopqrstuvwxyz
+ line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 4 Abcdefghijklmnopqrstuvwxyz
+ line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 6 Abcdefghijklmnopqrstuvwxyz
+ line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 8 Abcdefghijklmnopqrstuvwxyz
+ line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 10 Abcdefghijklmnopqrstuvwxyz
+ end of testfile]])
+ setup(function()
+ write_file('Xtest.c', [[
+ /*
+ * Here is a new .c file
+ */
+ ]])
+ end)
+ before_each(clear)
+ teardown(function()
+ os.remove('Xtestfile.gz')
+ os.remove('Xtest.c')
+ os.remove('test.out')
+ end)
+
+ if not has_gzip() then
+ pending('skipped (missing `gzip` utility)', function() end)
+ else
+
+ it('FileReadPost (using gzip)', function()
+ prepare_gz_file('Xtestfile', text1)
+ execute('let $GZIP = ""')
+ --execute('au FileChangedShell * echo "caught FileChangedShell"')
+ execute('set bin')
+ execute("au FileReadPost *.gz '[,']!gzip -d")
+ -- Read and decompress the testfile.
+ execute('$r Xtestfile.gz')
+ expect('\n'..text1)
+ end)
+
+ it('BufReadPre, BufReadPost (using gzip)', function()
+ prepare_gz_file('Xtestfile', text1)
+ local gzip_data = io.open('Xtestfile.gz'):read('*all')
+ execute('let $GZIP = ""')
+ -- Setup autocommands to decompress before reading and re-compress afterwards.
+ execute("au BufReadPre *.gz exe '!gzip -d ' . shellescape(expand('<afile>'))")
+ execute("au BufReadPre *.gz call rename(expand('<afile>:r'), expand('<afile>'))")
+ execute("au BufReadPost *.gz call rename(expand('<afile>'), expand('<afile>:r'))")
+ execute("au BufReadPost *.gz exe '!gzip ' . shellescape(expand('<afile>:r'))")
+ -- Edit compressed file.
+ execute('e! Xtestfile.gz')
+ -- Discard all prompts and messages.
+ feed('<C-L>')
+ -- Expect the decompressed file in the buffer.
+ expect(text1)
+ -- Expect the original file to be unchanged.
+ eq(gzip_data, io.open('Xtestfile.gz'):read('*all'))
+ end)
+
+ it('FileReadPre, FileReadPost', function()
+ prepare_gz_file('Xtestfile', text1)
+ execute('au! FileReadPre *.gz exe "silent !gzip -d " . shellescape(expand("<afile>"))')
+ execute('au FileReadPre *.gz call rename(expand("<afile>:r"), expand("<afile>"))')
+ execute("au! FileReadPost *.gz '[,']s/l/L/")
+ -- Read compressed file.
+ execute('$r Xtestfile.gz')
+ -- Discard all prompts and messages.
+ feed('<C-L>')
+ expect([[
+
+ start of testfiLe
+ Line 2 Abcdefghijklmnopqrstuvwxyz
+ Line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ Line 4 Abcdefghijklmnopqrstuvwxyz
+ Line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ Line 6 Abcdefghijklmnopqrstuvwxyz
+ Line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ Line 8 Abcdefghijklmnopqrstuvwxyz
+ Line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ Line 10 Abcdefghijklmnopqrstuvwxyz
+ end of testfiLe]])
+ end)
+
+ end
+
+ it('FileAppendPre, FileAppendPost', function()
+ execute('au BufNewFile *.c read Xtest.c')
+ -- Will load Xtest.c.
+ execute('e! foo.c')
+ execute("au FileAppendPre *.out '[,']s/new/NEW/")
+ execute('au FileAppendPost *.out !cat Xtest.c >>test.out')
+ -- Append it to the output file.
+ execute('w>>test.out')
+ -- Discard all prompts and messages.
+ feed('<C-L>')
+ -- Expect the decompressed file in the buffer.
+ execute('e test.out')
+ expect([[
+
+ /*
+ * Here is a NEW .c file
+ */]])
+ end)
+
+ it('FilterReadPre, FilterReadPost', function()
+ -- Write a special input file for this test block.
+ write_file('test.out', dedent([[
+ startstart
+ ]]) .. text1 .. dedent([[
+
+
+ start of test.c
+ /*
+ * Here is a new .c file
+ */
+ end of test.c
+ ]]) .. text1 .. dedent([[
+
+
+ /*
+ * Here is a NEW .c file
+ */
+ /*
+ * Here is a new .c file
+ */
+ ]]) .. text1 .. dedent([[
+
+ /*
+ * Here is a new .c file
+ */]]))
+ -- Need temp files here.
+ execute('set shelltemp')
+ execute('au FilterReadPre *.out call rename(expand("<afile>"), expand("<afile>") . ".t")')
+ execute('au FilterReadPre *.out exe "silent !sed s/e/E/ " . shellescape(expand("<afile>")) . ".t >" . shellescape(expand("<afile>"))')
+ execute('au FilterReadPre *.out exe "silent !rm " . shellescape(expand("<afile>")) . ".t"')
+ execute("au FilterReadPost *.out '[,']s/x/X/g")
+ -- Edit the output file.
+ execute('e! test.out')
+ execute('23,$!cat')
+ -- Discard all prompts and messages.
+ feed('<C-L>')
+ -- Remove CR for when sed adds them.
+ execute([[23,$s/\r$//]])
+ expect([[
+ startstart
+ start of testfile
+ line 2 Abcdefghijklmnopqrstuvwxyz
+ line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 4 Abcdefghijklmnopqrstuvwxyz
+ line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 6 Abcdefghijklmnopqrstuvwxyz
+ line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 8 Abcdefghijklmnopqrstuvwxyz
+ line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 10 Abcdefghijklmnopqrstuvwxyz
+ end of testfile
+
+ start of test.c
+ /*
+ * Here is a new .c file
+ */
+ end of test.c
+ start of testfile
+ line 2 Abcdefghijklmnopqrstuvwxyz
+ line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ line 4 Abcdefghijklmnopqrstuvwxyz
+ linE 5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ linE 6 AbcdefghijklmnopqrstuvwXyz
+ linE 7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ linE 8 AbcdefghijklmnopqrstuvwXyz
+ linE 9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ linE 10 AbcdefghijklmnopqrstuvwXyz
+ End of testfile
+
+ /*
+ * HEre is a NEW .c file
+ */
+ /*
+ * HEre is a new .c file
+ */
+ start of tEstfile
+ linE 2 AbcdefghijklmnopqrstuvwXyz
+ linE 3 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ linE 4 AbcdefghijklmnopqrstuvwXyz
+ linE 5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ linE 6 AbcdefghijklmnopqrstuvwXyz
+ linE 7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ linE 8 AbcdefghijklmnopqrstuvwXyz
+ linE 9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ linE 10 AbcdefghijklmnopqrstuvwXyz
+ End of testfile
+ /*
+ * HEre is a new .c file
+ */]])
+ end)
+end)
diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua
index e71f9d1c90..3b19f4ff42 100644
--- a/test/functional/legacy/015_alignment_spec.lua
+++ b/test/functional/legacy/015_alignment_spec.lua
@@ -3,7 +3,7 @@
-- Also test undo after ":%s" and formatting.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('alignment', function()
diff --git a/test/functional/legacy/022_line_ending_spec.lua b/test/functional/legacy/022_line_ending_spec.lua
index 4b897a7c95..a841378a82 100644
--- a/test/functional/legacy/022_line_ending_spec.lua
+++ b/test/functional/legacy/022_line_ending_spec.lua
@@ -1,7 +1,7 @@
-- Tests for file with some lines ending in CTRL-M, some not
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
describe('line ending', function()
diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua
index e68af9758d..15b30bfa3a 100644
--- a/test/functional/legacy/023_edit_arguments_spec.lua
+++ b/test/functional/legacy/023_edit_arguments_spec.lua
@@ -1,7 +1,7 @@
-- Tests for complicated + argument to :edit command
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe(':edit', function()
diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua
index ffe37819de..f17bb79702 100644
--- a/test/functional/legacy/026_execute_while_if_spec.lua
+++ b/test/functional/legacy/026_execute_while_if_spec.lua
@@ -1,7 +1,7 @@
-- Test for :execute, :while and :if
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
local source = helpers.source
diff --git a/test/functional/legacy/027_expand_file_names_spec.lua b/test/functional/legacy/027_expand_file_names_spec.lua
index d31f29d38a..4778d16d43 100644
--- a/test/functional/legacy/027_expand_file_names_spec.lua
+++ b/test/functional/legacy/027_expand_file_names_spec.lua
@@ -1,10 +1,10 @@
-- Test for expanding file names
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local clear, feed = helpers.clear, helpers.feed
+local execute = helpers.execute
local curbuf_contents = helpers.curbuf_contents
-local eq, eval = helpers.eq, helpers.eval
+local eq = helpers.eq
describe('expand file name', function()
setup(clear)
diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua
index eafa50d88c..25a072ad6e 100644
--- a/test/functional/legacy/029_join_spec.lua
+++ b/test/functional/legacy/029_join_spec.lua
@@ -1,7 +1,7 @@
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('joining lines', function()
diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua
index 78e71b5fb1..b79b1903ba 100644
--- a/test/functional/legacy/031_close_commands_spec.lua
+++ b/test/functional/legacy/031_close_commands_spec.lua
@@ -84,6 +84,28 @@ describe('Commands that close windows and/or buffers', function()
feed('GA 4<Esc>:all!<CR>')
execute('1wincmd w')
expect('testtext 2 2 2')
+
+ -- Test ":q!" and hidden buffer.
+ execute('bw! Xtest1 Xtest2 Xtest3 Xtest4')
+ execute('sp Xtest1')
+ execute('wincmd w')
+ execute('bw!')
+ execute('set modified')
+ execute('bot sp Xtest2')
+ execute('set modified')
+ execute('bot sp Xtest3')
+ execute('set modified')
+ execute('wincmd t')
+ execute('hide')
+ execute('q!')
+ expect('testtext 3')
+ execute('q!')
+ feed('<CR>')
+ expect('testtext 1')
+ source([[
+ q!
+ " Now nvim should have exited
+ throw "Oh, Not finished yet."]])
end)
teardown(function()
diff --git a/test/functional/legacy/035_increment_and_decrement_spec.lua b/test/functional/legacy/035_increment_and_decrement_spec.lua
index 20c0cc4206..e6252c384b 100644
--- a/test/functional/legacy/035_increment_and_decrement_spec.lua
+++ b/test/functional/legacy/035_increment_and_decrement_spec.lua
@@ -11,34 +11,40 @@ describe('increment and decrement commands', function()
it('should work', function()
-- Insert some numbers in various bases.
insert([[
- 100 0x100 077 0
- 100 0x100 077
+ 0b101 100 0x100 077 0
+ 0b101 100 0x100 077
100 0x100 077 0xfF 0xFf
- 100 0x100 077]])
+ 100 0x100 077
+ 0x0b101 0b1101]])
-- Increment and decrement numbers in the first row, interpreting the
-- numbers as decimal, octal or hexadecimal.
- execute('set nrformats=octal,hex', '1')
- feed('102ll64128$')
+ execute('set nrformats=bin,octal,hex', '1')
+ feed('63l102ll64128$')
-- For the second row, treat the numbers as decimal or octal.
-- 0x100 should be interpreted as decimal 0, the character x, and decimal 100.
execute('set nrformats=octal', '2')
- feed('0102l2w65129blx6lD')
+ feed('0w102l2w65129blx6lD')
-- For the third row, treat the numbers as decimal or hexadecimal.
-- 077 should be interpreted as decimal 77.
execute('set nrformats=hex', '3')
feed('0101l257Txldt   ')
- -- For the last row, interpret all numbers as decimal.
+ -- For the fourth row, interpret all numbers as decimal.
execute('set nrformats=', '4')
feed('0200l100w78')
+ -- For the last row, interpret as binary and hexadecimal.
+ execute('set nrformats=bin,hex', '5')
+ feed('010065l6432')
+
expect([[
- 0 0x0ff 0000 -1
- 0 1x100 0777777
+ 0b011 0 0x0ff 0000 -1
+ 1b101 0 1x100 0777777
-1 0x0 078 0xFE 0xfe
- -100 -100x100 000]])
+ -100 -100x100 000
+ 0x0b0de 0b0101101]])
end)
end)
diff --git a/test/functional/legacy/036_regexp_character_classes_spec.lua b/test/functional/legacy/036_regexp_character_classes_spec.lua
new file mode 100644
index 0000000000..de080f4b43
--- /dev/null
+++ b/test/functional/legacy/036_regexp_character_classes_spec.lua
@@ -0,0 +1,271 @@
+-- Test character classes in regexp using regexpengine 0, 1, 2.
+
+local helpers = require('test.functional.helpers')
+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 = ''
+ for _ = 1, 6 do
+ result = result .. text .. '\n'
+ end
+ return result
+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)
+ helpers.wait()
+ local data = io.open(tmpname):read('*all')
+ if nodedent then
+ helpers.eq(text, data)
+ else
+ helpers.eq(helpers.dedent(text), data)
+ end
+ os.remove(tmpname)
+end
+
+describe('character classes in regexp', function()
+ local ctrl1 = '\t\012\r'
+ local punct1 = " !\"#$%&'()#+'-./"
+ local digits = '0123456789'
+ local punct2 = ':;<=>?@'
+ local upper = 'ABCDEFGHIXYZ'
+ local punct3 = '[\\]^_`'
+ local lower = 'abcdefghiwxyz'
+ local punct4 = '{|}~'
+ local ctrl2 = '\127\128\130\144\155'
+ local iso_text = '\166\177\188\199\211\233' -- "¦±¼ÇÓé" in utf-8
+ setup(function()
+ -- The original test32.in file was not in utf-8 encoding and did also
+ -- contain some control characters. We use lua escape sequences to write
+ -- them to the test file.
+ local line = ctrl1..punct1..digits..punct2..upper..punct3..lower..punct4..ctrl2..iso_text
+ write_file('test36.in', sixlines(line))
+ end)
+ before_each(function()
+ clear()
+ execute('e test36.in')
+ end)
+ teardown(function()
+ os.remove('test36.in')
+ end)
+
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\d//g
+ 2 s/\%#=1\d//g
+ 3 s/\%#=2\d//g
+ 4 s/\%#=0[0-9]//g
+ 5 s/\%#=1[0-9]//g
+ 6 s/\%#=2[0-9]//g]])
+ diff(sixlines(ctrl1..punct1..punct2..upper..punct3..lower..punct4..
+ ctrl2..iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\D//g
+ 2 s/\%#=1\D//g
+ 3 s/\%#=2\D//g
+ 4 s/\%#=0[^0-9]//g
+ 5 s/\%#=1[^0-9]//g
+ 6 s/\%#=2[^0-9]//g]])
+ expect([[
+ 0123456789
+ 0123456789
+ 0123456789
+ 0123456789
+ 0123456789
+ 0123456789]])
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\o//g
+ 2 s/\%#=1\o//g
+ 3 s/\%#=2\o//g
+ 4 s/\%#=0[0-7]//g
+ 5 s/\%#=1[0-7]//g
+ 6 s/\%#=2[0-7]//g]])
+ diff(sixlines(ctrl1..punct1..'89'..punct2..upper..punct3..lower..punct4..ctrl2..
+ iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\O//g
+ 2 s/\%#=1\O//g
+ 3 s/\%#=2\O//g
+ 4 s/\%#=0[^0-7]//g
+ 5 s/\%#=1[^0-7]//g
+ 6 s/\%#=2[^0-7]//g]])
+ expect([[
+ 01234567
+ 01234567
+ 01234567
+ 01234567
+ 01234567
+ 01234567]])
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\x//g
+ 2 s/\%#=1\x//g
+ 3 s/\%#=2\x//g
+ 4 s/\%#=0[0-9A-Fa-f]//g
+ 5 s/\%#=1[0-9A-Fa-f]//g
+ 6 s/\%#=2[0-9A-Fa-f]//g]])
+ diff(sixlines(ctrl1..punct1..punct2..'GHIXYZ'..punct3..'ghiwxyz'..punct4..ctrl2..iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\X//g
+ 2 s/\%#=1\X//g
+ 3 s/\%#=2\X//g
+ 4 s/\%#=0[^0-9A-Fa-f]//g
+ 5 s/\%#=1[^0-9A-Fa-f]//g
+ 6 s/\%#=2[^0-9A-Fa-f]//g]])
+ expect([[
+ 0123456789ABCDEFabcdef
+ 0123456789ABCDEFabcdef
+ 0123456789ABCDEFabcdef
+ 0123456789ABCDEFabcdef
+ 0123456789ABCDEFabcdef
+ 0123456789ABCDEFabcdef]])
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\w//g
+ 2 s/\%#=1\w//g
+ 3 s/\%#=2\w//g
+ 4 s/\%#=0[0-9A-Za-z_]//g
+ 5 s/\%#=1[0-9A-Za-z_]//g
+ 6 s/\%#=2[0-9A-Za-z_]//g]])
+ diff(sixlines(ctrl1..punct1..punct2..'[\\]^`'..punct4..ctrl2..iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\W//g
+ 2 s/\%#=1\W//g
+ 3 s/\%#=2\W//g
+ 4 s/\%#=0[^0-9A-Za-z_]//g
+ 5 s/\%#=1[^0-9A-Za-z_]//g
+ 6 s/\%#=2[^0-9A-Za-z_]//g]])
+ expect([[
+ 0123456789ABCDEFGHIXYZ_abcdefghiwxyz
+ 0123456789ABCDEFGHIXYZ_abcdefghiwxyz
+ 0123456789ABCDEFGHIXYZ_abcdefghiwxyz
+ 0123456789ABCDEFGHIXYZ_abcdefghiwxyz
+ 0123456789ABCDEFGHIXYZ_abcdefghiwxyz
+ 0123456789ABCDEFGHIXYZ_abcdefghiwxyz]])
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\h//g
+ 2 s/\%#=1\h//g
+ 3 s/\%#=2\h//g
+ 4 s/\%#=0[A-Za-z_]//g
+ 5 s/\%#=1[A-Za-z_]//g
+ 6 s/\%#=2[A-Za-z_]//g]])
+ diff(sixlines(ctrl1..punct1..digits..punct2..'[\\]^`'..punct4..ctrl2..
+ iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\H//g
+ 2 s/\%#=1\H//g
+ 3 s/\%#=2\H//g
+ 4 s/\%#=0[^A-Za-z_]//g
+ 5 s/\%#=1[^A-Za-z_]//g
+ 6 s/\%#=2[^A-Za-z_]//g]])
+ expect([[
+ ABCDEFGHIXYZ_abcdefghiwxyz
+ ABCDEFGHIXYZ_abcdefghiwxyz
+ ABCDEFGHIXYZ_abcdefghiwxyz
+ ABCDEFGHIXYZ_abcdefghiwxyz
+ ABCDEFGHIXYZ_abcdefghiwxyz
+ ABCDEFGHIXYZ_abcdefghiwxyz]])
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\a//g
+ 2 s/\%#=1\a//g
+ 3 s/\%#=2\a//g
+ 4 s/\%#=0[A-Za-z]//g
+ 5 s/\%#=1[A-Za-z]//g
+ 6 s/\%#=2[A-Za-z]//g]])
+ diff(sixlines(ctrl1..punct1..digits..punct2..punct3..punct4..ctrl2..iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\A//g
+ 2 s/\%#=1\A//g
+ 3 s/\%#=2\A//g
+ 4 s/\%#=0[^A-Za-z]//g
+ 5 s/\%#=1[^A-Za-z]//g
+ 6 s/\%#=2[^A-Za-z]//g]])
+ expect([[
+ ABCDEFGHIXYZabcdefghiwxyz
+ ABCDEFGHIXYZabcdefghiwxyz
+ ABCDEFGHIXYZabcdefghiwxyz
+ ABCDEFGHIXYZabcdefghiwxyz
+ ABCDEFGHIXYZabcdefghiwxyz
+ ABCDEFGHIXYZabcdefghiwxyz]])
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\l//g
+ 2 s/\%#=1\l//g
+ 3 s/\%#=2\l//g
+ 4 s/\%#=0[a-z]//g
+ 5 s/\%#=1[a-z]//g
+ 6 s/\%#=2[a-z]//g]])
+ diff(sixlines(ctrl1..punct1..digits..punct2..upper..punct3..punct4..
+ ctrl2..iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\L//g
+ 2 s/\%#=1\L//g
+ 3 s/\%#=2\L//g
+ 4 s/\%#=0[^a-z]//g
+ 5 s/\%#=1[^a-z]//g
+ 6 s/\%#=2[^a-z]//g]])
+ expect([[
+ abcdefghiwxyz
+ abcdefghiwxyz
+ abcdefghiwxyz
+ abcdefghiwxyz
+ abcdefghiwxyz
+ abcdefghiwxyz]])
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\u//g
+ 2 s/\%#=1\u//g
+ 3 s/\%#=2\u//g
+ 4 s/\%#=0[A-Z]//g
+ 5 s/\%#=1[A-Z]//g
+ 6 s/\%#=2[A-Z]//g]])
+ diff(sixlines(ctrl1..punct1..digits..punct2..punct3..lower..punct4..
+ ctrl2..iso_text))
+ end)
+ it('is working', function()
+ source([[
+ 1 s/\%#=0\U//g
+ 2 s/\%#=1\U//g
+ 3 s/\%#=2\U//g
+ 4 s/\%#=0[^A-Z]//g
+ 5 s/\%#=1[^A-Z]//g
+ 6 s/\%#=2[^A-Z]//g]])
+ expect([[
+ ABCDEFGHIXYZ
+ ABCDEFGHIXYZ
+ ABCDEFGHIXYZ
+ ABCDEFGHIXYZ
+ ABCDEFGHIXYZ
+ ABCDEFGHIXYZ]])
+ end)
+end)
diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua
index 94503bd42a..10d42f0cea 100644
--- a/test/functional/legacy/038_virtual_replace_spec.lua
+++ b/test/functional/legacy/038_virtual_replace_spec.lua
@@ -1,7 +1,7 @@
-- Test Virtual replace mode.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('Virtual replace mode', function()
diff --git a/test/functional/legacy/039_visual_block_mode_commands_spec.lua b/test/functional/legacy/039_visual_block_mode_commands_spec.lua
new file mode 100644
index 0000000000..7195d7d11d
--- /dev/null
+++ b/test/functional/legacy/039_visual_block_mode_commands_spec.lua
@@ -0,0 +1,234 @@
+-- Test Visual block mode commands
+-- And test "U" in Visual mode, also on German sharp S.
+
+local helpers = require('test.functional.helpers')
+local nvim, eq = helpers.meths, helpers.eq
+local insert, feed = helpers.insert, helpers.feed
+local clear, expect = helpers.clear, helpers.expect
+local execute = helpers.execute
+
+describe('Visual block mode', function()
+
+ before_each(function()
+ clear()
+
+ execute('set ts&vi sw&vi sts&vi noet') -- Vim compatible
+ end)
+
+ it('should shift, insert, replace and change a block', function()
+ insert([[
+ abcdefghijklm
+ abcdefghijklm
+ abcdefghijklm
+ abcdefghijklm
+ abcdefghijklm]])
+
+ feed('gg')
+ -- Test shift-right of a block
+ feed('jllll<C-v>jj>wll<C-v>jlll><CR>')
+ -- Test shift-left of a block
+ feed('G$hhhh<C-v>kk<lt>')
+ -- Test block-insert
+ feed('Gkl<C-v>kkkIxyz<ESC>')
+ -- Test block-replace
+ feed('Gllll<C-v>kkklllrq')
+ -- Test block-change
+ feed('G$khhh<C-v>hhkkcmno<ESC>')
+
+ expect([[
+ axyzbcdefghijklm
+ axyzqqqq mno ghijklm
+ axyzqqqqef mno ghijklm
+ axyzqqqqefgmnoklm
+ abcdqqqqijklm]])
+ end)
+
+ it('should insert a block using cursor keys for movement', function()
+ insert([[
+ aaaaaa
+ bbbbbb
+ cccccc
+ dddddd
+
+ xaaa
+ bbbb
+ cccc
+ dddd]])
+
+ execute('/^aa')
+ feed('l<C-v>jjjlllI<Right><Right> <ESC>')
+ execute('/xaaa$')
+ feed('<C-v>jjjI<lt>><Left>p<ESC>')
+
+ expect([[
+ aaa aaa
+ bbb bbb
+ ccc ccc
+ ddd ddd
+
+ <p>xaaa
+ <p>bbbb
+ <p>cccc
+ <p>dddd]])
+ end)
+
+ it('should create a block', function()
+ insert([[
+ A23
+ 4567
+
+ B23
+ 4567
+
+ C23
+ 4567]])
+
+ -- Test for Visual block was created with the last <C-v>$.
+ execute('/^A23$/')
+ feed('l<C-v>j$Aab<ESC>')
+ -- Test for Visual block was created with the middle <C-v>$ (1).
+ execute('/^B23$/')
+ feed('l<C-v>j$hAab<ESC>')
+ -- Test for Visual block was created with the middle <C-v>$ (2).
+ execute('/^C23$/')
+ feed('l<C-v>j$hhAab<ESC>')
+
+ expect([[
+ A23ab
+ 4567ab
+
+ B23 ab
+ 4567ab
+
+ C23ab
+ 456ab7]])
+ end)
+
+ it('should insert and append a block when virtualedit=all', function()
+ insert([[
+ line1
+ line2
+ line3
+ ]])
+
+ -- Test for Visual block insert when virtualedit=all and utf-8 encoding.
+ execute('set ve=all')
+ execute('/\t\tline')
+ feed('07l<C-v>jjIx<ESC>')
+
+ expect([[
+ x line1
+ x line2
+ x line3
+ ]])
+
+ -- Test for Visual block append when virtualedit=all.
+ feed('012l<C-v>jjAx<ESC>')
+
+ expect([[
+ x x line1
+ x x line2
+ x x line3
+ ]])
+ end)
+
+ it('should make a selected part uppercase', function()
+ -- GUe must uppercase a whole word, also when ß changes to SS.
+ feed('Gothe youtußeuu end<ESC>Ypk0wgUe<CR>')
+ -- GUfx must uppercase until x, inclusive.
+ feed('O- youßtußexu -<ESC>0fogUfx<CR>')
+ -- VU must uppercase a whole line.
+ feed('YpkVU<CR>')
+ -- Same, when it's the last line in the buffer.
+ feed('YPGi111<ESC>VUddP<CR>')
+ -- Uppercase two lines.
+ feed('Oblah di<CR>')
+ feed('doh dut<ESC>VkUj<CR>')
+ -- Uppercase part of two lines.
+ feed('ddppi333<ESC>k0i222<esc>fyllvjfuUk<CR>')
+
+ expect([[
+
+ the YOUTUSSEUU end
+ - yOUSSTUSSEXu -
+ THE YOUTUSSEUU END
+ 111THE YOUTUSSEUU END
+ BLAH DI
+ DOH DUT
+ 222the yoUTUSSEUU END
+ 333THE YOUTUßeuu end]])
+ end)
+
+ it('should replace using Enter or NL', function()
+ -- Visual replace using Enter or NL.
+ feed('G3o123456789<ESC>2k05l<C-v>2jr<CR>')
+ feed('G3o98765<ESC>2k02l<C-v>2jr<C-v><CR>')
+ feed('G3o123456789<ESC>2k05l<C-v>2jr<CR>')
+ feed('G3o98765<ESC>2k02l<C-v>2jr<C-v><Nul>')
+
+ local expected = [[
+
+ 12345
+ 789
+ 12345
+ 789
+ 12345
+ 789
+ 98<CR>65
+ 98<CR>65
+ 98<CR>65
+ 12345
+ 789
+ 12345
+ 789
+ 12345
+ 789
+ 98<Nul>65
+ 98<Nul>65
+ 98<Nul>65]]
+ expected = expected:gsub('<CR>', '\r')
+ expected = expected:gsub('<Nul>', '\000')
+
+ expect(expected)
+ end)
+
+ it('should treat cursor position correctly when virtualedit=block', function()
+ insert([[
+ 12345
+ 789
+ 98765]])
+
+ -- Test cursor position. When virtualedit=block and Visual block mode and $gj.
+ execute('set ve=block')
+ feed('G2l')
+ feed('2k<C-v>$gj<ESC>')
+ execute([[let cpos=getpos("'>")]])
+ local cpos = nvim.get_var('cpos')
+ local expected = {
+ col = 4,
+ off = 0
+ }
+ local actual = {
+ col = cpos[3],
+ off = cpos[4]
+ }
+
+ eq(expected, actual)
+ end)
+
+ it('should replace spaces in front of the block with tabs', function()
+ insert([[
+ #define BO_ALL 0x0001
+ #define BO_BS 0x0002
+ #define BO_CRSR 0x0004]])
+
+ -- Block_insert when replacing spaces in front of the block with tabs.
+ execute('set ts=8 sts=4 sw=4')
+ feed('ggf0<C-v>2jI<TAB><ESC>')
+
+ expect([[
+ #define BO_ALL 0x0001
+ #define BO_BS 0x0002
+ #define BO_CRSR 0x0004]])
+ end)
+end)
diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
index efe61aa354..2a4c0149fa 100644
--- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
+++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
@@ -4,7 +4,7 @@
-- This test contains both "test44" and "test99" from the old test suite.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
-- Runs the test protocol with the given 'regexpengine' setting. In the old test
@@ -31,7 +31,8 @@ local function run_test_with_regexpengine(regexpengine)
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]])
+ k combinations
+ l ä ö ü ᾱ̆́]])
execute('set re=' .. regexpengine)
@@ -85,6 +86,11 @@ local function run_test_with_regexpengine(regexpengine)
execute([[let @w=':%s#comb[i]nations#œ̄ṣ́m̥̄ᾱ̆́#g']])
execute('@w')
+ -- Line l. Ex command ":s/ \?/ /g" should NOT split multi-byte characters
+ -- into bytes (fixed by vim-7.3.192).
+ execute([[/^l]])
+ execute([[s/ \?/ /g]])
+
-- Additional tests. Test matchstr() with multi-byte characters.
feed('G')
execute([[put =matchstr(\"אבגד\", \".\", 0, 2)]]) -- ב
@@ -123,6 +129,7 @@ local function run_test_with_regexpengine(regexpengine)
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
new file mode 100644
index 0000000000..04b623ff3b
--- /dev/null
+++ b/test/functional/legacy/045_folding_spec.lua
@@ -0,0 +1,139 @@
+-- Tests for folding.
+
+local helpers = require('test.functional.helpers')
+local feed, insert, clear, execute, expect =
+ helpers.feed, helpers.insert, helpers.clear, helpers.execute, helpers.expect
+
+describe('folding', function()
+ before_each(clear)
+
+ it('is working', function()
+ insert([[
+ 1 aa
+ 2 bb
+ 3 cc
+ 4 dd {{{
+ 5 ee {{{ }}}
+ 6 ff }}}
+ 7 gg
+ 8 hh
+ 9 ii
+ a jj
+ b kk
+ last]])
+
+ -- Basic test if a fold can be created, opened, moving to the end and
+ -- closed.
+ execute('/^1')
+ feed('zf2j')
+ execute('call append("$", "manual " . getline(foldclosed(".")))')
+ feed('zo')
+ execute('call append("$", foldclosed("."))')
+ feed(']z')
+ execute('call append("$", getline("."))')
+ feed('zc')
+ execute('call append("$", getline(foldclosed(".")))')
+ -- Test folding with markers.
+ execute('set fdm=marker fdl=1 fdc=3')
+ execute('/^5')
+ execute('call append("$", "marker " . foldlevel("."))')
+ feed('[z')
+ execute('call append("$", foldlevel("."))')
+ feed('jo{{ <esc>r{jj')
+ execute('call append("$", foldlevel("."))')
+ feed('kYpj')
+ execute('call append("$", foldlevel("."))')
+ -- Test folding with indent.
+ execute('set fdm=indent sw=2')
+ execute('/^2 b')
+ feed('i <esc>jI <esc>')
+ execute('call append("$", "indent " . foldlevel("."))')
+ feed('k')
+ execute('call append("$", foldlevel("."))')
+ -- Test syntax folding.
+ execute('set fdm=syntax fdl=0')
+ execute('syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3')
+ execute('syn region Fd1 start="ee" end="ff" fold contained')
+ execute('syn region Fd2 start="gg" end="hh" fold contained')
+ execute('syn region Fd3 start="commentstart" end="commentend" fold contained')
+ feed('Gzk')
+ execute('call append("$", "folding " . getline("."))')
+ feed('k')
+ execute('call append("$", getline("."))')
+ feed('jAcommentstart <esc>Acommentend<esc>')
+ execute('set fdl=1')
+ feed('3j')
+ execute('call append("$", getline("."))')
+ execute('set fdl=0')
+ feed('zO<C-L>j')
+ execute('call append("$", getline("."))')
+ -- Test expression folding.
+ execute('fun Flvl()')
+ execute(' let l = getline(v:lnum)')
+ execute(' if l =~ "bb$"')
+ execute(' return 2')
+ execute(' elseif l =~ "gg$"')
+ execute(' return "s1"')
+ execute(' elseif l =~ "ii$"')
+ execute(' return ">2"')
+ execute(' elseif l =~ "kk$"')
+ execute(' return "0"')
+ execute(' endif')
+ execute(' return "="')
+ execute('endfun')
+ execute('set fdm=expr fde=Flvl()')
+ execute('/bb$')
+ execute('call append("$", "expr " . foldlevel("."))')
+ execute('/hh$')
+ execute('call append("$", foldlevel("."))')
+ execute('/ii$')
+ execute('call append("$", foldlevel("."))')
+ execute('/kk$')
+ execute('call append("$", foldlevel("."))')
+ execute('0,/^last/delete')
+ execute('delfun Flvl')
+
+ -- Assert buffer contents.
+ expect([[
+ manual 1 aa
+ -1
+ 3 cc
+ 1 aa
+ marker 2
+ 1
+ 1
+ 0
+ indent 2
+ 1
+ folding 9 ii
+ 3 cc
+ 7 gg
+ 8 hh
+ expr 2
+ 1
+ 2
+ 0]])
+ end)
+
+ it('can open after :move', function()
+ insert([[
+ Test fdm=indent and :move bug END
+ line2
+ Test fdm=indent START
+ line3
+ line4]])
+
+ execute('set noai nosta')
+ execute('set fdm=indent')
+ execute('1m1')
+ feed('2jzc')
+ execute('m0')
+
+ expect([[
+ Test fdm=indent START
+ line3
+ line4
+ Test fdm=indent and :move bug END
+ line2]])
+ end)
+end)
diff --git a/test/functional/legacy/046_multi_line_regexps_spec.lua b/test/functional/legacy/046_multi_line_regexps_spec.lua
index f8a6143b18..b17ab42fe3 100644
--- a/test/functional/legacy/046_multi_line_regexps_spec.lua
+++ b/test/functional/legacy/046_multi_line_regexps_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local expect = helpers.expect
describe('multi-line regexp', function()
setup(clear)
diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua
index 620df97aac..94c42b73e5 100644
--- a/test/functional/legacy/051_highlight_spec.lua
+++ b/test/functional/legacy/051_highlight_spec.lua
@@ -3,7 +3,7 @@
local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
local wait = helpers.wait
diff --git a/test/functional/legacy/056_script_local_function_spec.lua b/test/functional/legacy/056_script_local_function_spec.lua
index 147391ceb1..dec88e8001 100644
--- a/test/functional/legacy/056_script_local_function_spec.lua
+++ b/test/functional/legacy/056_script_local_function_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local expect = helpers.expect
describe('source function', function()
setup(clear)
diff --git a/test/functional/legacy/057_sort_spec.lua b/test/functional/legacy/057_sort_spec.lua
index 585b391198..36062ded3a 100644
--- a/test/functional/legacy/057_sort_spec.lua
+++ b/test/functional/legacy/057_sort_spec.lua
@@ -600,4 +600,90 @@ describe(':sort', function()
eq('Vim(sort):E474: Invalid argument', eval('tmpvar'))
expect(text)
end)
+
+ it('binary', function()
+ insert([[
+ 0b111000
+ 0b101100
+ 0b101001
+ 0b101001
+ 0b101000
+ 0b000000
+ 0b001000
+ 0b010000
+ 0b101000
+ 0b100000
+ 0b101010
+ 0b100010
+ 0b100100
+ 0b100010]])
+ execute([[sort b]])
+ expect([[
+ 0b000000
+ 0b001000
+ 0b010000
+ 0b100000
+ 0b100010
+ 0b100010
+ 0b100100
+ 0b101000
+ 0b101000
+ 0b101001
+ 0b101001
+ 0b101010
+ 0b101100
+ 0b111000]])
+ end)
+
+ it('binary with leading characters', function()
+ insert([[
+ 0b100010
+ 0b010000
+ 0b101001
+ b0b101100
+ 0b100010
+ 0b100100
+ a0b001000
+ 0b101000
+ 0b101000
+ a0b101001
+ ab0b100000
+ 0b101010
+ 0b000000
+ b0b111000]])
+ execute([[sort b]])
+ expect([[
+ 0b000000
+ a0b001000
+ 0b010000
+ ab0b100000
+ 0b100010
+ 0b100010
+ 0b100100
+ 0b101000
+ 0b101000
+ 0b101001
+ a0b101001
+ 0b101010
+ b0b101100
+ b0b111000]])
+ end)
+
+ it('float', function()
+ insert([[
+ 1.234
+ 0.88
+ 123.456
+ 1.15e-6
+ -1.1e3
+ -1.01e3]])
+ execute([[sort f]])
+ expect([[
+ -1.1e3
+ -1.01e3
+ 1.15e-6
+ 0.88
+ 1.234
+ 123.456]])
+ end)
end)
diff --git a/test/functional/legacy/059_utf8_spell_checking_spec.lua b/test/functional/legacy/059_utf8_spell_checking_spec.lua
index 5794e875a0..63df387be3 100644
--- a/test/functional/legacy/059_utf8_spell_checking_spec.lua
+++ b/test/functional/legacy/059_utf8_spell_checking_spec.lua
@@ -31,8 +31,6 @@ describe("spell checking with 'encoding' set to utf-8", function()
RAR ?
BAD !
- #NOSPLITSUGS
-
PFX I N 1
PFX I 0 in .
@@ -92,8 +90,6 @@ describe("spell checking with 'encoding' set to utf-8", function()
RAR ?
BAD !
- #NOSPLITSUGS
-
PFX I N 1
PFX I 0 in .
@@ -300,6 +296,24 @@ describe("spell checking with 'encoding' set to utf-8", function()
tail/123
middle/77,1
]])
+ write_latin1('Xtest8.aff', [[
+ SET ISO8859-1
+
+ NOSPLITSUGS
+ ]])
+ write_latin1('Xtest8.dic', [[
+ 1234
+ foo
+ bar
+ faabar
+ ]])
+ write_latin1('Xtest9.aff', [[
+ ]])
+ write_latin1('Xtest9.dic', [[
+ 1234
+ foo
+ bar
+ ]])
write_latin1('Xtest-sal.aff', [[
SET ISO8859-1
TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ
@@ -314,8 +328,6 @@ describe("spell checking with 'encoding' set to utf-8", function()
RAR ?
BAD !
- #NOSPLITSUGS
-
PFX I N 1
PFX I 0 in .
@@ -483,6 +495,10 @@ describe("spell checking with 'encoding' set to utf-8", function()
os.remove('Xtest6.dic')
os.remove('Xtest7.aff')
os.remove('Xtest7.dic')
+ os.remove('Xtest8.aff')
+ os.remove('Xtest8.dic')
+ os.remove('Xtest9.aff')
+ os.remove('Xtest9.dic')
end)
-- Function to test .aff/.dic with list of good and bad words. This was a
@@ -940,4 +956,46 @@ describe("spell checking with 'encoding' set to utf-8", function()
leadprobar
['leadprebar', 'lead prebar', 'leadbar']]=])
end)
+
+ it('part 8-8', function()
+ insert([[
+ 8good: foo bar faabar
+ bad: foobar barfoo
+ badend
+ ]])
+ -- NOSPLITSUGS
+ test_one(8, 8)
+ -- Assert buffer contents.
+ execute('1,/^test 8-8/-1d')
+ expect([=[
+ test 8-8
+ # file: Xtest.utf-8.spl
+ bar
+ faabar
+ foo
+ -------
+ bad
+ ['bar', 'foo']
+ foobar
+ ['faabar', 'foo bar', 'bar']
+ barfoo
+ ['bar foo', 'bar', 'foo']]=])
+ end)
+
+ it('part 9-9', function()
+ insert([[
+ 9good: 0b1011 0777 1234 0x01ff
+ badend
+ ]])
+ -- NOSPLITSUGS
+ test_one(9, 9)
+ -- Assert buffer contents.
+ execute('1,/^test 9-9/-1d')
+ expect([=[
+ test 9-9
+ # file: Xtest.utf-8.spl
+ bar
+ foo
+ -------]=])
+ end)
end)
diff --git a/test/functional/legacy/060_exists_and_has_functions_spec.lua b/test/functional/legacy/060_exists_and_has_functions_spec.lua
index e9b79b490d..7f44b35a4e 100644
--- a/test/functional/legacy/060_exists_and_has_functions_spec.lua
+++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua
@@ -1,8 +1,8 @@
-- Tests for the exists() and has() functions.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
local write_file = helpers.write_file
describe('exists() and has() functions', function()
diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua
index 8cc2a371bb..6db37bf1ff 100644
--- a/test/functional/legacy/061_undo_tree_spec.lua
+++ b/test/functional/legacy/061_undo_tree_spec.lua
@@ -1,8 +1,8 @@
-- Tests for undo tree and :earlier and :later.
local helpers = require('test.functional.helpers')
-local feed, insert, source, eq, eval, clear, execute, expect, wait, write_file
- = helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval,
+local feed, source, eq, eval, clear, execute, expect, wait, write_file =
+ helpers.feed, helpers.source, helpers.eq, helpers.eval,
helpers.clear, helpers.execute, helpers.expect, helpers.wait,
helpers.write_file
@@ -97,9 +97,8 @@ describe('undo tree:', function()
-- Retry up to 3 times. pcall() is _not_ used for the final attempt, so
-- that failure messages can bubble up.
- local success, result = false, ''
- for i = 1, 2 do
- success, result = pcall(test_earlier_later)
+ for _ = 1, 2 do
+ local success = pcall(test_earlier_later)
if success then
return
end
@@ -192,7 +191,7 @@ describe('undo tree:', function()
end)
it('undo an expression-register', function()
- local normal_commands = 'o1\x1ba2\x12=string(123)\n\x1b'
+ local normal_commands = 'o1\027a2\018=string(123)\n\027'
write_file('Xtest.source', normal_commands)
feed('oa<esc>')
diff --git a/test/functional/legacy/062_tab_pages_spec.lua b/test/functional/legacy/062_tab_pages_spec.lua
index 6bbb06f9a7..f1c8b8d58b 100644
--- a/test/functional/legacy/062_tab_pages_spec.lua
+++ b/test/functional/legacy/062_tab_pages_spec.lua
@@ -86,21 +86,35 @@ describe('tab pages', function()
feed('1gt')
eq(1, eval('tabpagenr()'))
execute('tabmove 5')
- eq(6, eval('tabpagenr()'))
- execute('tabmove -2')
+ eq(5, eval('tabpagenr()'))
+ execute('.tabmove')
+ eq(5, eval('tabpagenr()'))
+ execute('tabmove -')
eq(4, eval('tabpagenr()'))
+ execute('tabmove +')
+ eq(5, eval('tabpagenr()'))
+ execute('tabmove -2')
+ eq(3, eval('tabpagenr()'))
execute('tabmove +4')
- eq(8, eval('tabpagenr()'))
+ eq(7, eval('tabpagenr()'))
execute('tabmove')
eq(10, eval('tabpagenr()'))
execute('tabmove -20')
eq(1, eval('tabpagenr()'))
execute('tabmove +20')
eq(10, eval('tabpagenr()'))
+ execute('0tabmove')
+ eq(1, eval('tabpagenr()'))
+ execute('$tabmove')
+ eq(10, eval('tabpagenr()'))
+ execute('tabmove 0')
+ eq(1, eval('tabpagenr()'))
+ execute('tabmove $')
+ eq(10, eval('tabpagenr()'))
execute('3tabmove')
eq(4, eval('tabpagenr()'))
execute('7tabmove 5')
- eq(6, eval('tabpagenr()'))
+ eq(5, eval('tabpagenr()'))
execute('let a="No error caught."')
execute('try')
execute('tabmove foo')
diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua
index d819db7812..23b4f4551b 100644
--- a/test/functional/legacy/063_match_and_matchadd_spec.lua
+++ b/test/functional/legacy/063_match_and_matchadd_spec.lua
@@ -2,10 +2,9 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local eval, clear, execute, expect = helpers.eval, helpers.clear, helpers.execute
-local expect, eq, neq = helpers.expect, helpers.eq, helpers.neq
-local command = helpers.command
+local feed, insert = helpers.feed, helpers.insert
+local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute
+local eq, neq = helpers.eq, helpers.neq
describe('063: Test for ":match", "matchadd()" and related functions', function()
setup(clear)
@@ -86,11 +85,15 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
execute("2match MyGroup2 /HUMPPA/")
execute("3match MyGroup3 /VIM/")
execute("let ml = getmatches()")
- ml = eval("ml")
+ local ml = eval("ml")
execute("call clearmatches()")
execute("call setmatches(ml)")
eq(ml, eval('getmatches()'))
+
+ -- Check that "setmatches()" can correctly restore the matches from matchaddpos()
execute("call clearmatches()")
+ execute("call setmatches(ml)")
+ eq(ml, eval('getmatches()'))
-- Check that "setmatches()" will not add two matches with the same ID. The
-- expected behaviour (for now) is to add the first match but not the
diff --git a/test/functional/legacy/065_float_and_logic_operators_spec.lua b/test/functional/legacy/065_float_and_logic_operators_spec.lua
index 5cdb0b7f58..e78b230956 100644
--- a/test/functional/legacy/065_float_and_logic_operators_spec.lua
+++ b/test/functional/legacy/065_float_and_logic_operators_spec.lua
@@ -1,7 +1,7 @@
-- Test for floating point and logical operators.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local insert, source = helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('floating point and logical operators', function()
diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua
index 6d89ad6d55..dc4c9c7eeb 100644
--- a/test/functional/legacy/067_augroup_exists_spec.lua
+++ b/test/functional/legacy/067_augroup_exists_spec.lua
@@ -2,7 +2,7 @@
-- autocommands.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('augroup when calling exists()', function()
diff --git a/test/functional/legacy/068_text_formatting_spec.lua b/test/functional/legacy/068_text_formatting_spec.lua
new file mode 100644
index 0000000000..cac8be77f3
--- /dev/null
+++ b/test/functional/legacy/068_text_formatting_spec.lua
@@ -0,0 +1,207 @@
+local helpers = require('test.functional.helpers')
+local feed, insert = helpers.feed, helpers.insert
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('text formatting', function()
+ setup(clear)
+
+ it('is working', function()
+ -- The control character <C-A> (byte \x01) needs to be put in the buffer
+ -- directly. But the insert function sends the text to nvim in insert
+ -- mode so it has to be escaped with <C-V>.
+ insert([[
+ Results of test68:
+
+
+ {
+
+
+ }
+
+
+ {
+ a b
+
+ a
+ }
+
+
+ {
+ a 
+ }
+
+
+ {
+ a b
+ #a b
+ }
+
+
+ {
+ 1 a
+ # 1 a
+ }
+
+
+ {
+
+ x a
+ b
+ c
+
+ }
+
+
+ {
+ # 1 a b
+ }
+
+
+ {
+ # x
+ # a b
+ }
+
+
+ {
+ 1aa
+ 2bb
+ }
+
+
+ /* abc def ghi jkl
+ * mno pqr stu
+ */
+
+
+ # 1 xxxxx
+ ]])
+
+ execute('/^{/+1')
+ execute('set noai tw=2 fo=t')
+ feed('gRa b<esc>')
+
+ execute('/^{/+1')
+ execute('set ai tw=2 fo=tw')
+ feed('gqgqjjllab<esc>')
+
+ execute('/^{/+1')
+ execute('set tw=3 fo=t')
+ feed('gqgqo<cr>')
+ feed('a <C-V><C-A><esc><esc>')
+
+ execute('/^{/+1')
+ execute('set tw=2 fo=tcq1 comments=:#')
+ feed('gqgqjgqgqo<cr>')
+ feed('a b<cr>')
+ feed('#a b<esc>')
+
+ execute('/^{/+1')
+ execute('set tw=5 fo=tcn comments=:#')
+ feed('A b<esc>jA b<esc>')
+
+ execute('/^{/+3')
+ execute('set tw=5 fo=t2a si')
+ feed('i <esc>A_<esc>')
+
+ execute('/^{/+1')
+ execute('set tw=5 fo=qn comments=:#')
+ feed('gwap<cr>')
+
+ execute('/^{/+1')
+ execute('set tw=5 fo=q2 comments=:#')
+ feed('gwap<cr>')
+
+ execute('/^{/+2')
+ execute('set tw& fo=a')
+ feed('I^^<esc><esc>')
+
+ execute('/mno pqr/')
+ execute('setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/')
+ feed('A vwx yz<esc>')
+
+ execute('/^#/')
+ execute('setl tw=12 fo=tqnc comments=:#')
+ feed('A foobar<esc>')
+
+ -- Assert buffer contents.
+ expect([[
+ Results of test68:
+
+
+ {
+ a
+ b
+ }
+
+
+ {
+ a
+ b
+
+ a
+ b
+ }
+
+
+ {
+ a
+ 
+
+ a
+ 
+ }
+
+
+ {
+ a b
+ #a b
+
+ a b
+ #a b
+ }
+
+
+ {
+ 1 a
+ b
+ # 1 a
+ # b
+ }
+
+
+ {
+
+ x a
+ b_
+ c
+
+ }
+
+
+ {
+ # 1 a
+ # b
+ }
+
+
+ {
+ # x a
+ # b
+ }
+
+
+ { 1aa ^^2bb }
+
+
+ /* abc def ghi jkl
+ * mno pqr stu
+ * vwx yz
+ */
+
+
+ # 1 xxxxx
+ # foobar
+ ]])
+ end)
+end)
diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua
index ce9129ff43..efcc2f2cc3 100644
--- a/test/functional/legacy/072_undo_file_spec.lua
+++ b/test/functional/legacy/072_undo_file_spec.lua
@@ -3,7 +3,7 @@
-- undo-able pieces. Do that by setting 'undolevels'.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('72', function()
diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua
index 2428b7f74d..49c4827613 100644
--- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua
+++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua
@@ -13,7 +13,7 @@ describe('storing global variables in ShaDa files', function()
end)
it('is working', function()
- local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE',
+ local nvim2 = spawn({helpers.nvim_prog, '-u', 'NONE',
'-i', 'Xviminfo', '--embed'})
helpers.set_session(nvim2)
diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua
index 418abb14d4..82965f5cb2 100644
--- a/test/functional/legacy/075_maparg_spec.lua
+++ b/test/functional/legacy/075_maparg_spec.lua
@@ -2,7 +2,7 @@
-- Also test utf8 map with a 0x80 byte.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
describe('maparg()', function()
diff --git a/test/functional/legacy/077_mf_hash_grow_spec.lua b/test/functional/legacy/077_mf_hash_grow_spec.lua
index 825f08e968..029fe98fe9 100644
--- a/test/functional/legacy/077_mf_hash_grow_spec.lua
+++ b/test/functional/legacy/077_mf_hash_grow_spec.lua
@@ -7,7 +7,7 @@
-- If it isn't available then the test will be skipped.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('mf_hash_grow()', function()
diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua
index 33115c1317..e48fddaac1 100644
--- a/test/functional/legacy/078_swapfile_recover_spec.lua
+++ b/test/functional/legacy/078_swapfile_recover_spec.lua
@@ -4,9 +4,7 @@
-- pointer blocks.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source
-local eval = helpers.eval
+local clear, expect, source = helpers.clear, helpers.expect, helpers.source
describe('78', function()
setup(clear)
diff --git a/test/functional/legacy/080_substitute_spec.lua b/test/functional/legacy/080_substitute_spec.lua
index 89ef7a713c..96082364e0 100644
--- a/test/functional/legacy/080_substitute_spec.lua
+++ b/test/functional/legacy/080_substitute_spec.lua
@@ -3,7 +3,7 @@
-- Test for *:s%* on :substitute.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
local eq, eval = helpers.eq, helpers.eval
diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua
index 1615828ca0..933c6c8fa3 100644
--- a/test/functional/legacy/082_string_comparison_spec.lua
+++ b/test/functional/legacy/082_string_comparison_spec.lua
@@ -2,7 +2,7 @@
-- Also test "g~ap".
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, source = helpers.feed, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('case-insensitive string comparison in UTF-8', function()
diff --git a/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua
new file mode 100644
index 0000000000..6b5ee60568
--- /dev/null
+++ b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua
@@ -0,0 +1,110 @@
+-- Tests for tag search with !_TAG_FILE_ENCODING.
+
+local helpers = require('test.functional.helpers')
+local insert, source, clear, expect, write_file = helpers.insert,
+ helpers.source, helpers.clear, helpers.expect, helpers.write_file
+
+local function has_iconv()
+ clear() -- ensures session
+ return 1 == helpers.eval('has("iconv")')
+end
+
+describe('tag search with !_TAG_FILE_ENCODING', function()
+ setup(function()
+ clear()
+ -- Create some temp files that are needed for the test run. In the old
+ -- test suite this was done by putting the text inside the file test83.in
+ -- and executing some "/first/,/last/w! tmpfile" commands.
+ write_file('Xtags1.txt', 'text for tags1\nabcdefghijklmnopqrs\n')
+ write_file('Xtags2.txt', 'text for tags2\nABC\n')
+ write_file('Xtags3.txt', 'text for tags3\nABC\n')
+ write_file('Xtags1', [[
+ !_TAG_FILE_ENCODING utf-8 //
+ abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs
+ ]])
+ write_file('test83-tags2',
+ '!_TAG_FILE_ENCODING cp932 //\n' ..
+ '\130`\130a\130b Xtags2.txt /\130`\130a\130b\n'
+ )
+ -- The last file is very long but repetetive and can be generated on the
+ -- fly.
+ local text = helpers.dedent([[
+ !_TAG_FILE_SORTED 1 //
+ !_TAG_FILE_ENCODING cp932 //
+ ]])
+ local line = ' Xtags3.txt /\130`\130a\130b\n'
+ for i = 1, 100 do
+ text = text .. 'abc' .. i .. line
+ end
+ write_file('test83-tags3', text)
+ end)
+ teardown(function()
+ os.remove('Xtags1')
+ os.remove('Xtags1.txt')
+ os.remove('Xtags2.txt')
+ os.remove('Xtags3.txt')
+ os.remove('test83-tags2')
+ os.remove('test83-tags3')
+ end)
+
+ if not has_iconv() then
+ pending('skipped (missing iconv)', function() end)
+ else
+ it('is working', function()
+
+ insert('Results of test83')
+
+ -- Case1:
+ source([[
+ new
+ set tags=Xtags1
+ let v:errmsg = ''
+ tag abcdefghijklmnopqrs
+ if v:errmsg =~ 'E426:' || getline('.') != 'abcdefghijklmnopqrs'
+ close
+ put ='case1: failed'
+ else
+ close
+ put ='case1: ok'
+ endif
+ ]])
+
+ -- Case2:
+ source([[
+ new
+ set tags=test83-tags2
+ let v:errmsg = ''
+ tag /.BC
+ if v:errmsg =~ 'E426:' || getline('.') != 'ABC'
+ close
+ put ='case2: failed'
+ else
+ close
+ put ='case2: ok'
+ endif
+ ]])
+
+ -- Case3:
+ source([[
+ new
+ set tags=test83-tags3
+ let v:errmsg = ''
+ tag abc50
+ if v:errmsg =~ 'E426:' || getline('.') != 'ABC'
+ close
+ put ='case3: failed'
+ else
+ close
+ put ='case3: ok'
+ endif
+ ]])
+
+ -- Assert buffer contents.
+ expect([[
+ Results of test83
+ case1: ok
+ case2: ok
+ case3: ok]])
+ end)
+ end
+end)
diff --git a/test/functional/legacy/084_curswant_spec.lua b/test/functional/legacy/084_curswant_spec.lua
index 55df5d3e73..946dd5e501 100644
--- a/test/functional/legacy/084_curswant_spec.lua
+++ b/test/functional/legacy/084_curswant_spec.lua
@@ -1,8 +1,8 @@
-- Tests for curswant not changing when setting an option.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('curswant', function()
setup(clear)
diff --git a/test/functional/legacy/088_conceal_tabs_spec.lua b/test/functional/legacy/088_conceal_tabs_spec.lua
new file mode 100644
index 0000000000..c78f4e5c3e
--- /dev/null
+++ b/test/functional/legacy/088_conceal_tabs_spec.lua
@@ -0,0 +1,96 @@
+-- Tests for correct display (cursor column position) with +conceal and
+-- tabulators.
+
+local helpers = require('test.functional.helpers')
+local feed, insert, clear, execute =
+ helpers.feed, helpers.insert, helpers.clear, helpers.execute
+
+local expect_pos = function(row, col)
+ return helpers.eq({row, col}, helpers.eval('[screenrow(), screencol()]'))
+end
+
+describe('cursor and column position with conceal and tabulators', function()
+ setup(clear)
+
+ it('are working', function()
+ insert([[
+ start:
+ .concealed. text
+ |concealed| text
+
+ .concealed. text
+ |concealed| text
+
+ .a. .b. .c. .d.
+ |a| |b| |c| |d|]])
+
+ -- Conceal settings.
+ execute('set conceallevel=2')
+ execute('set concealcursor=nc')
+ execute('syntax match test /|/ conceal')
+ -- Start test.
+ execute('/^start:')
+ feed('ztj')
+ expect_pos(2, 1)
+ -- We should end up in the same column when running these commands on the
+ -- two lines.
+ feed('ft')
+ expect_pos(2, 17)
+ feed('$')
+ expect_pos(2, 20)
+ feed('0j')
+ expect_pos(3, 1)
+ feed('ft')
+ expect_pos(3, 17)
+ feed('$')
+ expect_pos(3, 20)
+ feed('j0j')
+ expect_pos(5, 8)
+ -- Same for next test block.
+ feed('ft')
+ expect_pos(5, 25)
+ feed('$')
+ expect_pos(5, 28)
+ feed('0j')
+ expect_pos(6, 8)
+ feed('ft')
+ expect_pos(6, 25)
+ feed('$')
+ expect_pos(6, 28)
+ feed('0j0j')
+ expect_pos(8, 1)
+ -- And check W with multiple tabs and conceals in a line.
+ feed('W')
+ expect_pos(8, 9)
+ feed('W')
+ expect_pos(8, 17)
+ feed('W')
+ expect_pos(8, 25)
+ feed('$')
+ expect_pos(8, 27)
+ feed('0j')
+ expect_pos(9, 1)
+ feed('W')
+ expect_pos(9, 9)
+ feed('W')
+ expect_pos(9, 17)
+ feed('W')
+ expect_pos(9, 25)
+ feed('$')
+ expect_pos(9, 26)
+ execute('set lbr')
+ feed('$')
+ expect_pos(9, 26)
+ execute('set list listchars=tab:>-')
+ feed('0')
+ expect_pos(9, 1)
+ feed('W')
+ expect_pos(9, 9)
+ feed('W')
+ expect_pos(9, 17)
+ feed('W')
+ expect_pos(9, 25)
+ feed('$')
+ expect_pos(9, 26)
+ end)
+end)
diff --git a/test/functional/legacy/089_number_relnumber_findfile_spec.lua b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
index 1f8e49cc81..f72ebf3f72 100644
--- a/test/functional/legacy/089_number_relnumber_findfile_spec.lua
+++ b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
@@ -4,7 +4,7 @@
local helpers = require('test.functional.helpers')
local feed = helpers.feed
-local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source
+local clear, expect, source = helpers.clear, helpers.expect, helpers.source
describe("setting 'number' and 'relativenumber'", function()
setup(clear)
diff --git a/test/functional/legacy/090_sha256_spec.lua b/test/functional/legacy/090_sha256_spec.lua
index 35fbd5752e..95e50063a1 100644
--- a/test/functional/legacy/090_sha256_spec.lua
+++ b/test/functional/legacy/090_sha256_spec.lua
@@ -1,8 +1,8 @@
-- Tests for sha256() function.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('sha256()', function()
setup(clear)
diff --git a/test/functional/legacy/091_context_variables_spec.lua b/test/functional/legacy/091_context_variables_spec.lua
index bb9c32b84f..2c46ef643c 100644
--- a/test/functional/legacy/091_context_variables_spec.lua
+++ b/test/functional/legacy/091_context_variables_spec.lua
@@ -1,8 +1,8 @@
-- Tests for getbufvar(), getwinvar(), gettabvar() and gettabwinvar().
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('context variables', function()
setup(clear)
@@ -13,6 +13,9 @@ describe('context variables', function()
-- Test for getbufvar().
-- Use strings to test for memory leaks.
source([[
+ let t:testvar='abcd'
+ $put =string(gettabvar(1, 'testvar'))
+ $put =string(gettabvar(1, 'testvar'))
let b:var_num = '1234'
let def_num = '5678'
$put =string(getbufvar(1, 'var_num'))
@@ -125,6 +128,8 @@ describe('context variables', function()
-- Assert buffer contents.
expect([[
start:
+ 'abcd'
+ 'abcd'
'1234'
'1234'
{'var_num': '1234'}
diff --git a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
index e0cc39dc40..f76ba25d7a 100644
--- a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
+++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
@@ -4,7 +4,7 @@
-- Same as legacy test 93 but using UTF-8 file encoding.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('store cursor position in session file in UTF-8', function()
diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
index 659e716721..bf3af1a827 100644
--- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
+++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
@@ -4,7 +4,7 @@
-- Same as legacy test 92 but using Latin-1 file encoding.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('store cursor position in session file in Latin-1', function()
diff --git a/test/functional/legacy/094_visual_mode_operators_spec.lua b/test/functional/legacy/094_visual_mode_operators_spec.lua
index c4aebe4ecc..4dce39b8d2 100644
--- a/test/functional/legacy/094_visual_mode_operators_spec.lua
+++ b/test/functional/legacy/094_visual_mode_operators_spec.lua
@@ -24,6 +24,27 @@ local function source_user_functions()
]])
end
+local function put_abc()
+ source([[
+ $put ='a'
+ $put ='b'
+ $put ='c']])
+end
+
+local function put_aaabbbccc()
+ source([[
+ $put ='aaa'
+ $put ='bbb'
+ $put ='ccc']])
+end
+
+local function define_select_mode_maps()
+ source([[
+ snoremap <lt>End> <End>
+ snoremap <lt>Down> <Down>
+ snoremap <lt>Del> <Del>]])
+end
+
describe('Visual mode and operator', function()
before_each(function()
clear()
@@ -150,4 +171,228 @@ describe('Visual mode and operator', function()
ok
ok]])
end)
+
+ describe('characterwise visual mode:', function()
+ it('replace last line', function()
+ source([[
+ $put ='a'
+ let @" = 'x']])
+ feed('v$p')
+
+ expect([[
+
+ x]])
+ end)
+
+ it('delete middle line', function()
+ put_abc()
+ feed('kkv$d')
+
+ expect([[
+
+ b
+ c]])
+ end)
+
+ it('delete middle two line', function()
+ put_abc()
+ feed('kkvj$d')
+
+ expect([[
+
+ c]])
+ end)
+
+ it('delete last line', function()
+ put_abc()
+ feed('v$d')
+
+ expect([[
+
+ a
+ b
+ ]])
+ end)
+
+ it('delete last two line', function()
+ put_abc()
+ feed('kvj$d')
+
+ expect([[
+
+ a
+ ]])
+ end)
+ end)
+
+ describe('characterwise select mode:', function()
+ before_each(function()
+ define_select_mode_maps()
+ end)
+
+ it('delete middle line', function()
+ put_abc()
+ feed('kkgh<End><Del>')
+
+ expect([[
+
+ b
+ c]])
+ end)
+
+ it('delete middle two line', function()
+ put_abc()
+ feed('kkgh<Down><End><Del>')
+
+ expect([[
+
+ c]])
+ end)
+
+ it('delete last line', function()
+ put_abc()
+ feed('gh<End><Del>')
+
+ expect([[
+
+ a
+ b
+ ]])
+ end)
+
+ it('delete last two line', function()
+ put_abc()
+ feed('kgh<Down><End><Del>')
+
+ expect([[
+
+ a
+ ]])
+ end)
+ end)
+
+ describe('linewise select mode:', function()
+ before_each(function()
+ define_select_mode_maps()
+ end)
+
+ it('delete middle line', function()
+ put_abc()
+ feed(' kkgH<Del> ')
+
+ expect([[
+
+ b
+ c]])
+ end)
+
+ it('delete middle two line', function()
+ put_abc()
+ feed('kkgH<Down><Del>')
+
+ expect([[
+
+ c]])
+ end)
+
+ it('delete last line', function()
+ put_abc()
+ feed('gH<Del>')
+
+ expect([[
+
+ a
+ b]])
+ end)
+
+ it('delete last two line', function()
+ put_abc()
+ feed('kgH<Down><Del>')
+
+ expect([[
+
+ a]])
+ end)
+ end)
+
+ describe('v_p:', function()
+ it('replace last character with line register at middle line', function()
+ put_aaabbbccc()
+ execute('-2yank')
+ feed('k$vp')
+
+ expect([[
+
+ aaa
+ bb
+ aaa
+
+ ccc]])
+ end)
+
+ it('replace last character with line register at middle line selecting newline', function()
+ put_aaabbbccc()
+ execute('-2yank')
+ feed('k$v$p')
+
+ expect([[
+
+ aaa
+ bb
+ aaa
+ ccc]])
+ end)
+
+ it('replace last character with line register at last line', function()
+ put_aaabbbccc()
+ execute('-2yank')
+ feed('$vp')
+
+ expect([[
+
+ aaa
+ bbb
+ cc
+ aaa
+ ]])
+ end)
+
+ it('replace last character with line register at last line selecting newline', function()
+ put_aaabbbccc()
+ execute('-2yank')
+ feed('$v$p')
+
+ expect([[
+
+ aaa
+ bbb
+ cc
+ aaa
+ ]])
+ end)
+ end)
+
+ it('gv in exclusive select mode after operation', function()
+ source([[
+ $put ='zzz '
+ $put ='äà '
+ set selection=exclusive]])
+ feed('kv3lyjv3lpgvcxxx<Esc>')
+
+ expect([[
+
+ zzz
+ xxx ]])
+ end)
+
+ it('gv in exclusive select mode without operation', function()
+ source([[
+ $put ='zzz '
+ set selection=exclusive]])
+ feed('0v3l<Esc>gvcxxx<Esc>')
+
+ expect([[
+
+ xxx ]])
+ end)
end)
diff --git a/test/functional/legacy/095_regexp_multibyte_spec.lua b/test/functional/legacy/095_regexp_multibyte_spec.lua
index 559222e2ff..a80a247612 100644
--- a/test/functional/legacy/095_regexp_multibyte_spec.lua
+++ b/test/functional/legacy/095_regexp_multibyte_spec.lua
@@ -4,8 +4,8 @@
-- actually tried.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('regex with multi-byte', function()
setup(clear)
diff --git a/test/functional/legacy/096_location_list_spec.lua b/test/functional/legacy/096_location_list_spec.lua
index 2ccfd3530d..6e2f22ea33 100644
--- a/test/functional/legacy/096_location_list_spec.lua
+++ b/test/functional/legacy/096_location_list_spec.lua
@@ -7,7 +7,7 @@
-- it belongs to.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local source = helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('location list', function()
diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua
index 84f26478ac..5c467fbb20 100644
--- a/test/functional/legacy/097_glob_path_spec.lua
+++ b/test/functional/legacy/097_glob_path_spec.lua
@@ -3,7 +3,7 @@
-- characters.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('glob() and globpath()', function()
diff --git a/test/functional/legacy/098_scrollbind_spec.lua b/test/functional/legacy/098_scrollbind_spec.lua
index 7b2059e38b..6850e373ab 100644
--- a/test/functional/legacy/098_scrollbind_spec.lua
+++ b/test/functional/legacy/098_scrollbind_spec.lua
@@ -1,8 +1,8 @@
-- Test for 'scrollbind' causing an unexpected scroll of one of the windows.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('scrollbind', function()
setup(clear)
diff --git a/test/functional/legacy/100_undo_level_spec.lua b/test/functional/legacy/100_undo_level_spec.lua
deleted file mode 100644
index 9143d9e540..0000000000
--- a/test/functional/legacy/100_undo_level_spec.lua
+++ /dev/null
@@ -1,142 +0,0 @@
--- Tests for 'undolevel' setting being global-local
-
-local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
-
-describe('undolevel', function()
- setup(clear)
-
- it('is working', function()
- source([[
- set ul=5
- fu! FillBuffer()
- for i in range(1,13)
- put=i
- exe "setg ul=" . &g:ul
- endfor
- endfu
- fu! UndoLevel()
- redir @z
- setglobal undolevels?
- echon ' global'
- setlocal undolevels?
- echon ' local'
- redir end
- $put z
- endfu
-
- 0put ='ONE: expecting global undolevels: 5, local undolevels: -123456 (default)'
- call FillBuffer()
- setlocal undolevels<
- earlier 10
- call UndoLevel()
- set ff=unix
- %yank A
- %delete
-
- 0put ='TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards)'
- setlocal ul=2
- call FillBuffer()
- earlier 10
- call UndoLevel()
- setlocal ul=10
- call UndoLevel()
- set ff=unix
- %yank A
- %delete
- setlocal undolevels<
- redir @A
- echo "global value shouldn't be changed and still be 5!"
- echo 'ONE: expecting global undolevels: 5, local undolevels: -123456 (default)'
- setglobal undolevels?
- echon ' global'
- setlocal undolevels?
- echon ' local'
- echo ""
- redir end
-
- setglobal ul=50
- 1put ='global value should be changed to 50'
- 2put ='THREE: expecting global undolevels: 50, local undolevels: -123456 (default)'
- call UndoLevel()
- set ff=unix
- %yank A
- %delete
- setglobal lispwords=foo,bar,baz
- setlocal lispwords-=foo
- setlocal lispwords+=quux
- redir @A
- echo "Testing 'lispwords' local value"
- setglobal lispwords?
- setlocal lispwords?
- echo &lispwords
- echo ''
- redir end
- setlocal lispwords<
- redir @A
- echo "Testing 'lispwords' value reset"
- setglobal lispwords?
- setlocal lispwords?
- echo &lispwords
- redir end
-
- 0put a
- $d
- ]])
-
- -- Assert buffer contents.
- expect([[
- ONE: expecting global undolevels: 5, local undolevels: -123456 (default)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
-
-
- undolevels=5 global
- undolevels=-123456 local
- TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
-
- undolevels=5 global
- undolevels=2 local
-
- undolevels=5 global
- undolevels=10 local
-
- global value shouldn't be changed and still be 5!
- ONE: expecting global undolevels: 5, local undolevels: -123456 (default)
- undolevels=5 global
- undolevels=-123456 local
-
- global value should be changed to 50
- THREE: expecting global undolevels: 50, local undolevels: -123456 (default)
-
- undolevels=50 global
- undolevels=-123456 local
-
- Testing 'lispwords' local value
- lispwords=foo,bar,baz
- lispwords=bar,baz,quux
- bar,baz,quux
-
- Testing 'lispwords' value reset
- lispwords=foo,bar,baz
- lispwords=foo,bar,baz
- foo,bar,baz]])
- end)
-end)
diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua
index 4b8b1cef50..335d275c2a 100644
--- a/test/functional/legacy/101_hlsearch_spec.lua
+++ b/test/functional/legacy/101_hlsearch_spec.lua
@@ -1,9 +1,8 @@
-- Test for v:hlsearch
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
-local eval = helpers.eval
describe('v:hlsearch', function()
setup(clear)
diff --git a/test/functional/legacy/102_fnameescape_spec.lua b/test/functional/legacy/102_fnameescape_spec.lua
index 251ce68430..a3b0313d7a 100644
--- a/test/functional/legacy/102_fnameescape_spec.lua
+++ b/test/functional/legacy/102_fnameescape_spec.lua
@@ -1,7 +1,7 @@
-- Test if fnameescape is correct for special chars like!
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('fnameescape', function()
diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua
index 6b2f3bc1b6..c1407ef10a 100644
--- a/test/functional/legacy/103_visual_mode_reset_spec.lua
+++ b/test/functional/legacy/103_visual_mode_reset_spec.lua
@@ -1,8 +1,8 @@
-- Test for visual mode not being reset causing E315 error.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local feed, source = helpers.feed, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('E315 error', function()
setup(clear)
diff --git a/test/functional/legacy/105_filename_modifiers_spec.lua b/test/functional/legacy/105_filename_modifiers_spec.lua
deleted file mode 100644
index 3b417a88eb..0000000000
--- a/test/functional/legacy/105_filename_modifiers_spec.lua
+++ /dev/null
@@ -1,81 +0,0 @@
--- Test filename modifiers.
-
-local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
-
-describe('filename modifiers', function()
- setup(clear)
-
- it('is working', function()
- local tmpdir = helpers.nvim('eval', 'resolve("/tmp")')
-
- execute('cd ' .. tmpdir)
- execute([=[set shell=sh]=])
- execute([=[set shellslash]=])
- execute([=[let tab="\t"]=])
- execute([=[command -nargs=1 Put :let expr=<q-args> | $put =expr.tab.strtrans(string(eval(expr)))]=])
- execute([=[let $HOME=fnamemodify('.', ':p:h:h:h')]=])
- execute([=[Put fnamemodify('.', ':p' )[-1:]]=])
- execute([=[Put fnamemodify('.', ':p:h' )[-1:]]=])
- execute([=[Put fnamemodify('test.out', ':p' )[-1:]]=])
- execute([=[Put fnamemodify('test.out', ':.' )]=])
- execute([=[Put fnamemodify('../testdir/a', ':.' )]=])
- execute([=[Put fnamemodify('test.out', ':~' )]=])
- execute([=[Put fnamemodify('../testdir/a', ':~' )]=])
- execute([=[Put fnamemodify('../testdir/a', ':t' )]=])
- execute([=[Put fnamemodify('.', ':p:t' )]=])
- execute([=[Put fnamemodify('test.out', ':p:t' )]=])
- execute([=[Put fnamemodify('test.out', ':p:e' )]=])
- execute([=[Put fnamemodify('test.out', ':p:t:e' )]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':r' )]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':r:r' )]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':r:r:r' )]=])
- execute([=[Put substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(nvim/testdir/.*\)', '\1', '')]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e' )]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e' )]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e:e' )]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e:e:e')]=])
- execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e:r' )]=])
- execute([=[Put fnamemodify('abc def', ':S' )]=])
- execute([=[Put fnamemodify('abc" "def', ':S' )]=])
- execute([=[Put fnamemodify('abc"%"def', ':S' )]=])
- execute([=[Put fnamemodify('abc'' ''def', ':S' )]=])
- execute([=[Put fnamemodify('abc''%''def', ':S' )]=])
- execute([=[Put fnamemodify("abc\ndef", ':S' )]=])
- execute([=[set shell=tcsh]=])
- execute([=[Put fnamemodify("abc\ndef", ':S' )]=])
- execute([=[1 delete _]=])
-
- -- Assert buffer contents.
- expect([=[
- fnamemodify('.', ':p' )[-1:] '/'
- fnamemodify('.', ':p:h' )[-1:] 'p'
- fnamemodify('test.out', ':p' )[-1:] 't'
- fnamemodify('test.out', ':.' ) 'test.out'
- fnamemodify('../testdir/a', ':.' ) '../testdir/a'
- fnamemodify('test.out', ':~' ) 'test.out'
- fnamemodify('../testdir/a', ':~' ) '../testdir/a'
- fnamemodify('../testdir/a', ':t' ) 'a'
- fnamemodify('.', ':p:t' ) ''
- fnamemodify('test.out', ':p:t' ) 'test.out'
- fnamemodify('test.out', ':p:e' ) 'out'
- fnamemodify('test.out', ':p:t:e' ) 'out'
- fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
- fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
- fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
- substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(nvim/testdir/.*\)', '\1', '') ']=] .. tmpdir .. [=[/abc.fb2'
- fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
- fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
- fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
- fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
- fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
- fnamemodify('abc def', ':S' ) '''abc def'''
- fnamemodify('abc" "def', ':S' ) '''abc" "def'''
- fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
- fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
- fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
- fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
- fnamemodify("abc\ndef", ':S' ) '''abc\^@def''']=])
- end)
-end)
diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua
index 5b6037f928..5958f1aa7b 100644
--- a/test/functional/legacy/106_errorformat_spec.lua
+++ b/test/functional/legacy/106_errorformat_spec.lua
@@ -1,7 +1,7 @@
-- Tests for errorformat.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('errorformat', function()
diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua
index f6ea7e5a6c..7a6de3d748 100644
--- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua
+++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua
@@ -2,8 +2,8 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert = helpers.insert
+local clear, execute = helpers.clear, helpers.execute
describe('107', function()
setup(clear)
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua
new file mode 100644
index 0000000000..1ce665360d
--- /dev/null
+++ b/test/functional/legacy/assert_spec.lua
@@ -0,0 +1,145 @@
+local helpers = require('test.functional.helpers')
+local nvim, call = helpers.meths, helpers.call
+local clear, eq = helpers.clear, helpers.eq
+local source, execute = helpers.source, helpers.execute
+
+local function expected_errors(errors)
+ eq(errors, nvim.get_vvar('errors'))
+end
+
+local function expected_empty()
+ eq({}, nvim.get_vvar('errors'))
+end
+
+describe('assert function:', function()
+
+ before_each(function()
+ clear()
+ end)
+
+ -- assert_equal({expected}, {actual}, [, {msg}])
+ describe('assert_equal', function()
+ it('should not change v:errors when expected is equal to actual', function()
+ source([[
+ let s = 'foo'
+ call assert_equal('foo', s)
+ let n = 4
+ call assert_equal(4, n)
+ let l = [1, 2, 3]
+ call assert_equal([1, 2, 3], l)
+ fu Func()
+ endfu
+ let F1 = function('Func')
+ let F2 = function('Func')
+ call assert_equal(F1, F2)
+ ]])
+ expected_empty()
+ end)
+
+ it('should not change v:errors when expected is equal to actual', function()
+ call('assert_equal', '', '')
+ call('assert_equal', 'string', 'string')
+ expected_empty()
+ end)
+
+ it('should change v:errors when expected is not equal to actual', function()
+ call('assert_equal', 0, {0})
+ expected_errors({'Expected 0 but got [0]'})
+ end)
+
+ it('should change v:errors when expected is not equal to actual', function()
+ call('assert_equal', 0, "0")
+ expected_errors({"Expected 0 but got '0'"})
+ end)
+
+ it('should change v:errors when expected is not equal to actual', function()
+ -- Lua does not tell integer from float.
+ execute('call assert_equal(1, 1.0)')
+ expected_errors({'Expected 1 but got 1.0'})
+ end)
+
+ it('should change v:errors when expected is not equal to actual', function()
+ call('assert_equal', 'true', 'false')
+ expected_errors({"Expected 'true' but got 'false'"})
+ end)
+ end)
+
+ -- assert_false({actual}, [, {msg}])
+ describe('assert_false', function()
+ it('should not change v:errors when actual is false', function()
+ call('assert_false', 0)
+ call('assert_false', false)
+ expected_empty()
+ end)
+
+ it('should change v:errors when actual is not false', function()
+ call('assert_false', 1)
+ expected_errors({'Expected False but got 1'})
+ end)
+
+ it('should change v:errors when actual is not false', function()
+ call('assert_false', {})
+ expected_errors({'Expected False but got []'})
+ end)
+ end)
+
+ -- assert_true({actual}, [, {msg}])
+ describe('assert_true', function()
+ it('should not change v:errors when actual is true', function()
+ call('assert_true', 1)
+ call('assert_true', -1) -- In Vim script, non-zero Numbers are TRUE.
+ call('assert_true', true)
+ expected_empty()
+ end)
+
+ it('should change v:errors when actual is not true', function()
+ call('assert_true', 1.5)
+ expected_errors({'Expected True but got 1.5'})
+ end)
+ end)
+
+ describe('v:errors', function()
+ it('should be initialized at startup', function()
+ expected_empty()
+ end)
+
+ it('should have function names and relative line numbers', function()
+ source([[
+ fu Func_one()
+ call assert_equal([0], {'0' : 0})
+ call assert_false('False')
+ call assert_true("True")
+ endfu
+ fu Func_two()
+ " for shifting a line number
+ call assert_true('line two')
+ endfu
+ ]])
+ call('Func_one')
+ call('Func_two')
+ expected_errors({
+ "function Func_one line 1: Expected [0] but got {'0': 0}",
+ "function Func_one line 2: Expected False but got 'False'",
+ "function Func_one line 3: Expected True but got 'True'",
+ "function Func_two line 2: Expected True but got 'line two'",
+ })
+ end)
+
+ it('should have file names and passed messages', function()
+ local tmpname_one = source([[
+ call assert_equal(1, 100, 'equal assertion failed')
+ call assert_false('true', 'true assertion failed')
+ call assert_true('false', 'false assertion failed')
+ ]])
+ local tmpname_two = source([[
+ call assert_true('', 'file two')
+ ]])
+ expected_errors({
+ tmpname_one .. " line 1: 'equal assertion failed'",
+ tmpname_one .. " line 2: 'true assertion failed'",
+ tmpname_one .. " line 3: 'false assertion failed'",
+ tmpname_two .. " line 1: 'file two'",
+ })
+ end)
+ end)
+end)
diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua
new file mode 100644
index 0000000000..6349371808
--- /dev/null
+++ b/test/functional/legacy/autocmd_option_spec.lua
@@ -0,0 +1,318 @@
+local helpers = require('test.functional.helpers')
+local nvim = helpers.meths
+local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
+local curbuf, buf = helpers.curbuf, helpers.bufmeths
+local curwin = helpers.curwin
+local redir_exec = helpers.redir_exec
+local source, execute = helpers.source, helpers.execute
+
+local function declare_hook_function()
+ source([[
+ fu! AutoCommand(match, bufnr, winnr)
+ let l:acc = {
+ \ 'option' : a:match,
+ \ 'oldval' : v:option_old,
+ \ 'newval' : v:option_new,
+ \ 'scope' : v:option_type,
+ \ 'attr' : {
+ \ 'bufnr' : a:bufnr,
+ \ 'winnr' : a:winnr,
+ \ }
+ \ }
+ call add(g:ret, l:acc)
+ endfu
+ ]])
+end
+
+local function set_hook(pattern)
+ execute(
+ 'au OptionSet '
+ .. pattern ..
+ ' :call AutoCommand(expand("<amatch>"), bufnr("%"), winnr())'
+ )
+end
+
+local function init_var()
+ execute('let g:ret = []')
+end
+
+local function get_result()
+ local ret = nvim.get_var('ret')
+ init_var()
+ return ret
+end
+
+local function expected_table(option, oldval, newval, scope, attr)
+ return {
+ option = option,
+ oldval = tostring(oldval),
+ newval = tostring(newval),
+ scope = scope,
+ attr = attr,
+ }
+end
+
+local function expected_combination(...)
+ local args = {...}
+ local ret = get_result()
+
+ if not (#args == #ret) then
+ local expecteds = {}
+ for _, v in pairs(args) do
+ table.insert(expecteds, expected_table(unpack(v)))
+ end
+ eq(expecteds, ret)
+ return
+ end
+
+ for i, v in ipairs(args) do
+ local attr = v[5]
+ if not attr then
+ -- remove attr entries
+ ret[i].attr = nil
+ else
+ -- remove attr entries which are not required
+ for k in pairs(ret[i].attr) do
+ if not attr[k] then
+ ret[i].attr[k] = nil
+ end
+ end
+ end
+ eq(expected_table(unpack(v)), ret[i])
+ end
+end
+
+local function expected_empty()
+ eq({}, get_result())
+end
+
+local function make_buffer()
+ local old_buf = curbuf()
+ execute('botright new')
+ local new_buf = curbuf()
+ execute('wincmd p') -- move previous window
+
+ neq(old_buf, new_buf)
+ eq(old_buf, curbuf())
+
+ return new_buf
+end
+
+local function get_new_window_number()
+ local old_win = curwin()
+ execute('botright new')
+ local new_win = curwin()
+ local new_winnr = redir_exec('echo winnr()')
+ execute('wincmd p') -- move previous window
+
+ neq(old_win, new_win)
+ eq(old_win, curwin())
+
+ return new_winnr:gsub('\n', '')
+end
+
+describe('au OptionSet', function()
+ describe('with any opton (*)', function()
+
+ before_each(function()
+ clear()
+ declare_hook_function()
+ init_var()
+ set_hook('*')
+ end)
+
+ it('should be called in setting number option', function()
+ execute('set nu')
+ expected_combination({'number', 0, 1, 'global'})
+
+ execute('setlocal nonu')
+ expected_combination({'number', 1, 0, 'local'})
+
+ execute('setglobal nonu')
+ expected_combination({'number', 1, 0, 'global'})
+ end)
+
+ it('should be called in setting autoindent option',function()
+ execute('setlocal ai')
+ expected_combination({'autoindent', 0, 1, 'local'})
+
+ execute('setglobal ai')
+ expected_combination({'autoindent', 0, 1, 'global'})
+
+ execute('set noai')
+ expected_combination({'autoindent', 1, 0, 'global'})
+ end)
+
+ it('should be called in inverting global autoindent option',function()
+ execute('set ai!')
+ expected_combination({'autoindent', 0, 1, 'global'})
+ end)
+
+ it('should be called in being unset local autoindent option',function()
+ execute('setlocal ai')
+ expected_combination({'autoindent', 0, 1, 'local'})
+
+ execute('setlocal ai<')
+ expected_combination({'autoindent', 1, 0, 'local'})
+ end)
+
+ it('should be called in setting global list and number option at the same time',function()
+ execute('set list nu')
+ expected_combination(
+ {'list', 0, 1, 'global'},
+ {'number', 0, 1, 'global'}
+ )
+ end)
+
+ it('should not print anything, use :noa', function()
+ execute('noa set nolist nonu')
+ expected_empty()
+ end)
+
+ it('should be called in setting local acd', function()
+ execute('setlocal acd')
+ expected_combination({'autochdir', 0, 1, 'local'})
+ end)
+
+ it('should be called in setting autoread', function()
+ execute('set noar')
+ expected_combination({'autoread', 1, 0, 'global'})
+
+ execute('setlocal ar')
+ expected_combination({'autoread', 0, 1, 'local'})
+ end)
+
+ it('should be called in inverting global autoread', function()
+ execute('setglobal invar')
+ expected_combination({'autoread', 1, 0, 'global'})
+ end)
+
+ it('should be called in setting backspace option through :let', function()
+ execute('let &bs=""')
+ expected_combination({'backspace', 'indent,eol,start', '', 'global'})
+ end)
+
+ describe('being set by setbufvar()', function()
+ it('should not trigger because option name is invalid', function()
+ execute('call setbufvar(1, "&l:bk", 1)')
+ expected_empty()
+ end)
+
+ it('should trigger using correct option name', function()
+ execute('call setbufvar(1, "&backup", 1)')
+ expected_combination({'backup', 0, 1, 'local'})
+ end)
+
+ it('should trigger if the current buffer is different from the targetted buffer', function()
+ local new_buffer = make_buffer()
+ local new_bufnr = buf.get_number(new_buffer)
+
+ execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
+ expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}})
+ end)
+ end)
+ end)
+
+ describe('with specific option', function()
+
+ before_each(function()
+ clear()
+ declare_hook_function()
+ init_var()
+ end)
+
+ it('should be called iff setting readonly', function()
+ set_hook('readonly')
+
+ execute('set nu')
+ expected_empty()
+
+ execute('setlocal ro')
+ expected_combination({'readonly', 0, 1, 'local'})
+
+ execute('setglobal ro')
+ expected_combination({'readonly', 0, 1, 'global'})
+
+ execute('set noro')
+ expected_combination({'readonly', 1, 0, 'global'})
+ end)
+
+ describe('being set by setbufvar()', function()
+ it('should not trigger because option name does not match with backup', function()
+ set_hook('backup')
+
+ execute('call setbufvar(1, "&l:bk", 1)')
+ expected_empty()
+ end)
+
+ it('should trigger, use correct option name backup', function()
+ set_hook('backup')
+
+ execute('call setbufvar(1, "&backup", 1)')
+ expected_combination({'backup', 0, 1, 'local'})
+ end)
+
+ it('should trigger if the current buffer is different from the targetted buffer', function()
+ set_hook('buftype')
+
+ local new_buffer = make_buffer()
+ local new_bufnr = buf.get_number(new_buffer)
+
+ execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
+ expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}})
+ end)
+ end)
+
+ describe('being set by setwinvar()', function()
+ it('should not trigger because option name does not match with backup', function()
+ set_hook('backup')
+
+ execute('call setwinvar(1, "&l:bk", 1)')
+ expected_empty()
+ end)
+
+ it('should trigger, use correct option name backup', function()
+ set_hook('backup')
+
+ execute('call setwinvar(1, "&backup", 1)')
+ expected_combination({'backup', 0, 1, 'local'})
+ end)
+
+ it('should not trigger if the current window is different from the targetted window', function()
+ set_hook('cursorcolumn')
+
+ local new_winnr = get_new_window_number()
+
+ execute('call setwinvar(' .. new_winnr .. ', "&cursorcolumn", 1)')
+ -- expected_combination({'cursorcolumn', 0, 1, 'local', {winnr = new_winnr}})
+ expected_empty()
+ end)
+ end)
+
+ describe('being set by neovim api', function()
+ it('should trigger if a boolean option be set globally', function()
+ set_hook('autochdir')
+
+ nvim.set_option('autochdir', true)
+ eq(true, nvim.get_option('autochdir'))
+ expected_combination({'autochdir', '0', '1', 'global'})
+ end)
+
+ it('should trigger if a number option be set globally', function()
+ set_hook('cmdheight')
+
+ nvim.set_option('cmdheight', 5)
+ eq(5, nvim.get_option('cmdheight'))
+ expected_combination({'cmdheight', 1, 5, 'global'})
+ end)
+
+ it('should trigger if a string option be set globally', function()
+ set_hook('ambiwidth')
+
+ nvim.set_option('ambiwidth', 'double')
+ eq('double', nvim.get_option('ambiwidth'))
+ expected_combination({'ambiwidth', 'single', 'double', 'global'})
+ end)
+ end)
+ end)
+end)
diff --git a/test/functional/legacy/backspace_opt_spec.lua b/test/functional/legacy/backspace_opt_spec.lua
new file mode 100644
index 0000000000..b40019a410
--- /dev/null
+++ b/test/functional/legacy/backspace_opt_spec.lua
@@ -0,0 +1,67 @@
+local helpers = require('test.functional.helpers')
+local call, clear = helpers.call, helpers.clear
+local source, eq, nvim = helpers.source, helpers.eq, helpers.meths
+
+describe("test 'backspace' settings", function()
+ before_each(function()
+ clear()
+
+ source([[
+ func Exec(expr)
+ let str=''
+ try
+ exec a:expr
+ catch /.*/
+ let str=v:exception
+ endtry
+ return str
+ endfunc
+
+ func Test_backspace_option()
+ set backspace=
+ call assert_equal('', &backspace)
+ set backspace=indent
+ call assert_equal('indent', &backspace)
+ set backspace=eol
+ call assert_equal('eol', &backspace)
+ set backspace=start
+ call assert_equal('start', &backspace)
+ " Add the value
+ set backspace=
+ set backspace=indent
+ call assert_equal('indent', &backspace)
+ set backspace+=eol
+ call assert_equal('indent,eol', &backspace)
+ set backspace+=start
+ call assert_equal('indent,eol,start', &backspace)
+ " Delete the value
+ set backspace-=indent
+ call assert_equal('eol,start', &backspace)
+ set backspace-=start
+ call assert_equal('eol', &backspace)
+ set backspace-=eol
+ call assert_equal('', &backspace)
+ " Check the error
+ call assert_equal(0, match(Exec('set backspace=ABC'), '.*E474'))
+ call assert_equal(0, match(Exec('set backspace+=def'), '.*E474'))
+ " NOTE: Vim doesn't check following error...
+ "call assert_equal(0, match(Exec('set backspace-=ghi'), '.*E474'))
+
+ " Check backwards compatibility with version 5.4 and earlier
+ set backspace=0
+ call assert_equal('0', &backspace)
+ set backspace=1
+ call assert_equal('1', &backspace)
+ set backspace=2
+ call assert_equal('2', &backspace)
+ call assert_false(match(Exec('set backspace=3'), '.*E474'))
+ call assert_false(match(Exec('set backspace=10'), '.*E474'))
+ endfunc
+ ]])
+ end)
+
+ it('works', function()
+ call('Test_backspace_option')
+ eq({}, nvim.get_vvar('errors'))
+ end)
+end)
diff --git a/test/functional/legacy/cdo_spec.lua b/test/functional/legacy/cdo_spec.lua
new file mode 100644
index 0000000000..4b313ede3f
--- /dev/null
+++ b/test/functional/legacy/cdo_spec.lua
@@ -0,0 +1,226 @@
+-- Tests for the :cdo, :cfdo, :ldo and :lfdo commands
+
+local helpers = require('test.functional.helpers')
+local nvim, clear = helpers.meths, helpers.clear
+local call, feed = helpers.call, helpers.feed
+local source, eq = helpers.source, helpers.eq
+
+local function expected_empty()
+ eq({}, nvim.get_vvar('errors'))
+end
+
+describe('cdo', function()
+ before_each(function()
+ clear()
+
+ call('writefile', {'Line1', 'Line2', 'Line3'}, 'Xtestfile1')
+ call('writefile', {'Line1', 'Line2', 'Line3'}, 'Xtestfile2')
+ call('writefile', {'Line1', 'Line2', 'Line3'}, 'Xtestfile3')
+
+ source([=[
+ " Returns the current line in '<filename> <linenum>L <column>C' format
+ function GetRuler()
+ return expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C'
+ endfunction
+
+ " Tests for the :cdo and :ldo commands
+ function XdoTests(cchar)
+ enew
+
+ " Shortcuts for calling the cdo and ldo commands
+ let Xdo = a:cchar . 'do'
+ let Xgetexpr = a:cchar . 'getexpr'
+ let Xprev = a:cchar. 'prev'
+ let XdoCmd = Xdo . ' call add(l, GetRuler())'
+
+ " Try with an empty list
+ let l = []
+ exe XdoCmd
+ call assert_equal([], l)
+
+ " Populate the list and then try
+ exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:3:1:Line3']"
+
+ let l = []
+ exe XdoCmd
+ call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l)
+
+ " Run command only on selected error lines
+ let l = []
+ enew
+ exe "2,3" . XdoCmd
+ call assert_equal(['Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l)
+
+ " Boundary condition tests
+ let l = []
+ enew
+ exe "1,1" . XdoCmd
+ call assert_equal(['Xtestfile1 1L 3C'], l)
+
+ let l = []
+ enew
+ exe "3" . XdoCmd
+ call assert_equal(['Xtestfile3 3L 1C'], l)
+
+ " Range test commands
+ let l = []
+ enew
+ exe "%" . XdoCmd
+ call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l)
+
+ let l = []
+ enew
+ exe "1,$" . XdoCmd
+ call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l)
+
+ let l = []
+ enew
+ exe Xprev
+ exe "." . XdoCmd
+ call assert_equal(['Xtestfile2 2L 2C'], l)
+
+ let l = []
+ enew
+ exe "+" . XdoCmd
+ call assert_equal(['Xtestfile3 3L 1C'], l)
+
+ " Invalid error lines test
+ let l = []
+ enew
+ exe "silent! 27" . XdoCmd
+ exe "silent! 4,5" . XdoCmd
+ call assert_equal([], l)
+
+ " Run commands from an unsaved buffer
+ let v:errmsg=''
+ let l = []
+ enew
+ setlocal modified
+ exe "silent! 2,2" . XdoCmd
+ if v:errmsg !~# 'No write since last change'
+ call add(v:errors, 'Unsaved file change test failed')
+ endif
+
+ " If the executed command fails, then the operation should be aborted
+ enew!
+ let subst_count = 0
+ exe "silent!" . Xdo . " s/Line/xLine/ | let subst_count += 1"
+ if subst_count != 1 || getline('.') != 'xLine1'
+ call add(v:errors, 'Abort command on error test failed')
+ endif
+
+ let l = []
+ exe "2,2" . Xdo . "! call add(l, GetRuler())"
+ call assert_equal(['Xtestfile2 2L 2C'], l)
+
+ " List with no valid error entries
+ let l = []
+ edit! +2 Xtestfile1
+ exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']"
+ exe XdoCmd
+ call assert_equal([], l)
+ exe "silent! 2" . XdoCmd
+ call assert_equal([], l)
+ let v:errmsg=''
+ exe "%" . XdoCmd
+ exe "1,$" . XdoCmd
+ exe "." . XdoCmd
+ call assert_equal('', v:errmsg)
+
+ " List with only one valid entry
+ let l = []
+ exe Xgetexpr . " ['Xtestfile3:3:1:Line3']"
+ exe XdoCmd
+ call assert_equal(['Xtestfile3 3L 1C'], l)
+
+ endfunction
+
+ " Tests for the :cfdo and :lfdo commands
+ function XfdoTests(cchar)
+ enew
+
+ " Shortcuts for calling the cfdo and lfdo commands
+ let Xfdo = a:cchar . 'fdo'
+ let Xgetexpr = a:cchar . 'getexpr'
+ let XfdoCmd = Xfdo . ' call add(l, GetRuler())'
+ let Xpfile = a:cchar. 'pfile'
+
+ " Clear the quickfix/location list
+ exe Xgetexpr . " []"
+
+ " Try with an empty list
+ let l = []
+ exe XfdoCmd
+ call assert_equal([], l)
+
+ " Populate the list and then try
+ exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', 'Xtestfile1:2:1:Line2', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:2:3:Line2', 'Xtestfile3:3:1:Line3']"
+
+ let l = []
+ exe XfdoCmd
+ call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l)
+
+ " Run command only on selected error lines
+ let l = []
+ exe "2,3" . XfdoCmd
+ call assert_equal(['Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l)
+
+ " Boundary condition tests
+ let l = []
+ exe "3" . XfdoCmd
+ call assert_equal(['Xtestfile3 2L 3C'], l)
+
+ " Range test commands
+ let l = []
+ exe "%" . XfdoCmd
+ call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l)
+
+ let l = []
+ exe "1,$" . XfdoCmd
+ call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l)
+
+ let l = []
+ exe Xpfile
+ exe "." . XfdoCmd
+ call assert_equal(['Xtestfile2 2L 2C'], l)
+
+ " List with only one valid entry
+ let l = []
+ exe Xgetexpr . " ['Xtestfile2:2:5:Line2']"
+ exe XfdoCmd
+ call assert_equal(['Xtestfile2 2L 5C'], l)
+
+ endfunction
+ ]=])
+ end)
+
+ after_each(function()
+ os.remove('Xtestfile1')
+ os.remove('Xtestfile2')
+ os.remove('Xtestfile3')
+ end)
+
+ it('works for :cdo', function()
+ -- call('XdoTests', 'c')
+ feed(":call XdoTests('c')<CR><C-l>")
+ expected_empty()
+ end)
+
+ it('works for :cfdo', function()
+ -- call('XfdoTests', 'c')
+ feed(":call XfdoTests('c')<CR><C-l>")
+ expected_empty()
+ end)
+
+ it('works for :ldo', function()
+ -- call('XdoTests', 'l')
+ feed(":call XdoTests('l')<CR><C-l>")
+ expected_empty()
+ end)
+
+ it('works for :lfdo', function()
+ -- call('XfdoTests', 'l')
+ feed(":call XfdoTests('l')<CR><C-l>")
+ expected_empty()
+ end)
+end)
diff --git a/test/functional/legacy/charsearch_spec.lua b/test/functional/legacy/charsearch_spec.lua
new file mode 100644
index 0000000000..4a83801cfc
--- /dev/null
+++ b/test/functional/legacy/charsearch_spec.lua
@@ -0,0 +1,42 @@
+-- Test for character searches
+
+local helpers = require('test.functional.helpers')
+local feed, insert = helpers.feed, helpers.insert
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('charsearch', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ Xabcdefghijkemnopqretuvwxyz
+ Yabcdefghijkemnopqretuvwxyz
+ Zabcdefghijkemnokqretkvwxyz]])
+
+ -- Check that "fe" and ";" work.
+ execute('/^X')
+ feed('ylfep;;p,,p')
+ -- Check that save/restore works.
+ execute('/^Y')
+ feed('ylfep')
+ execute('let csave = getcharsearch()')
+ feed('fip')
+ execute('call setcharsearch(csave)')
+ feed(';p;p')
+ -- Check that setcharsearch() changes the settings.
+ execute('/^Z')
+ feed('ylfep')
+ execute("call setcharsearch({'char': 'k'})")
+ feed(';p')
+ execute("call setcharsearch({'forward': 0})")
+ feed('$;p')
+ execute("call setcharsearch({'until': 1})")
+ feed(';;p')
+
+ -- Assert buffer contents.
+ expect([[
+ XabcdeXfghijkeXmnopqreXtuvwxyz
+ YabcdeYfghiYjkeYmnopqreYtuvwxyz
+ ZabcdeZfghijkZZemnokqretkZvwxyz]])
+ end)
+end)
diff --git a/test/functional/legacy/command_count_spec.lua b/test/functional/legacy/command_count_spec.lua
new file mode 100644
index 0000000000..d9b4f09263
--- /dev/null
+++ b/test/functional/legacy/command_count_spec.lua
@@ -0,0 +1,243 @@
+-- Test for user command counts
+
+local helpers = require('test.functional.helpers')
+local clear, source, expect = helpers.clear, helpers.source, helpers.expect
+local execute, spawn = helpers.execute, helpers.spawn
+local nvim_prog = helpers.nvim_prog
+
+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)
+
+ source([[
+ lang C
+ let g:lines = []
+ com -range=% RangeLines
+ \ :call add(g:lines, 'RangeLines '.<line1>.' '.<line2>)
+ com -range -addr=arguments RangeArguments
+ \ :call add(g:lines, 'RangeArguments '.<line1>.' '.<line2>)
+ com -range=% -addr=arguments RangeArgumentsAll
+ \ :call add(g:lines, 'RangeArgumentsAll '.<line1>.' '.<line2>)
+ com -range -addr=loaded_buffers RangeLoadedBuffers
+ \ :call add(g:lines, 'RangeLoadedBuffers '.<line1>.' '.<line2>)
+ com -range=% -addr=loaded_buffers RangeLoadedBuffersAll
+ \ :call add(g:lines, 'RangeLoadedBuffersAll '.<line1>.' '.<line2>)
+ com -range -addr=buffers RangeBuffers
+ \ :call add(g:lines, 'RangeBuffers '.<line1>.' '.<line2>)
+ com -range=% -addr=buffers RangeBuffersAll
+ \ :call add(g:lines, 'RangeBuffersAll '.<line1>.' '.<line2>)
+ com -range -addr=windows RangeWindows
+ \ :call add(g:lines, 'RangeWindows '.<line1>.' '.<line2>)
+ com -range=% -addr=windows RangeWindowsAll
+ \ :call add(g:lines, 'RangeWindowsAll '.<line1>.' '.<line2>)
+ com -range -addr=tabs RangeTabs
+ \ :call add(g:lines, 'RangeTabs '.<line1>.' '.<line2>)
+ com -range=% -addr=tabs RangeTabsAll
+ \ :call add(g:lines, 'RangeTabsAll '.<line1>.' '.<line2>)
+ set hidden
+ arga a b c d
+ argdo echo "loading buffers"
+ argu 3
+ .-,$-RangeArguments
+ %RangeArguments
+ RangeArgumentsAll
+ N
+ .RangeArguments
+ split
+ split
+ split
+ split
+ 3wincmd w
+ .,$RangeWindows
+ %RangeWindows
+ RangeWindowsAll
+ only
+ blast
+ bd
+ .,$RangeLoadedBuffers
+ %RangeLoadedBuffers
+ RangeLoadedBuffersAll
+ .,$RangeBuffers
+ %RangeBuffers
+ RangeBuffersAll
+ tabe
+ tabe
+ tabe
+ tabe
+ normal 2gt
+ .,$RangeTabs
+ %RangeTabs
+ RangeTabsAll
+ 1tabonly
+ s/\n/\r\r\r\r\r/
+ 2ma<
+ $-ma>
+ '<,'>RangeLines
+ com -range=% -buffer LocalRangeLines
+ \ :call add(g:lines, 'LocalRangeLines '.<line1>.' '.<line2>)
+ '<,'>LocalRangeLines
+ b1
+ call add(g:lines, '')
+ %argd
+ arga a b c d
+ ]])
+ -- This can not be in the source() call as it will produce errors.
+ execute([[let v:errmsg = '']])
+ execute('5argu')
+ execute([[call add(g:lines, '5argu ' . v:errmsg)]])
+ execute('$argu')
+ execute([[call add(g:lines, '4argu ' . expand('%:t'))]])
+ execute([[let v:errmsg = '']])
+ execute('1argu')
+ execute([[call add(g:lines, '1argu ' . expand('%:t'))]])
+ execute([[let v:errmsg = '']])
+ execute('100b')
+ execute([[call add(g:lines, '100b ' . v:errmsg)]])
+ execute('split')
+ execute('split')
+ execute('split')
+ execute('split')
+ execute([[let v:errmsg = '']])
+ execute('0close')
+ execute([[call add(g:lines, '0close ' . v:errmsg)]])
+ execute('$wincmd w')
+ execute('$close')
+ execute([[call add(g:lines, '$close ' . winnr())]])
+ execute([[let v:errmsg = '']])
+ execute('$+close')
+ execute([[call add(g:lines, '$+close ' . v:errmsg)]])
+ execute('$tabe')
+ execute([[call add(g:lines, '$tabe ' . tabpagenr())]])
+ execute([[let v:errmsg = '']])
+ execute('$+tabe')
+ execute([[call add(g:lines, '$+tabe ' . v:errmsg)]])
+ source([[
+ only!
+ e x
+ 0tabm
+ normal 1gt
+ call add(g:lines, '0tabm ' . expand('%:t'))
+ tabonly!
+ only!
+ e! test.out
+ call append(0, g:lines)
+ unlet g:lines
+ w
+ bd
+ b1
+ let g:lines = []
+ func BufStatus()
+ call add(g:lines,
+ \ 'aaa: ' . buflisted(g:buf_aaa) .
+ \ ' bbb: ' . buflisted(g:buf_bbb) .
+ \ ' ccc: ' . buflisted(g:buf_ccc))
+ endfunc
+ se nohidden
+ e aaa
+ let buf_aaa = bufnr('%')
+ e bbb
+ let buf_bbb = bufnr('%')
+ e ccc
+ let buf_ccc = bufnr('%')
+ b1
+ call BufStatus()
+ exe buf_bbb . "," . buf_ccc . "bdelete"
+ call BufStatus()
+ exe buf_aaa . "bdelete"
+ call BufStatus()
+ e! test.out
+ call append('$', g:lines)
+ unlet g:lines
+ delfunc BufStatus
+ w
+ bd
+ b1
+ se hidden
+ only!
+ let g:lines = []
+ %argd
+ arga a b c d e f
+ 3argu
+ let args = ''
+ .,$-argdo let args .= ' '.expand('%')
+ call add(g:lines, 'argdo:' . args)
+ split
+ split
+ split
+ split
+ 2wincmd w
+ let windows = ''
+ .,$-windo let windows .= ' '.winnr()
+ call add(g:lines, 'windo:'. windows)
+ b2
+ let buffers = ''
+ .,$-bufdo let buffers .= ' '.bufnr('%')
+ call add(g:lines, 'bufdo:' . buffers)
+ 3bd
+ let buffers = ''
+ 3,7bufdo let buffers .= ' '.bufnr('%')
+ call add(g:lines, 'bufdo:' . buffers)
+ tabe
+ tabe
+ tabe
+ tabe
+ normal! 2gt
+ let tabpages = ''
+ .,$-tabdo let tabpages .= ' '.tabpagenr()
+ call add(g:lines, 'tabdo:' . tabpages)
+ e! test.out
+ call append('$', g:lines)
+ ]])
+
+ -- Assert buffer contents.
+ expect([[
+ RangeArguments 2 4
+ RangeArguments 1 5
+ RangeArgumentsAll 1 5
+ RangeArguments 2 2
+ RangeWindows 3 5
+ RangeWindows 1 5
+ RangeWindowsAll 1 5
+ RangeLoadedBuffers 2 4
+ RangeLoadedBuffers 1 4
+ RangeLoadedBuffersAll 1 4
+ RangeBuffers 2 5
+ RangeBuffers 1 5
+ RangeBuffersAll 1 5
+ RangeTabs 2 5
+ RangeTabs 1 5
+ RangeTabsAll 1 5
+ RangeLines 2 5
+ LocalRangeLines 2 5
+
+ 5argu E16: Invalid range
+ 4argu d
+ 1argu a
+ 100b E16: Invalid range
+ 0close
+ $close 3
+ $+close E16: Invalid range
+ $tabe 2
+ $+tabe E16: Invalid range
+ 0tabm x
+
+ aaa: 1 bbb: 1 ccc: 1
+ aaa: 1 bbb: 0 ccc: 0
+ aaa: 0 bbb: 0 ccc: 0
+ argdo: c d e
+ windo: 2 3 4
+ bufdo: 2 3 4 5 6 7 8 9 10 15
+ bufdo: 4 5 6 7
+ tabdo: 2 3 4]])
+ end)
+end)
diff --git a/test/functional/legacy/comparators_spec.lua b/test/functional/legacy/comparators_spec.lua
new file mode 100644
index 0000000000..e3fa3eea23
--- /dev/null
+++ b/test/functional/legacy/comparators_spec.lua
@@ -0,0 +1,14 @@
+-- " Test for expression comparators.
+
+local helpers = require('test.functional.helpers')
+local clear, eq = helpers.clear, helpers.eq
+local eval, execute = helpers.eval, helpers.execute
+
+describe('comparators', function()
+ before_each(clear)
+
+ it('is working', function()
+ execute('set isident+=#')
+ eq(1, eval('1 is#1'))
+ end)
+end)
diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua
new file mode 100644
index 0000000000..cd18a8f750
--- /dev/null
+++ b/test/functional/legacy/delete_spec.lua
@@ -0,0 +1,99 @@
+local helpers = require('test.functional.helpers')
+local clear, source = helpers.clear, helpers.source
+local eq, eval, execute = helpers.eq, helpers.eval, helpers.execute
+
+describe('Test for delete()', function()
+ before_each(clear)
+
+ it('file delete', function()
+ execute('split Xfile')
+ execute("call setline(1, ['a', 'b'])")
+ execute('wq')
+ eq(eval("['a', 'b']"), eval("readfile('Xfile')"))
+ eq(0, eval("delete('Xfile')"))
+ eq(-1, eval("delete('Xfile')"))
+ end)
+
+ it('directory delete', function()
+ execute("call mkdir('Xdir1')")
+ eq(1, eval("isdirectory('Xdir1')"))
+ eq(0, eval("delete('Xdir1', 'd')"))
+ eq(0, eval("isdirectory('Xdir1')"))
+ eq(-1, eval("delete('Xdir1', 'd')"))
+ end)
+ it('recursive delete', function()
+ execute("call mkdir('Xdir1')")
+ execute("call mkdir('Xdir1/subdir')")
+ execute("call mkdir('Xdir1/empty')")
+ execute('split Xdir1/Xfile')
+ execute("call setline(1, ['a', 'b'])")
+ execute('w')
+ execute('w Xdir1/subdir/Xfile')
+ execute('close')
+
+ eq(1, eval("isdirectory('Xdir1')"))
+ eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')"))
+ eq(1, eval("isdirectory('Xdir1/subdir')"))
+ eq(eval("['a', 'b']"), eval("readfile('Xdir1/subdir/Xfile')"))
+ eq(1, eval("isdirectory('Xdir1/empty')"))
+ eq(0, eval("delete('Xdir1', 'rf')"))
+ eq(0, eval("isdirectory('Xdir1')"))
+ eq(-1, eval("delete('Xdir1', 'd')"))
+ end)
+
+ it('symlink delete', function()
+ source([[
+ split Xfile
+ call setline(1, ['a', 'b'])
+ wq
+ silent !ln -s Xfile Xlink
+ ]])
+ -- Delete the link, not the file
+ eq(0, eval("delete('Xlink')"))
+ eq(-1, eval("delete('Xlink')"))
+ eq(0, eval("delete('Xfile')"))
+ end)
+
+ it('symlink directory delete', function()
+ execute("call mkdir('Xdir1')")
+ execute("silent !ln -s Xdir1 Xlink")
+ eq(1, eval("isdirectory('Xdir1')"))
+ eq(1, eval("isdirectory('Xlink')"))
+ -- Delete the link, not the directory
+ eq(0, eval("delete('Xlink')"))
+ eq(-1, eval("delete('Xlink')"))
+ eq(0, eval("delete('Xdir1', 'd')"))
+ end)
+
+ it('symlink recursive delete', function()
+ source([[
+ call mkdir('Xdir3')
+ call mkdir('Xdir3/subdir')
+ call mkdir('Xdir4')
+ split Xdir3/Xfile
+ call setline(1, ['a', 'b'])
+ w
+ w Xdir3/subdir/Xfile
+ w Xdir4/Xfile
+ close
+ silent !ln -s ../Xdir4 Xdir3/Xlink
+ ]])
+
+ eq(1, eval("isdirectory('Xdir3')"))
+ eq(eval("['a', 'b']"), eval("readfile('Xdir3/Xfile')"))
+ eq(1, eval("isdirectory('Xdir3/subdir')"))
+ eq(eval("['a', 'b']"), eval("readfile('Xdir3/subdir/Xfile')"))
+ eq(1, eval("isdirectory('Xdir4')"))
+ eq(1, eval("isdirectory('Xdir3/Xlink')"))
+ eq(eval("['a', 'b']"), eval("readfile('Xdir4/Xfile')"))
+
+ eq(0, eval("delete('Xdir3', 'rf')"))
+ eq(0, eval("isdirectory('Xdir3')"))
+ eq(-1, eval("delete('Xdir3', 'd')"))
+ -- symlink is deleted, not the directory it points to
+ eq(1, eval("isdirectory('Xdir4')"))
+ eq(eval("['a', 'b']"), eval("readfile('Xdir4/Xfile')"))
+ eq(0, eval("delete('Xdir4/Xfile')"))
+ eq(0, eval("delete('Xdir4', 'd')"))
+ end)
+end)
diff --git a/test/functional/legacy/erasebackword_spec.lua b/test/functional/legacy/erasebackword_spec.lua
new file mode 100644
index 0000000000..cb3967b763
--- /dev/null
+++ b/test/functional/legacy/erasebackword_spec.lua
@@ -0,0 +1,24 @@
+-- Test for CTRL-W in Insert mode
+
+local helpers = require('test.functional.helpers')
+local clear, feed, expect = helpers.clear, helpers.feed, helpers.expect
+
+describe('CTRL-W in Insert mode', function()
+ setup(clear)
+
+ it('works for multi-byte characters', function()
+
+ for i = 1, 6 do
+ feed('o wwwこんにちわ世界ワールドvim ' .. string.rep('<C-w>', i) .. '<esc>')
+ end
+
+ expect([[
+
+ wwwこんにちわ世界ワールド
+ wwwこんにちわ世界
+ wwwこんにちわ
+ www
+
+ ]])
+ end)
+end)
diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua
new file mode 100644
index 0000000000..3ff1092a4b
--- /dev/null
+++ b/test/functional/legacy/eval_spec.lua
@@ -0,0 +1,736 @@
+-- Test for various eval features.
+
+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 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', [[
+ set noswapfile
+ lang C
+
+ fun AppendRegContents(reg)
+ call AppendRegParts(a:reg, getregtype(a:reg), getreg(a:reg), string(getreg(a:reg, 0, 1)), getreg(a:reg, 1), string(getreg(a:reg, 1, 1)))
+ endfun
+
+ fun AppendRegParts(reg, type, cont, strcont, cont1, strcont1)
+ call append('$', printf('%s: type %s; value: %s (%s), expr: %s (%s)', a:reg, a:type, a:cont, a:strcont, a:cont1, a:strcont1))
+ endfun
+
+ command -nargs=? AR :call AppendRegContents(<q-args>)
+
+ fun SetReg(...)
+ call call('setreg', a:000)
+ call append('$', printf('{{{2 setreg(%s)', string(a:000)[1:-2]))
+ call AppendRegContents(a:1)
+ if a:1 isnot# '='
+ execute "silent normal! Go==\n==\e\"".a:1."P"
+ endif
+ endfun
+ ]])
+ end)
+ before_each(clear)
+ teardown(function()
+ os.remove('test_eval_setup.vim')
+ end)
+
+ it(':let', function()
+ execute('so test_eval_setup.vim')
+ execute([[let @" = 'abc']])
+ execute('AR "')
+ execute([[let @" = "abc\n"]])
+ source('AR "')
+ execute([[let @" = "abc\<C-m>"]])
+ execute('AR "')
+ execute([[let @= = '"abc"']])
+ execute('AR =')
+ expect([[
+
+ ": type v; value: abc (['abc']), expr: abc (['abc'])
+ ": type V; value: abc]].."\000 (['abc']), expr: abc\000"..[[ (['abc'])
+ ": type V; value: abc]].."\r\000 (['abc\r']), expr: abc\r\000 (['abc\r"..[['])
+ =: type v; value: abc (['abc']), expr: "abc" (['"abc"'])]])
+ end)
+
+ it('basic setreg() tests', function()
+ execute('so test_eval_setup.vim')
+ insert('{{{1 Basic setreg tests')
+ execute([[call SetReg('a', 'abcA', 'c')]])
+ execute([[call SetReg('b', 'abcB', 'v')]])
+ execute([[call SetReg('c', 'abcC', 'l')]])
+ execute([[call SetReg('d', 'abcD', 'V')]])
+ execute([[call SetReg('e', 'abcE', 'b')]])
+ execute([[call SetReg('f', 'abcF', "\<C-v>")]])
+ execute([[call SetReg('g', 'abcG', 'b10')]])
+ execute([[call SetReg('h', 'abcH', "\<C-v>10")]])
+ execute([[call SetReg('I', 'abcI')]])
+
+ feed('Go{{{1 Appending single lines with setreg()<esc>')
+ execute([[call SetReg('A', 'abcAc', 'c')]])
+ execute([[call SetReg('A', 'abcAl', 'l')]])
+ execute([[call SetReg('A', 'abcAc2','c')]])
+ execute([[call SetReg('b', 'abcBc', 'ca')]])
+ execute([[call SetReg('b', 'abcBb', 'ba')]])
+ execute([[call SetReg('b', 'abcBc2','ca')]])
+ execute([[call SetReg('b', 'abcBb2','b50a')]])
+ execute([[call SetReg('C', 'abcCl', 'l')]])
+ execute([[call SetReg('C', 'abcCc', 'c')]])
+ execute([[call SetReg('D', 'abcDb', 'b')]])
+ execute([[call SetReg('E', 'abcEb', 'b')]])
+ execute([[call SetReg('E', 'abcEl', 'l')]])
+ execute([[call SetReg('F', 'abcFc', 'c')]])
+ expect([[
+ {{{1 Basic setreg tests
+ {{{2 setreg('a', 'abcA', 'c')
+ a: type v; value: abcA (['abcA']), expr: abcA (['abcA'])
+ ==
+ =abcA=
+ {{{2 setreg('b', 'abcB', 'v')
+ b: type v; value: abcB (['abcB']), expr: abcB (['abcB'])
+ ==
+ =abcB=
+ {{{2 setreg('c', 'abcC', 'l')
+ c: type V; value: abcC]].."\000 (['abcC']), expr: abcC\000"..[[ (['abcC'])
+ ==
+ abcC
+ ==
+ {{{2 setreg('d', 'abcD', 'V')
+ d: type V; value: abcD]].."\000 (['abcD']), expr: abcD\000"..[[ (['abcD'])
+ ==
+ abcD
+ ==
+ {{{2 setreg('e', 'abcE', 'b')
+ e: type ]]..'\022'..[[4; value: abcE (['abcE']), expr: abcE (['abcE'])
+ ==
+ =abcE=
+ {{{2 setreg('f', 'abcF', ']]..'\022'..[[')
+ f: type ]]..'\022'..[[4; value: abcF (['abcF']), expr: abcF (['abcF'])
+ ==
+ =abcF=
+ {{{2 setreg('g', 'abcG', 'b10')
+ g: type ]]..'\022'..[[10; value: abcG (['abcG']), expr: abcG (['abcG'])
+ ==
+ =abcG =
+ {{{2 setreg('h', 'abcH', ']]..'\022'..[[10')
+ h: type ]]..'\022'..[[10; value: abcH (['abcH']), expr: abcH (['abcH'])
+ ==
+ =abcH =
+ {{{2 setreg('I', 'abcI')
+ I: type v; value: abcI (['abcI']), expr: abcI (['abcI'])
+ ==
+ =abcI=
+ {{{1 Appending single lines with setreg()
+ {{{2 setreg('A', 'abcAc', 'c')
+ A: type v; value: abcAabcAc (['abcAabcAc']), expr: abcAabcAc (['abcAabcAc'])
+ ==
+ =abcAabcAc=
+ {{{2 setreg('A', 'abcAl', 'l')
+ A: type V; value: abcAabcAcabcAl]].."\000 (['abcAabcAcabcAl']), expr: abcAabcAcabcAl\000"..[[ (['abcAabcAcabcAl'])
+ ==
+ abcAabcAcabcAl
+ ==
+ {{{2 setreg('A', 'abcAc2', 'c')
+ A: type v; value: abcAabcAcabcAl]].."\000abcAc2 (['abcAabcAcabcAl', 'abcAc2']), expr: abcAabcAcabcAl\000"..[[abcAc2 (['abcAabcAcabcAl', 'abcAc2'])
+ ==
+ =abcAabcAcabcAl
+ abcAc2=
+ {{{2 setreg('b', 'abcBc', 'ca')
+ b: type v; value: abcBabcBc (['abcBabcBc']), expr: abcBabcBc (['abcBabcBc'])
+ ==
+ =abcBabcBc=
+ {{{2 setreg('b', 'abcBb', 'ba')
+ b: type ]]..'\022'..[[5; value: abcBabcBcabcBb (['abcBabcBcabcBb']), expr: abcBabcBcabcBb (['abcBabcBcabcBb'])
+ ==
+ =abcBabcBcabcBb=
+ {{{2 setreg('b', 'abcBc2', 'ca')
+ b: type v; value: abcBabcBcabcBb]].."\000abcBc2 (['abcBabcBcabcBb', 'abcBc2']), expr: abcBabcBcabcBb\000"..[[abcBc2 (['abcBabcBcabcBb', 'abcBc2'])
+ ==
+ =abcBabcBcabcBb
+ abcBc2=
+ {{{2 setreg('b', 'abcBb2', 'b50a')
+ b: type ]].."\02250; value: abcBabcBcabcBb\000abcBc2abcBb2 (['abcBabcBcabcBb', 'abcBc2abcBb2']), expr: abcBabcBcabcBb\000"..[[abcBc2abcBb2 (['abcBabcBcabcBb', 'abcBc2abcBb2'])
+ ==
+ =abcBabcBcabcBb =
+ abcBc2abcBb2
+ {{{2 setreg('C', 'abcCl', 'l')
+ C: type V; value: abcC]].."\000abcCl\000 (['abcC', 'abcCl']), expr: abcC\000abcCl\000"..[[ (['abcC', 'abcCl'])
+ ==
+ abcC
+ abcCl
+ ==
+ {{{2 setreg('C', 'abcCc', 'c')
+ C: type v; value: abcC]].."\000abcCl\000abcCc (['abcC', 'abcCl', 'abcCc']), expr: abcC\000abcCl\000"..[[abcCc (['abcC', 'abcCl', 'abcCc'])
+ ==
+ =abcC
+ abcCl
+ abcCc=
+ {{{2 setreg('D', 'abcDb', 'b')
+ D: type ]].."\0225; value: abcD\000abcDb (['abcD', 'abcDb']), expr: abcD\000"..[[abcDb (['abcD', 'abcDb'])
+ ==
+ =abcD =
+ abcDb
+ {{{2 setreg('E', 'abcEb', 'b')
+ E: type ]].."\0225; value: abcE\000abcEb (['abcE', 'abcEb']), expr: abcE\000"..[[abcEb (['abcE', 'abcEb'])
+ ==
+ =abcE =
+ abcEb
+ {{{2 setreg('E', 'abcEl', 'l')
+ E: type V; value: abcE]].."\000abcEb\000abcEl\000 (['abcE', 'abcEb', 'abcEl']), expr: abcE\000abcEb\000abcEl\000"..[[ (['abcE', 'abcEb', 'abcEl'])
+ ==
+ abcE
+ abcEb
+ abcEl
+ ==
+ {{{2 setreg('F', 'abcFc', 'c')
+ F: type v; value: abcF]].."\000abcFc (['abcF', 'abcFc']), expr: abcF\000"..[[abcFc (['abcF', 'abcFc'])
+ ==
+ =abcF
+ abcFc=]])
+ end)
+
+ it('appending NL with setreg()', function()
+ execute('so test_eval_setup.vim')
+
+ execute([[call setreg('a', 'abcA2', 'c')]])
+ execute([[call setreg('b', 'abcB2', 'v')]])
+ execute([[call setreg('c', 'abcC2', 'l')]])
+ execute([[call setreg('d', 'abcD2', 'V')]])
+ execute([[call setreg('e', 'abcE2', 'b')]])
+ execute([[call setreg('f', 'abcF2', "\<C-v>")]])
+ -- These registers where set like this in the old test_eval.in but never
+ -- copied to the output buffer with SetReg(). They do not appear in
+ -- test_eval.ok. Therefore they are commented out.
+ --execute([[call setreg('g', 'abcG2', 'b10')]])
+ --execute([[call setreg('h', 'abcH2', "\<C-v>10")]])
+ --execute([[call setreg('I', 'abcI2')]])
+
+ execute([[call SetReg('A', "\n")]])
+ execute([[call SetReg('B', "\n", 'c')]])
+ execute([[call SetReg('C', "\n")]])
+ execute([[call SetReg('D', "\n", 'l')]])
+ execute([[call SetReg('E', "\n")]])
+ execute([[call SetReg('F', "\n", 'b')]])
+ expect([[
+
+ {{{2 setreg('A', ']]..'\000'..[[')
+ A: type V; value: abcA2]].."\000 (['abcA2']), expr: abcA2\000"..[[ (['abcA2'])
+ ==
+ abcA2
+ ==
+ {{{2 setreg('B', ']]..'\000'..[[', 'c')
+ B: type v; value: abcB2]].."\000 (['abcB2', '']), expr: abcB2\000"..[[ (['abcB2', ''])
+ ==
+ =abcB2
+ =
+ {{{2 setreg('C', ']]..'\000'..[[')
+ C: type V; value: abcC2]].."\000\000 (['abcC2', '']), expr: abcC2\000\000"..[[ (['abcC2', ''])
+ ==
+ abcC2
+
+ ==
+ {{{2 setreg('D', ']]..'\000'..[[', 'l')
+ D: type V; value: abcD2]].."\000\000 (['abcD2', '']), expr: abcD2\000\000"..[[ (['abcD2', ''])
+ ==
+ abcD2
+
+ ==
+ {{{2 setreg('E', ']]..'\000'..[[')
+ E: type V; value: abcE2]].."\000\000 (['abcE2', '']), expr: abcE2\000\000"..[[ (['abcE2', ''])
+ ==
+ abcE2
+
+ ==
+ {{{2 setreg('F', ']]..'\000'..[[', 'b')
+ F: type ]].."\0220; value: abcF2\000 (['abcF2', '']), expr: abcF2\000"..[[ (['abcF2', ''])
+ ==
+ =abcF2=
+ ]])
+ end)
+
+ it('setting and appending list with setreg()', function()
+ execute('so test_eval_setup.vim')
+
+ execute([[$put ='{{{1 Setting lists with setreg()']])
+ execute([=[call SetReg('a', ['abcA3'], 'c')]=])
+ execute([=[call SetReg('b', ['abcB3'], 'l')]=])
+ execute([=[call SetReg('c', ['abcC3'], 'b')]=])
+ execute([=[call SetReg('d', ['abcD3'])]=])
+ execute([=[call SetReg('e', [1, 2, 'abc', 3])]=])
+ execute([=[call SetReg('f', [1, 2, 3])]=])
+
+ execute([[$put ='{{{1 Appending lists with setreg()']])
+ execute([=[call SetReg('A', ['abcA3c'], 'c')]=])
+ execute([=[call SetReg('b', ['abcB3l'], 'la')]=])
+ execute([=[call SetReg('C', ['abcC3b'], 'lb')]=])
+ execute([=[call SetReg('D', ['abcD32'])]=])
+ execute([=[call SetReg('A', ['abcA32'])]=])
+ execute([=[call SetReg('B', ['abcB3c'], 'c')]=])
+ execute([=[call SetReg('C', ['abcC3l'], 'l')]=])
+ execute([=[call SetReg('D', ['abcD3b'], 'b')]=])
+ expect([[
+
+ {{{1 Setting lists with setreg()
+ {{{2 setreg('a', ['abcA3'], 'c')
+ a: type v; value: abcA3 (['abcA3']), expr: abcA3 (['abcA3'])
+ ==
+ =abcA3=
+ {{{2 setreg('b', ['abcB3'], 'l')
+ b: type V; value: abcB3]].."\000 (['abcB3']), expr: abcB3\000"..[[ (['abcB3'])
+ ==
+ abcB3
+ ==
+ {{{2 setreg('c', ['abcC3'], 'b')
+ c: type ]]..'\022'..[[5; value: abcC3 (['abcC3']), expr: abcC3 (['abcC3'])
+ ==
+ =abcC3=
+ {{{2 setreg('d', ['abcD3'])
+ d: type V; value: abcD3]].."\000 (['abcD3']), expr: abcD3\000"..[[ (['abcD3'])
+ ==
+ abcD3
+ ==
+ {{{2 setreg('e', [1, 2, 'abc', 3])
+ e: type V; value: 1]].."\0002\000abc\0003\000 (['1', '2', 'abc', '3']), expr: 1\0002\000abc\0003\000"..[[ (['1', '2', 'abc', '3'])
+ ==
+ 1
+ 2
+ abc
+ 3
+ ==
+ {{{2 setreg('f', [1, 2, 3])
+ f: type V; value: 1]].."\0002\0003\000 (['1', '2', '3']), expr: 1\0002\0003\000"..[[ (['1', '2', '3'])
+ ==
+ 1
+ 2
+ 3
+ ==
+ {{{1 Appending lists with setreg()
+ {{{2 setreg('A', ['abcA3c'], 'c')
+ A: type v; value: abcA3]].."\000abcA3c (['abcA3', 'abcA3c']), expr: abcA3\000"..[[abcA3c (['abcA3', 'abcA3c'])
+ ==
+ =abcA3
+ abcA3c=
+ {{{2 setreg('b', ['abcB3l'], 'la')
+ b: type V; value: abcB3]].."\000abcB3l\000 (['abcB3', 'abcB3l']), expr: abcB3\000abcB3l\000"..[[ (['abcB3', 'abcB3l'])
+ ==
+ abcB3
+ abcB3l
+ ==
+ {{{2 setreg('C', ['abcC3b'], 'lb')
+ C: type ]].."\0226; value: abcC3\000abcC3b (['abcC3', 'abcC3b']), expr: abcC3\000"..[[abcC3b (['abcC3', 'abcC3b'])
+ ==
+ =abcC3 =
+ abcC3b
+ {{{2 setreg('D', ['abcD32'])
+ D: type V; value: abcD3]].."\000abcD32\000 (['abcD3', 'abcD32']), expr: abcD3\000abcD32\000"..[[ (['abcD3', 'abcD32'])
+ ==
+ abcD3
+ abcD32
+ ==
+ {{{2 setreg('A', ['abcA32'])
+ A: type V; value: abcA3]].."\000abcA3c\000abcA32\000 (['abcA3', 'abcA3c', 'abcA32']), expr: abcA3\000abcA3c\000abcA32\000"..[[ (['abcA3', 'abcA3c', 'abcA32'])
+ ==
+ abcA3
+ abcA3c
+ abcA32
+ ==
+ {{{2 setreg('B', ['abcB3c'], 'c')
+ B: type v; value: abcB3]].."\000abcB3l\000abcB3c (['abcB3', 'abcB3l', 'abcB3c']), expr: abcB3\000abcB3l\000"..[[abcB3c (['abcB3', 'abcB3l', 'abcB3c'])
+ ==
+ =abcB3
+ abcB3l
+ abcB3c=
+ {{{2 setreg('C', ['abcC3l'], 'l')
+ C: type V; value: abcC3]].."\000abcC3b\000abcC3l\000 (['abcC3', 'abcC3b', 'abcC3l']), expr: abcC3\000abcC3b\000abcC3l\000"..[[ (['abcC3', 'abcC3b', 'abcC3l'])
+ ==
+ abcC3
+ abcC3b
+ abcC3l
+ ==
+ {{{2 setreg('D', ['abcD3b'], 'b')
+ D: type ]].."\0226; value: abcD3\000abcD32\000abcD3b (['abcD3', 'abcD32', 'abcD3b']), expr: abcD3\000abcD32\000"..[[abcD3b (['abcD3', 'abcD32', 'abcD3b'])
+ ==
+ =abcD3 =
+ abcD32
+ abcD3b]])
+
+ -- From now on we delete the buffer contents after each expect() to make
+ -- the next expect() easier to write. This is neccessary because null
+ -- bytes on a line by itself don't play well together with the dedent
+ -- function used in expect().
+ execute('%delete')
+ execute([[$put ='{{{1 Appending lists with NL with setreg()']])
+ execute([=[call SetReg('A', ["\n", 'abcA3l2'], 'l')]=])
+ expect(
+ '\n'..
+ '{{{1 Appending lists with NL with setreg()\n'..
+ "{{{2 setreg('A', ['\000', 'abcA3l2'], 'l')\n"..
+ "A: type V; value: abcA3\000abcA3c\000abcA32\000\000\000abcA3l2\000 (['abcA3', 'abcA3c', 'abcA32', '\000', 'abcA3l2']), expr: abcA3\000abcA3c\000abcA32\000\000\000abcA3l2\000 (['abcA3', 'abcA3c', 'abcA32', '\000', 'abcA3l2'])\n"..
+ '==\n'..
+ 'abcA3\n'..
+ 'abcA3c\n'..
+ 'abcA32\n'..
+ '\000\n'..
+ 'abcA3l2\n'..
+ '==')
+ execute('%delete')
+ execute([=[call SetReg('B', ["\n", 'abcB3c2'], 'c')]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('B', ['\000', 'abcB3c2'], 'c')\n"..
+ "B: type v; value: abcB3\000abcB3l\000abcB3c\000\000\000abcB3c2 (['abcB3', 'abcB3l', 'abcB3c', '\000', 'abcB3c2']), expr: abcB3\000abcB3l\000abcB3c\000\000\000abcB3c2 (['abcB3', 'abcB3l', 'abcB3c', '\000', 'abcB3c2'])\n"..
+ '==\n'..
+ '=abcB3\n'..
+ 'abcB3l\n'..
+ 'abcB3c\n'..
+ '\000\n'..
+ 'abcB3c2=')
+ execute('%delete')
+ execute([=[call SetReg('C', ["\n", 'abcC3b2'], 'b')]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('C', ['\000', 'abcC3b2'], 'b')\n"..
+ "C: type \0227; value: abcC3\000abcC3b\000abcC3l\000\000\000abcC3b2 (['abcC3', 'abcC3b', 'abcC3l', '\000', 'abcC3b2']), expr: abcC3\000abcC3b\000abcC3l\000\000\000abcC3b2 (['abcC3', 'abcC3b', 'abcC3l', '\000', 'abcC3b2'])\n"..
+ '==\n'..
+ '=abcC3 =\n'..
+ ' abcC3b\n'..
+ ' abcC3l\n'..
+ ' \000\n'..
+ ' abcC3b2')
+ execute('%delete')
+ execute([=[call SetReg('D', ["\n", 'abcD3b50'],'b50')]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('D', ['\000', 'abcD3b50'], 'b50')\n"..
+ "D: type \02250; value: abcD3\000abcD32\000abcD3b\000\000\000abcD3b50 (['abcD3', 'abcD32', 'abcD3b', '\000', 'abcD3b50']), expr: abcD3\000abcD32\000abcD3b\000\000\000abcD3b50 (['abcD3', 'abcD32', 'abcD3b', '\000', 'abcD3b50'])\n"..
+ '==\n'..
+ '=abcD3 =\n'..
+ ' abcD32\n'..
+ ' abcD3b\n'..
+ ' \000\n'..
+ ' abcD3b50')
+ end)
+
+ -- The tests for setting lists with NLs are split into seperate it() blocks
+ -- to make the expect() calls easier to write. Otherwise the null byte can
+ -- make trouble on a line on its own.
+ it('setting lists with NLs with setreg(), part 1', function()
+ execute('so test_eval_setup.vim')
+ execute([=[call SetReg('a', ['abcA4-0', "\n", "abcA4-2\n", "\nabcA4-3", "abcA4-4\nabcA4-4-2"])]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('a', ['abcA4-0', '\000', 'abcA4-2\000', '\000abcA4-3', 'abcA4-4\000abcA4-4-2'])\n"..
+ "a: type V; value: abcA4-0\000\000\000abcA4-2\000\000\000abcA4-3\000abcA4-4\000abcA4-4-2\000 (['abcA4-0', '\000', 'abcA4-2\000', '\000abcA4-3', 'abcA4-4\000abcA4-4-2']), expr: abcA4-0\000\000\000abcA4-2\000\000\000abcA4-3\000abcA4-4\000abcA4-4-2\000 (['abcA4-0', '\000', 'abcA4-2\000', '\000abcA4-3', 'abcA4-4\000abcA4-4-2'])\n"..
+ '==\n'..
+ 'abcA4-0\n'..
+ '\000\n'..
+ 'abcA4-2\000\n'..
+ '\000abcA4-3\n'..
+ 'abcA4-4\000abcA4-4-2\n'..
+ '==')
+ end)
+
+ it('setting lists with NLs with setreg(), part 2', function()
+ execute('so test_eval_setup.vim')
+ execute([=[call SetReg('b', ['abcB4c-0', "\n", "abcB4c-2\n", "\nabcB4c-3", "abcB4c-4\nabcB4c-4-2"], 'c')]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('b', ['abcB4c-0', '\000', 'abcB4c-2\000', '\000abcB4c-3', 'abcB4c-4\000abcB4c-4-2'], 'c')\n"..
+ "b: type v; value: abcB4c-0\000\000\000abcB4c-2\000\000\000abcB4c-3\000abcB4c-4\000abcB4c-4-2 (['abcB4c-0', '\000', 'abcB4c-2\000', '\000abcB4c-3', 'abcB4c-4\000abcB4c-4-2']), expr: abcB4c-0\000\000\000abcB4c-2\000\000\000abcB4c-3\000abcB4c-4\000abcB4c-4-2 (['abcB4c-0', '\000', 'abcB4c-2\000', '\000abcB4c-3', 'abcB4c-4\000abcB4c-4-2'])\n"..
+ '==\n'..
+ '=abcB4c-0\n'..
+ '\000\n'..
+ 'abcB4c-2\000\n'..
+ '\000abcB4c-3\n'..
+ 'abcB4c-4\000abcB4c-4-2=')
+ end)
+
+ it('setting lists with NLs with setreg(), part 3', function()
+ execute('so test_eval_setup.vim')
+ execute([=[call SetReg('c', ['abcC4l-0', "\n", "abcC4l-2\n", "\nabcC4l-3", "abcC4l-4\nabcC4l-4-2"], 'l')]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('c', ['abcC4l-0', '\000', 'abcC4l-2\000', '\000abcC4l-3', 'abcC4l-4\000abcC4l-4-2'], 'l')\n"..
+ "c: type V; value: abcC4l-0\000\000\000abcC4l-2\000\000\000abcC4l-3\000abcC4l-4\000abcC4l-4-2\000 (['abcC4l-0', '\000', 'abcC4l-2\000', '\000abcC4l-3', 'abcC4l-4\000abcC4l-4-2']), expr: abcC4l-0\000\000\000abcC4l-2\000\000\000abcC4l-3\000abcC4l-4\000abcC4l-4-2\000 (['abcC4l-0', '\000', 'abcC4l-2\000', '\000abcC4l-3', 'abcC4l-4\000abcC4l-4-2'])\n"..
+ '==\n'..
+ 'abcC4l-0\n'..
+ '\000\n'..
+ 'abcC4l-2\000\n'..
+ '\000abcC4l-3\n'..
+ 'abcC4l-4\000abcC4l-4-2\n'..
+ '==')
+ end)
+ it('setting lists with NLs with setreg(), part 4', function()
+ execute('so test_eval_setup.vim')
+ execute([=[call SetReg('d', ['abcD4b-0', "\n", "abcD4b-2\n", "\nabcD4b-3", "abcD4b-4\nabcD4b-4-2"], 'b')]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('d', ['abcD4b-0', '\000', 'abcD4b-2\000', '\000abcD4b-3', 'abcD4b-4\000abcD4b-4-2'], 'b')\n"..
+ "d: type \02219; value: abcD4b-0\000\000\000abcD4b-2\000\000\000abcD4b-3\000abcD4b-4\000abcD4b-4-2 (['abcD4b-0', '\000', 'abcD4b-2\000', '\000abcD4b-3', 'abcD4b-4\000abcD4b-4-2']), expr: abcD4b-0\000\000\000abcD4b-2\000\000\000abcD4b-3\000abcD4b-4\000abcD4b-4-2 (['abcD4b-0', '\000', 'abcD4b-2\000', '\000abcD4b-3', 'abcD4b-4\000abcD4b-4-2'])\n"..
+ '==\n'..
+ '=abcD4b-0 =\n'..
+ ' \000\n'..
+ ' abcD4b-2\000\n'..
+ ' \000abcD4b-3\n'..
+ ' abcD4b-4\000abcD4b-4-2')
+ end)
+ it('setting lists with NLs with setreg(), part 5', function()
+ execute('so test_eval_setup.vim')
+ execute([=[call SetReg('e', ['abcE4b10-0', "\n", "abcE4b10-2\n", "\nabcE4b10-3", "abcE4b10-4\nabcE4b10-4-2"], 'b10')]=])
+ expect(
+ '\n'..
+ "{{{2 setreg('e', ['abcE4b10-0', '\000', 'abcE4b10-2\000', '\000abcE4b10-3', 'abcE4b10-4\000abcE4b10-4-2'], 'b10')\n"..
+ "e: type \02210; value: abcE4b10-0\000\000\000abcE4b10-2\000\000\000abcE4b10-3\000abcE4b10-4\000abcE4b10-4-2 (['abcE4b10-0', '\000', 'abcE4b10-2\000', '\000abcE4b10-3', 'abcE4b10-4\000abcE4b10-4-2']), expr: abcE4b10-0\000\000\000abcE4b10-2\000\000\000abcE4b10-3\000abcE4b10-4\000abcE4b10-4-2 (['abcE4b10-0', '\000', 'abcE4b10-2\000', '\000abcE4b10-3', 'abcE4b10-4\000abcE4b10-4-2'])\n"..
+ '==\n'..
+ '=abcE4b10-0=\n'..
+ ' \000\n'..
+ ' abcE4b10-2\000\n'..
+ ' \000abcE4b10-3\n'..
+ ' abcE4b10-4\000abcE4b10-4-2')
+ end)
+
+ it('getreg("a",1,1) returns a valid list when "a is unset', function()
+ -- Precondition: "a is actually unset and "0 is nonempty
+ eq('', eval("getregtype('a')"))
+ eq('', eval("getreg('a')"))
+ execute("call setreg('0','text')")
+
+ -- This used to return a NULL list
+ -- which setreg didn't handle
+ execute("let x = getreg('a',1,1)")
+ execute("call setreg('0',x)")
+
+ -- nvim didn't crash and "0 was emptied
+ eq(2, eval("1+1"))
+ eq({}, eval("getreg('0',1,1)"))
+
+ -- x is a mutable list
+ execute("let y = x")
+ eq({}, eval("y"))
+ execute("call add(x, 'item')")
+ eq({'item'}, eval("y"))
+ end)
+
+ it('search and expressions', function()
+ execute('so test_eval_setup.vim')
+ execute([=[call SetReg('/', ['abc/'])]=])
+ execute([=[call SetReg('/', ["abc/\n"])]=])
+ execute([=[call SetReg('=', ['"abc/"'])]=])
+ execute([=[call SetReg('=', ["\"abc/\n\""])]=])
+ expect([[
+
+ {{{2 setreg('/', ['abc/'])
+ /: type v; value: abc/ (['abc/']), expr: abc/ (['abc/'])
+ ==
+ =abc/=
+ {{{2 setreg('/', ['abc/]]..'\000'..[['])
+ /: type v; value: abc/]].."\000 (['abc/\000']), expr: abc/\000 (['abc/\000"..[['])
+ ==
+ =abc/]]..'\000'..[[=
+ {{{2 setreg('=', ['"abc/"'])
+ =: type v; value: abc/ (['abc/']), expr: "abc/" (['"abc/"'])
+ {{{2 setreg('=', ['"abc/]]..'\000'..[["'])
+ =: type v; value: abc/]].."\000 (['abc/\000"..[[']), expr: "abc/]]..'\000'..[[" (['"abc/]]..'\000'..[["'])]])
+ end)
+
+ if has_clipboard() then
+ it('system clipboard', function()
+ insert([[
+ Some first line (this text was at the top of the old test_eval.in).
+
+ Note: system clipboard is saved, changed and restored.
+
+ clipboard contents
+ something else]])
+ execute('so test_eval_setup.vim')
+ -- Save and restore system clipboard.
+ execute("let _clipreg = ['*', getreg('*'), getregtype('*')]")
+ execute('let _clipopt = &cb')
+ execute("let &cb='unnamed'")
+ execute('5y')
+ execute('AR *')
+ execute('tabdo :windo :echo "hi"')
+ execute('6y')
+ execute('AR *')
+ execute('let &cb=_clipopt')
+ execute("call call('setreg', _clipreg)")
+ expect([[
+ Some first line (this text was at the top of the old test_eval.in).
+
+ Note: system clipboard is saved, changed and restored.
+
+ clipboard contents
+ something else
+ *: 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
+
+ it('errors', function()
+ source([[
+ fun ErrExe(str)
+ call append('$', 'Executing '.a:str)
+ try
+ execute a:str
+ catch
+ $put =v:exception
+ endtry
+ endfun]])
+ execute([[call ErrExe('call setreg()')]])
+ execute([[call ErrExe('call setreg(1)')]])
+ execute([[call ErrExe('call setreg(1, 2, 3, 4)')]])
+ execute([=[call ErrExe('call setreg([], 2)')]=])
+ execute([[call ErrExe('call setreg(1, {})')]])
+ execute([=[call ErrExe('call setreg(1, 2, [])')]=])
+ execute([=[call ErrExe('call setreg("/", ["1", "2"])')]=])
+ execute([=[call ErrExe('call setreg("=", ["1", "2"])')]=])
+ execute([=[call ErrExe('call setreg(1, ["", "", [], ""])')]=])
+ expect([[
+
+ Executing call setreg()
+ Vim(call):E119: Not enough arguments for function: setreg
+ Executing call setreg(1)
+ Vim(call):E119: Not enough arguments for function: setreg
+ Executing call setreg(1, 2, 3, 4)
+ Vim(call):E118: Too many arguments for function: setreg
+ Executing call setreg([], 2)
+ Vim(call):E730: using List as a String
+ Executing call setreg(1, {})
+ Vim(call):E731: using Dictionary as a String
+ Executing call setreg(1, 2, [])
+ Vim(call):E730: using List as a String
+ Executing call setreg("/", ["1", "2"])
+ Vim(call):E883: search pattern and expression register may not contain two or more lines
+ Executing call setreg("=", ["1", "2"])
+ Vim(call):E883: search pattern and expression register may not contain two or more lines
+ Executing call setreg(1, ["", "", [], ""])
+ Vim(call):E730: using List as a String]])
+ end)
+
+ it('function name not starting with a capital', function()
+ execute('try')
+ execute(' func! g:test()')
+ execute(' echo "test"')
+ execute(' endfunc')
+ execute('catch')
+ execute(' let tmp = v:exception')
+ execute('endtry')
+ eq('Vim(function):E128: Function name must start with a capital or "s:": g:test()', eval('tmp'))
+ end)
+
+ it('Function name followed by #', function()
+ execute('try')
+ execute(' func! test2() "#')
+ execute(' echo "test2"')
+ execute(' endfunc')
+ execute('catch')
+ execute(' let tmp = v:exception')
+ execute('endtry')
+ eq('Vim(function):E128: Function name must start with a capital or "s:": test2() "#', eval('tmp'))
+ end)
+
+ it('function name includes a colon', function()
+ execute('try')
+ execute(' func! b:test()')
+ execute(' echo "test"')
+ execute(' endfunc')
+ execute('catch')
+ execute(' let tmp = v:exception')
+ execute('endtry')
+ eq('Vim(function):E128: Function name must start with a capital or "s:": b:test()', eval('tmp'))
+ end)
+
+ it('function name starting with/without "g:", buffer-local funcref', function()
+ execute('function! g:Foo(n)')
+ execute(" $put ='called Foo(' . a:n . ')'")
+ execute('endfunction')
+ execute("let b:my_func = function('Foo')")
+ execute('call b:my_func(1)')
+ execute('echo g:Foo(2)')
+ execute('echo Foo(3)')
+ expect([[
+
+ called Foo(1)
+ called Foo(2)
+ called Foo(3)]])
+ end)
+
+ it('script-local function used in Funcref must exist', function()
+ source([[
+ " Vim script used in test_eval.in. Needed for script-local function.
+
+ func! s:Testje()
+ return "foo"
+ endfunc
+
+ let Bar = function('s:Testje')
+
+ $put ='s:Testje exists: ' . exists('s:Testje')
+ $put ='func s:Testje exists: ' . exists('*s:Testje')
+ $put ='Bar exists: ' . exists('Bar')
+ $put ='func Bar exists: ' . exists('*Bar')
+ ]])
+ expect([[
+
+ s:Testje exists: 0
+ func s:Testje exists: 1
+ Bar exists: 1
+ func Bar exists: 1]])
+ end)
+
+ it("using $ instead of '$' must give an error", function()
+ execute('try')
+ execute(" call append($, 'foobar')")
+ execute('catch')
+ execute(' let tmp = v:exception')
+ execute('endtry')
+ eq('Vim(call):E116: Invalid arguments for function append', eval('tmp'))
+ end)
+
+ it('getcurpos/setpos', function()
+ insert([[
+ 012345678
+ 012345678
+
+ start:]])
+ execute('/^012345678')
+ feed('6l')
+ execute('let sp = getcurpos()')
+ feed('0')
+ execute("call setpos('.', sp)")
+ feed('jyl')
+ execute('$put')
+ expect([[
+ 012345678
+ 012345678
+
+ start:
+ 6]])
+ end)
+
+ it('substring and variable name', function()
+ execute("let str = 'abcdef'")
+ execute('let n = 3')
+ eq('def', eval('str[n:]'))
+ eq('abcd', eval('str[:n]'))
+ eq('d', eval('str[n:n]'))
+ execute('unlet n')
+ execute('let nn = 3')
+ eq('def', eval('str[nn:]'))
+ eq('abcd', eval('str[:nn]'))
+ eq('d', eval('str[nn:nn]'))
+ execute('unlet nn')
+ execute('let b:nn = 4')
+ eq('ef', eval('str[b:nn:]'))
+ eq('abcde', eval('str[:b:nn]'))
+ eq('e', eval('str[b:nn:b:nn]'))
+ end)
+end)
diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua
new file mode 100644
index 0000000000..2d1824c8cd
--- /dev/null
+++ b/test/functional/legacy/fixeol_spec.lua
@@ -0,0 +1,72 @@
+-- Tests for 'fixeol'
+
+local helpers = require('test.functional.helpers')
+local feed = helpers.feed
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('fixeol', function()
+ local function rmtestfiles()
+ os.remove('test.out')
+ os.remove('XXEol')
+ os.remove('XXNoEol')
+ os.remove('XXTestEol')
+ os.remove('XXTestNoEol')
+ end
+ setup(function()
+ clear()
+ rmtestfiles()
+ end)
+ teardown(function()
+ rmtestfiles()
+ end)
+
+ it('is working', function()
+ -- First write two test files – with and without trailing EOL.
+ -- Use Unix fileformat for consistency.
+ execute('set ff=unix')
+ execute('enew!')
+ feed('awith eol<esc>:w! XXEol<cr>')
+ execute('enew!')
+ execute('set noeol nofixeol')
+ feed('awithout eol<esc>:w! XXNoEol<cr>')
+ execute('set eol fixeol')
+ execute('bwipe XXEol XXNoEol')
+
+ -- Try editing files with 'fixeol' disabled.
+ execute('e! XXEol')
+ feed('ostays eol<esc>:set nofixeol<cr>')
+ execute('w! XXTestEol')
+ execute('e! XXNoEol')
+ feed('ostays without<esc>:set nofixeol<cr>')
+ execute('w! XXTestNoEol')
+ execute('bwipe XXEol XXNoEol XXTestEol XXTestNoEol')
+ execute('set fixeol')
+
+ -- Append "END" to each file so that we can see what the last written char was.
+ feed('ggdGaEND<esc>:w >>XXEol<cr>')
+ execute('w >>XXNoEol')
+ execute('w >>XXTestEol')
+ execute('w >>XXTestNoEol')
+
+ -- Concatenate the results.
+ execute('e! test.out')
+ feed('a0<esc>:$r XXEol<cr>')
+ execute('$r XXNoEol')
+ feed('Go1<esc>:$r XXTestEol<cr>')
+ execute('$r XXTestNoEol')
+ execute('w')
+
+ -- Assert buffer contents.
+ expect([=[
+ 0
+ with eol
+ END
+ without eolEND
+ 1
+ with eol
+ stays eol
+ END
+ without eol
+ stays withoutEND]=])
+ end)
+end)
diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua
new file mode 100644
index 0000000000..2a32aea127
--- /dev/null
+++ b/test/functional/legacy/fnamemodify_spec.lua
@@ -0,0 +1,75 @@
+-- Test filename modifiers.
+
+local helpers = require('test.functional.helpers')
+local clear, source = helpers.clear, helpers.source
+local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
+
+local function expected_empty()
+ eq({}, nvim.get_vvar('errors'))
+end
+
+describe('filename modifiers', function()
+ before_each(function()
+ clear()
+
+ source([=[
+ func Test_fnamemodify()
+ let tmpdir = resolve('/tmp')
+ execute 'cd '. tmpdir
+ set shell=sh
+ set shellslash
+ let $HOME=fnamemodify('.', ':p:h:h:h')
+ call assert_equal('/', fnamemodify('.', ':p')[-1:])
+ call assert_equal('p', fnamemodify('.', ':p:h')[-1:])
+ call assert_equal('t', fnamemodify('test.out', ':p')[-1:])
+ call assert_equal('test.out', fnamemodify('test.out', ':.'))
+ call assert_equal('../testdir/a', fnamemodify('../testdir/a', ':.'))
+ call assert_equal('test.out', fnamemodify('test.out', ':~'))
+ call assert_equal('../testdir/a', fnamemodify('../testdir/a', ':~'))
+ call assert_equal('a', fnamemodify('../testdir/a', ':t'))
+ call assert_equal('', fnamemodify('.', ':p:t'))
+ call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
+ call assert_equal('out', fnamemodify('test.out', ':p:e'))
+ call assert_equal('out', fnamemodify('test.out', ':p:t:e'))
+ call assert_equal('abc.fb2.tar', fnamemodify('abc.fb2.tar.gz', ':r'))
+ call assert_equal('abc.fb2', fnamemodify('abc.fb2.tar.gz', ':r:r'))
+ call assert_equal('abc', fnamemodify('abc.fb2.tar.gz', ':r:r:r'))
+ call assert_equal(tmpdir .'/abc.fb2', substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(nvim/testdir/.*\)', '\1', ''))
+ call assert_equal('gz', fnamemodify('abc.fb2.tar.gz', ':e'))
+ call assert_equal('tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e'))
+ call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e'))
+ call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e:e'))
+ call assert_equal('tar', fnamemodify('abc.fb2.tar.gz', ':e:e:r'))
+ call assert_equal('''abc def''', fnamemodify('abc def', ':S'))
+ call assert_equal('''abc" "def''', fnamemodify('abc" "def', ':S'))
+ call assert_equal('''abc"%"def''', fnamemodify('abc"%"def', ':S'))
+ call assert_equal('''abc''\'''' ''\''''def''', fnamemodify('abc'' ''def', ':S'))
+ call assert_equal('''abc''\''''%''\''''def''', fnamemodify('abc''%''def', ':S'))
+ new foo.txt
+ call assert_equal(expand('%:r:S'), shellescape(expand('%:r')))
+ call assert_equal('foo,''foo'',foo.txt', join([expand('%:r'), expand('%:r:S'), expand('%')], ','))
+ quit
+
+ call assert_equal("'abc\ndef'", fnamemodify("abc\ndef", ':S'))
+ set shell=tcsh
+ call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
+ endfunc
+
+ func Test_expand()
+ new
+ call assert_equal("", expand('%:S'))
+ quit
+ endfunc
+ ]=])
+ end)
+
+ it('is working', function()
+ call('Test_fnamemodify')
+ expected_empty()
+ end)
+
+ it('works for :S in an unnamed buffer', function()
+ call('Test_expand')
+ expected_empty()
+ end)
+end)
diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua
new file mode 100644
index 0000000000..9083911021
--- /dev/null
+++ b/test/functional/legacy/function_sort_spec.lua
@@ -0,0 +1,29 @@
+local helpers = require('test.functional.helpers')
+local clear = helpers.clear
+local eq = helpers.eq
+local eval = helpers.eval
+
+describe('sort', function()
+ before_each(clear)
+
+ it('numbers compared as strings', function()
+ eq({1, 2, 3}, eval('sort([3, 2, 1])'))
+ eq({13, 28, 3}, eval('sort([3, 28, 13])'))
+ end)
+
+ it('numbers compared as numeric', function()
+ eq({1, 2, 3}, eval("sort([3, 2, 1], 'n')"))
+ eq({3, 13, 28}, eval("sort([3, 28, 13], 'n')"))
+ -- Strings are not sorted.
+ eq({'13', '28', '3'}, eval("sort(['13', '28', '3'], 'n')"))
+ end)
+
+ it('numbers compared as numbers', function()
+ eq({3, 13, 28}, eval("sort([13, 28, 3], 'N')"))
+ eq({'3', '13', '28'}, eval("sort(['13', '28', '3'], 'N')"))
+ end)
+
+ it('numbers compared as float', function()
+ eq({0.28, 3, 13.5}, eval("sort([13.5, 0.28, 3], 'f')"))
+ end)
+end)
diff --git a/test/functional/legacy/glob2regpat_spec.lua b/test/functional/legacy/glob2regpat_spec.lua
new file mode 100644
index 0000000000..0492143616
--- /dev/null
+++ b/test/functional/legacy/glob2regpat_spec.lua
@@ -0,0 +1,22 @@
+-- Tests for signs
+
+local helpers = require('test.functional.helpers')
+local clear, execute = helpers.clear, helpers.execute
+local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
+
+describe('glob2regpat()', function()
+ before_each(clear)
+
+ it('handles invalid input', function()
+ execute('call glob2regpat(1.33)')
+ helpers.feed('<cr>')
+ neq(nil, string.find(eval('v:errmsg'), '^E806:'))
+ end)
+ it('returns ^$ for empty input', function()
+ eq('^$', eval("glob2regpat('')"))
+ end)
+ it('handles valid input', function()
+ eq('^foo\\.', eval("glob2regpat('foo.*')"))
+ eq('\\.vim$', eval("glob2regpat('*.vim')"))
+ end)
+end)
diff --git a/test/functional/legacy/increment_spec.lua b/test/functional/legacy/increment_spec.lua
new file mode 100644
index 0000000000..4aa24c0d53
--- /dev/null
+++ b/test/functional/legacy/increment_spec.lua
@@ -0,0 +1,748 @@
+-- Tests for using Ctrl-A/Ctrl-X on visual selections
+
+local helpers = require('test.functional.helpers')
+local source, execute = helpers.source, helpers.execute
+local call, clear = helpers.call, helpers.clear
+local eq, nvim = helpers.eq, helpers.meths
+
+describe('Ctrl-A/Ctrl-X on visual selections', function()
+
+ before_each(function()
+ clear()
+ source([=[
+ " 1) Ctrl-A on visually selected number
+ " Text:
+ " foobar-10
+ " Expected:
+ " 1) Ctrl-A on start of line:
+ " foobar-9
+ " 2) Ctrl-A on visually selected "-10":
+ " foobar-9
+ " 3) Ctrl-A on visually selected "10":
+ " foobar-11
+ " 4) Ctrl-X on visually selected "-10"
+ " foobar-11
+ " 5) Ctrl-X on visually selected "10"
+ " foobar-9
+ func Test_visual_increment_01()
+ call setline(1, repeat(["foobaar-10"], 5))
+
+ call cursor(1, 1)
+ exec "norm! \<C-A>"
+ call assert_equal("foobaar-9", getline('.'))
+ call assert_equal([0, 1, 9, 0], getpos('.'))
+
+ call cursor(2, 1)
+ exec "norm! f-v$\<C-A>"
+ call assert_equal("foobaar-9", getline('.'))
+ call assert_equal([0, 2, 8, 0], getpos('.'))
+
+ call cursor(3, 1)
+ exec "norm! f1v$\<C-A>"
+ call assert_equal("foobaar-11", getline('.'))
+ call assert_equal([0, 3, 9, 0], getpos('.'))
+
+ call cursor(4, 1)
+ exec "norm! f-v$\<C-X>"
+ call assert_equal("foobaar-11", getline('.'))
+ call assert_equal([0, 4, 8, 0], getpos('.'))
+
+ call cursor(5, 1)
+ exec "norm! f1v$\<C-X>"
+ call assert_equal("foobaar-9", getline('.'))
+ call assert_equal([0, 5, 9, 0], getpos('.'))
+ endfunc
+
+ " 2) Ctrl-A on visually selected lines
+ " Text:
+ " 10
+ " 20
+ " 30
+ " 40
+ "
+ " Expected:
+ " 1) Ctrl-A on visually selected lines:
+ " 11
+ " 21
+ " 31
+ " 41
+ "
+ " 2) Ctrl-X on visually selected lines:
+ " 9
+ " 19
+ " 29
+ " 39
+ func Test_visual_increment_02()
+ call setline(1, ["10", "20", "30", "40"])
+ exec "norm! GV3k$\<C-A>"
+ call assert_equal(["11", "21", "31", "41"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["10", "20", "30", "40"])
+ exec "norm! GV3k$\<C-X>"
+ call assert_equal(["9", "19", "29", "39"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 3) g Ctrl-A on visually selected lines, with non-numbers in between
+ " Text:
+ " 10
+ "
+ " 20
+ "
+ " 30
+ "
+ " 40
+ "
+ " Expected:
+ " 1) 2 g Ctrl-A on visually selected lines:
+ " 12
+ "
+ " 24
+ "
+ " 36
+ "
+ " 48
+ " 2) 2 g Ctrl-X on visually selected lines
+ " 8
+ "
+ " 16
+ "
+ " 24
+ "
+ " 32
+ func Test_visual_increment_03()
+ call setline(1, ["10", "", "20", "", "30", "", "40"])
+ exec "norm! GV6k2g\<C-A>"
+ call assert_equal(["12", "", "24", "", "36", "", "48"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["10", "", "20", "", "30", "", "40"])
+ exec "norm! GV6k2g\<C-X>"
+ call assert_equal(["8", "", "16", "", "24", "", "32"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 4) Ctrl-A on non-number
+ " Text:
+ " foobar-10
+ " Expected:
+ " 1) visually select foobar:
+ " foobar-10
+ func Test_visual_increment_04()
+ call setline(1, ["foobar-10"])
+ exec "norm! vf-\<C-A>"
+ call assert_equal(["foobar-10"], getline(1, '$'))
+ " NOTE: I think this is correct behavior...
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 5) g<Ctrl-A> on letter
+ " Test:
+ " a
+ " a
+ " a
+ " a
+ " Expected:
+ " 1) g Ctrl-A on visually selected lines
+ " b
+ " c
+ " d
+ " e
+ func Test_visual_increment_05()
+ set nrformats+=alpha
+ call setline(1, repeat(["a"], 4))
+ exec "norm! GV3kg\<C-A>"
+ call assert_equal(["b", "c", "d", "e"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 6) g<Ctrl-A> on letter
+ " Test:
+ " z
+ " z
+ " z
+ " z
+ " Expected:
+ " 1) g Ctrl-X on visually selected lines
+ " y
+ " x
+ " w
+ " v
+ func Test_visual_increment_06()
+ set nrformats+=alpha
+ call setline(1, repeat(["z"], 4))
+ exec "norm! GV3kg\<C-X>"
+ call assert_equal(["y", "x", "w", "v"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 7) <Ctrl-A> on letter
+ " Test:
+ " 2
+ " 1
+ " 0
+ " -1
+ " -2
+ "
+ " Expected:
+ " 1) Ctrl-A on visually selected lines
+ " 3
+ " 2
+ " 1
+ " 0
+ " -1
+ "
+ " 2) Ctrl-X on visually selected lines
+ " 1
+ " 0
+ " -1
+ " -2
+ " -3
+ func Test_visual_increment_07()
+ call setline(1, ["2", "1", "0", "-1", "-2"])
+ exec "norm! GV4k\<C-A>"
+ call assert_equal(["3", "2", "1", "0", "-1"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["2", "1", "0", "-1", "-2"])
+ exec "norm! GV4k\<C-X>"
+ call assert_equal(["1", "0", "-1", "-2", "-3"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 8) Block increment on 0x9
+ " Text:
+ " 0x9
+ " 0x9
+ " Expected:
+ " 1) Ctrl-A on visually block selected region (cursor at beginning):
+ " 0xa
+ " 0xa
+ " 2) Ctrl-A on visually block selected region (cursor at end)
+ " 0xa
+ " 0xa
+ func Test_visual_increment_08()
+ call setline(1, repeat(["0x9"], 2))
+ exec "norm! \<C-V>j$\<C-A>"
+ call assert_equal(["0xa", "0xa"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, repeat(["0x9"], 2))
+ exec "norm! gg$\<C-V>+\<C-A>"
+ call assert_equal(["0xa", "0xa"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 9) Increment and redo
+ " Text:
+ " 2
+ " 2
+ "
+ " 3
+ " 3
+ "
+ " Expected:
+ " 1) 2 Ctrl-A on first 2 visually selected lines
+ " 4
+ " 4
+ " 2) redo (.) on 3
+ " 5
+ " 5
+ func Test_visual_increment_09()
+ call setline(1, ["2", "2", "", "3", "3", ""])
+ exec "norm! ggVj2\<C-A>"
+ call assert_equal(["4", "4", "", "3", "3", ""], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ exec "norm! 3j."
+ call assert_equal(["4", "4", "", "5", "5", ""], getline(1, '$'))
+ call assert_equal([0, 4, 1, 0], getpos('.'))
+ endfunc
+
+ " 10) sequentially decrement 1
+ " Text:
+ " 1
+ " 1
+ " 1
+ " 1
+ " Expected:
+ " 1) g Ctrl-X on visually selected lines
+ " 0
+ " -1
+ " -2
+ " -3
+ func Test_visual_increment_10()
+ call setline(1, repeat(["1"], 4))
+ exec "norm! GV3kg\<C-X>"
+ call assert_equal(["0", "-1", "-2", "-3"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 11) visually block selected indented lines
+ " Text:
+ " 1
+ " 1
+ " 1
+ " 1
+ " Expexted:
+ " 1) g Ctrl-A on block selected indented lines
+ " 2
+ " 1
+ " 3
+ " 4
+ func Test_visual_increment_11()
+ call setline(1, [" 1", "1", " 1", " 1"])
+ exec "norm! f1\<C-V>3jg\<C-A>"
+ call assert_equal([" 2", "1", " 3", " 4"], getline(1, '$'))
+ call assert_equal([0, 1, 5, 0], getpos('.'))
+ endfunc
+
+ " 12) visually selected several columns
+ " Text:
+ " 0 0
+ " 0 0
+ " 0 0
+ " Expected:
+ " 1) 'v' select last zero and first zeroes
+ " 0 1
+ " 1 0
+ " 1 0
+ func Test_visual_increment_12()
+ call setline(1, repeat(["0 0"], 3))
+ exec "norm! $v++\<C-A>"
+ call assert_equal(["0 1", "1 0", "1 0"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+ endfunc
+
+ " 13) visually selected part of columns
+ " Text:
+ " max: 100px
+ " max: 200px
+ " max: 300px
+ " max: 400px
+ " Expected:
+ " 1) 'v' on first two numbers Ctrl-A
+ " max: 110px
+ " max: 220px
+ " max: 330px
+ " max: 400px
+ " 2) 'v' on first two numbers Ctrl-X
+ " max: 90px
+ " max: 190px
+ " max: 290px
+ " max: 400px
+ func Test_visual_increment_13()
+ call setline(1, ["max: 100px", "max: 200px", "max: 300px", "max: 400px"])
+ exec "norm! f1\<C-V>l2j\<C-A>"
+ call assert_equal(["max: 110px", "max: 210px", "max: 310px", "max: 400px"], getline(1, '$'))
+ call assert_equal([0, 1, 6, 0], getpos('.'))
+
+ call setline(1, ["max: 100px", "max: 200px", "max: 300px", "max: 400px"])
+ exec "norm! ggf1\<C-V>l2j\<C-X>"
+ call assert_equal(["max: 90px", "max: 190px", "max: 290px", "max: 400px"], getline(1, '$'))
+ call assert_equal([0, 1, 6, 0], getpos('.'))
+ endfunc
+
+ " 14) redo in block mode
+ " Text:
+ " 1 1
+ " 1 1
+ " Expected:
+ " 1) Ctrl-a on first column, redo on second column
+ " 2 2
+ " 2 2
+ func Test_visual_increment_14()
+ call setline(1, repeat(["1 1"], 2))
+ exec "norm! G\<C-V>k\<C-A>w."
+ call assert_equal(["2 2", "2 2"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+ endfunc
+
+ " 15) block select single numbers
+ " Text:
+ " 101
+ " Expected:
+ " 1) Ctrl-a on visually selected zero
+ " 111
+ func Test_visual_increment_15()
+ call setline(1, ["101"])
+ exec "norm! lv\<C-A>"
+ call assert_equal(["111"], getline(1, '$'))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+ endfunc
+
+ " 16) increment right aligned numbers
+ " Text:
+ " 1
+ " 19
+ " 119
+ " Expected:
+ " 1) Ctrl-a on line selected region
+ " 2
+ " 20
+ " 120
+ func Test_visual_increment_16()
+ call setline(1, [" 1", " 19", " 119"])
+ exec "norm! VG\<C-A>"
+ call assert_equal([" 2", " 20", " 120"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 17) block-wise increment and redo
+ " Text:
+ " 100
+ " 1
+ "
+ " 100
+ " 1
+ "
+ " Expected:
+ " 1) Ctrl-V j $ on first block, afterwards '.' on second
+ " 101
+ " 2
+ "
+ " 101
+ " 2
+ func Test_visual_increment_17()
+ call setline(1, [" 100", " 1", "", " 100", " 1"])
+ exec "norm! \<C-V>j$\<C-A>2j."
+ call assert_equal([" 101", " 2", "", " 101", " 1"], getline(1, '$'))
+ call assert_equal([0, 3, 1, 0], getpos('.'))
+ endfunc
+
+ " 18) repeat of g<Ctrl-a>
+ " Text:
+ " 0
+ " 0
+ " 0
+ " 0
+ "
+ " Expected:
+ " 1) V 4j g<ctrl-a>, repeat twice afterwards with .
+ " 3
+ " 6
+ " 9
+ " 12
+ func Test_visual_increment_18()
+ call setline(1, repeat(["0"], 4))
+ exec "norm! GV3kg\<C-A>"
+ exec "norm! .."
+ call assert_equal(["3", "6", "9", "12"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 19) increment on number with nrformat including alpha
+ " Text:
+ " 1
+ " 1a
+ "
+ " Expected:
+ " 1) <Ctrl-V>j$ <ctrl-a>
+ " 2
+ " 2a
+ func Test_visual_increment_19()
+ set nrformats+=alpha
+ call setline(1, ["1", "1a"])
+ exec "norm! \<C-V>G$\<C-A>"
+ call assert_equal(["2", "2a"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 20) increment a single letter
+ " Text:
+ " a
+ "
+ " Expected:
+ " 1) <Ctrl-a> and cursor is on a
+ " b
+ func Test_visual_increment_20()
+ set nrformats+=alpha
+ call setline(1, ["a"])
+ exec "norm! \<C-A>"
+ call assert_equal(["b"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 21) block-wise increment on part of hexadecimal
+ " Text:
+ " 0x123456
+ "
+ " Expected:
+ " 1) Ctrl-V f3 <ctrl-a>
+ " 0x124456
+ func Test_visual_increment_21()
+ call setline(1, ["0x123456"])
+ exec "norm! \<C-V>f3\<C-A>"
+ call assert_equal(["0x124456"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 22) Block increment on 0b0
+ " Text:
+ " 0b1
+ " 0b1
+ " Expected:
+ " 1) Ctrl-A on visually block selected region (cursor at beginning):
+ " 0b10
+ " 0b10
+ " 2) Ctrl-A on visually block selected region (cursor at end)
+ " 0b10
+ " 0b10
+ func Test_visual_increment_22()
+ call setline(1, repeat(["0b1"], 2))
+ exec "norm! \<C-V>j$\<C-A>"
+ call assert_equal(repeat(["0b10"], 2), getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, repeat(["0b1"], 2))
+ exec "norm! $\<C-V>+\<C-A>"
+ call assert_equal(repeat(["0b10"], 2), getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 23) block-wise increment on part of binary
+ " Text:
+ " 0b1001
+ "
+ " Expected:
+ " 1) Ctrl-V 5l <ctrl-a>
+ " 0b1011
+ func Test_visual_increment_23()
+ call setline(1, ["0b1001"])
+ exec "norm! \<C-V>4l\<C-A>"
+ call assert_equal(["0b1011"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 24) increment hexadecimal
+ " Text:
+ " 0x0b1001
+ "
+ " Expected:
+ " 1) <ctrl-a>
+ " 0x0b1002
+ func Test_visual_increment_24()
+ call setline(1, ["0x0b1001"])
+ exec "norm! \<C-V>$\<C-A>"
+ call assert_equal(["0x0b1002"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 25) increment binary with nrformats including alpha
+ " Text:
+ " 0b1001a
+ "
+ " Expected:
+ " 1) <ctrl-a>
+ " 0b1010a
+ func Test_visual_increment_25()
+ set nrformats+=alpha
+ call setline(1, ["0b1001a"])
+ exec "norm! \<C-V>$\<C-A>"
+ call assert_equal(["0b1010a"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " 26) increment binary with 32 bits
+ " Text:
+ " 0b11111111111111111111111111111110
+ "
+ " Expected:
+ " 1) <ctrl-a>
+ " 0b11111111111111111111111111111111
+ func Test_visual_increment_26()
+ set nrformats+=alpha
+ call setline(1, ["0b11111111111111111111111111111110"])
+ exec "norm! \<C-V>$\<C-A>"
+ call assert_equal(["0b11111111111111111111111111111111"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ set nrformats-=alpha
+ endfunc
+
+ " 27) increment with 'rightreft', if supported
+ func Test_visual_increment_27()
+ if exists('+rightleft')
+ set rightleft
+ call setline(1, ["1234 56"])
+
+ exec "norm! $\<C-A>"
+ call assert_equal(["1234 57"], getline(1, '$'))
+ call assert_equal([0, 1, 7, 0], getpos('.'))
+
+ exec "norm! \<C-A>"
+ call assert_equal(["1234 58"], getline(1, '$'))
+ call assert_equal([0, 1, 7, 0], getpos('.'))
+ set norightleft
+ endif
+ endfunc
+
+ " Tab code and linewise-visual inc/dec
+ func Test_visual_increment_28()
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! Vj\<C-A>"
+ call assert_equal(["x\<TAB>11", "\<TAB>0"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! ggVj\<C-X>"
+ call assert_equal(["x\<TAB>9", "\<TAB>-2"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " Tab code and linewise-visual inc/dec with 'nrformats'+=alpha
+ func Test_visual_increment_29()
+ set nrformats+=alpha
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! Vj\<C-A>"
+ call assert_equal(["y\<TAB>10", "\<TAB>0"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! ggVj\<C-X>"
+ call assert_equal(["w\<TAB>10", "\<TAB>-2"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " Tab code and character-visual inc/dec
+ func Test_visual_increment_30()
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! f1vjf1\<C-A>"
+ call assert_equal(["x\<TAB>11", "\<TAB>0"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! ggf1vjf1\<C-X>"
+ call assert_equal(["x\<TAB>9", "\<TAB>-2"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+ endfunc
+
+ " Tab code and blockwise-visual inc/dec
+ func Test_visual_increment_31()
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! f1\<C-V>jl\<C-A>"
+ call assert_equal(["x\<TAB>11", "\<TAB>0"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+
+ call setline(1, ["x\<TAB>10", "\<TAB>-1"])
+ exec "norm! ggf1\<C-V>jl\<C-X>"
+ call assert_equal(["x\<TAB>9", "\<TAB>-2"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+ endfunc
+
+ " Tab code and blockwise-visual decrement with 'linebreak' and 'showbreak'
+ func Test_visual_increment_32()
+ 28vnew dummy_31
+ set linebreak showbreak=+
+ call setline(1, ["x\<TAB>\<TAB>\<TAB>10", "\<TAB>\<TAB>\<TAB>\<TAB>-1"])
+ exec "norm! ggf0\<C-V>jg_\<C-X>"
+ call assert_equal(["x\<TAB>\<TAB>\<TAB>1-1", "\<TAB>\<TAB>\<TAB>\<TAB>-2"], getline(1, '$'))
+ call assert_equal([0, 1, 6, 0], getpos('.'))
+ bwipe!
+ endfunc
+
+ " Tab code and blockwise-visual increment with $
+ func Test_visual_increment_33()
+ call setline(1, ["\<TAB>123", "456"])
+ exec "norm! gg0\<C-V>j$\<C-A>"
+ call assert_equal(["\<TAB>124", "457"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " Tab code and blockwise-visual increment and redo
+ func Test_visual_increment_34()
+ call setline(1, ["\<TAB>123", " 456789"])
+ exec "norm! gg0\<C-V>j\<C-A>"
+ call assert_equal(["\<TAB>123", " 457789"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ exec "norm! .."
+ call assert_equal(["\<TAB>123", " 459789"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " Tab code, spaces and character-visual increment and redo
+ func Test_visual_increment_35()
+ call setline(1, ["\<TAB>123", " 123", "\<TAB>123", "\<TAB>123"])
+ exec "norm! ggvjf3\<C-A>..."
+ call assert_equal(["\<TAB>127", " 127", "\<TAB>123", "\<TAB>123"], getline(1, '$'))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+ endfunc
+
+ " Tab code, spaces and blockwise-visual increment and redo
+ func Test_visual_increment_36()
+ call setline(1, [" 123", "\<TAB>456789"])
+ exec "norm! G0\<C-V>kl\<C-A>"
+ call assert_equal([" 123", "\<TAB>556789"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ exec "norm! ..."
+ call assert_equal([" 123", "\<TAB>856789"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ endfunc
+
+ " block-wise increment and dot-repeat
+ " Text:
+ " 1 23
+ " 4 56
+ "
+ " Expected:
+ " 1) f2 Ctrl-V jl <ctrl-a>, repeat twice afterwards with .
+ " 1 26
+ " 4 59
+ "
+ " Try with and without indent.
+ func Test_visual_increment_37()
+ call setline(1, [" 1 23", " 4 56"])
+ exec "norm! ggf2\<C-V>jl\<C-A>.."
+ call assert_equal([" 1 26", " 4 59"], getline(1, 2))
+
+ call setline(1, ["1 23", "4 56"])
+ exec "norm! ggf2\<C-V>jl\<C-A>.."
+ call assert_equal(["1 26", "4 59"], getline(1, 2))
+ endfunc
+
+ " Check redo after the normal mode increment
+ func Test_visual_increment_38()
+ exec "norm! i10\<ESC>5\<C-A>."
+ call assert_equal(["20"], getline(1, '$'))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+ endfunc
+
+ " Test what patch 7.3.414 fixed. Ctrl-A on "000" drops the leading zeros.
+ func Test_normal_increment_01()
+ call setline(1, "000")
+ exec "norm! gg0\<C-A>"
+ call assert_equal("001", getline(1))
+
+ call setline(1, "000")
+ exec "norm! gg$\<C-A>"
+ call assert_equal("001", getline(1))
+
+ call setline(1, "001")
+ exec "norm! gg0\<C-A>"
+ call assert_equal("002", getline(1))
+
+ call setline(1, "001")
+ exec "norm! gg$\<C-A>"
+ call assert_equal("002", getline(1))
+ endfunc
+ ]=])
+ end)
+
+ for i = 1, 38 do
+ local id = string.format('%02d', i)
+
+ it('works on Test ' .. id, function()
+ execute('set nrformats&vi') -- &vi makes Vim compatible
+ call('Test_visual_increment_' .. id)
+ eq({}, nvim.get_vvar('errors'))
+ end)
+ end
+
+ it('does not drop leading zeroes', function()
+ execute('set nrformats&vi') -- &vi makes Vim compatible
+ call('Test_normal_increment_01')
+ eq({}, nvim.get_vvar('errors'))
+ end)
+end)
diff --git a/test/functional/legacy/lispwords_spec.lua b/test/functional/legacy/lispwords_spec.lua
new file mode 100644
index 0000000000..48df4de55e
--- /dev/null
+++ b/test/functional/legacy/lispwords_spec.lua
@@ -0,0 +1,25 @@
+local helpers = require('test.functional.helpers')
+local clear = helpers.clear
+local eq = helpers.eq
+local eval = helpers.eval
+local execute = helpers.execute
+local source = helpers.source
+
+describe('lispwords', function()
+ before_each(clear)
+
+ it('should be set global-local',function()
+ source([[
+ setglobal lispwords=foo,bar,baz
+ setlocal lispwords-=foo
+ setlocal lispwords+=quux]])
+ eq('foo,bar,baz', eval('&g:lispwords'))
+ eq('bar,baz,quux', eval('&l:lispwords'))
+ eq('bar,baz,quux', eval('&lispwords'))
+
+ execute('setlocal lispwords<')
+ eq('foo,bar,baz', eval('&g:lispwords'))
+ eq('foo,bar,baz', eval('&l:lispwords'))
+ eq('foo,bar,baz', eval('&lispwords'))
+ end)
+end)
diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua
index 15d12ac4af..df0e817533 100644
--- a/test/functional/legacy/listlbr_utf8_spec.lua
+++ b/test/functional/legacy/listlbr_utf8_spec.lua
@@ -1,8 +1,9 @@
-- Test for linebreak and list option in utf-8 mode
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local feed = helpers.feed
+local clear, expect = helpers.clear, helpers.expect
describe('linebreak', function()
setup(clear)
@@ -32,16 +33,19 @@ describe('linebreak', function()
$put =g:line
wincmd p
endfu
+ "
let g:test ="Test 1: set linebreak + set list + fancy listchars"
exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
redraw!
let line=ScreenChar(winwidth(0),4)
call DoRecordScreen()
+ "
let g:test ="Test 2: set nolinebreak list"
set list nolinebreak
redraw!
let line=ScreenChar(winwidth(0),4)
call DoRecordScreen()
+ "
let g:test ="Test 3: set linebreak nolist"
$put =\"\t*mask = nil;\"
$
@@ -50,6 +54,7 @@ describe('linebreak', function()
redraw!
let line=ScreenChar(winwidth(0),4)
call DoRecordScreen()
+ "
let g:test ="Test 4: set linebreak list listchars and concealing"
let c_defines=['#define ABCDE 1','#define ABCDEF 1','#define ABCDEFG 1','#define ABCDEFGH 1', '#define MSG_MODE_FILE 1','#define MSG_MODE_CONSOLE 2','#define MSG_MODE_FILE_AND_CONSOLE 3','#define MSG_MODE_FILE_THEN_CONSOLE 4']
call append('$', c_defines)
@@ -61,6 +66,84 @@ describe('linebreak', function()
redraw!
let line=ScreenChar(winwidth(0),7)
call DoRecordScreen()
+ "
+ let g:test ="Test 5: set linebreak list listchars and concealing part2"
+ let c_defines=['bbeeeeee ; some text']
+ call append('$', c_defines)
+ $
+ norm! zt
+ set nowrap ts=2 list linebreak listchars=tab:>- cole=2 concealcursor=n
+ syn clear
+ syn match meaning /;\s*\zs.*/
+ syn match hasword /^\x\{8}/ contains=word
+ syn match word /\<\x\{8}\>/ contains=beginword,endword contained
+ syn match beginword /\<\x\x/ contained conceal
+ syn match endword /\x\{6}\>/ contained
+ hi meaning guibg=blue
+ hi beginword guibg=green
+ hi endword guibg=red
+ redraw!
+ let line=ScreenChar(winwidth(0),1)
+ call DoRecordScreen()
+ "
+ let g:test ="Test 6: Screenattributes for comment"
+ $put =g:test
+ call append('$', ' /* and some more */')
+ exe "set ft=c ts=7 linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
+ syntax on
+ hi SpecialKey term=underline ctermfg=red guifg=red
+ let attr=[]
+ nnoremap <expr> GG ":let attr += ['".screenattr(screenrow(),screencol())."']\n"
+ $
+ norm! zt0
+ ]])
+ feed('GGlGGlGGlGGlGGlGGlGGlGGlGGlGGl')
+ source([[
+ call append('$', ['ScreenAttributes for test6:'])
+ if attr[0] != attr[1] && attr[1] != attr[3] && attr[3] != attr[5]
+ call append('$', "Attribut 0 and 1 and 3 and 5 are different!")
+ else
+ call append('$', "Not all attributes are different")
+ endif
+ set cpo&vim linebreak selection=exclusive
+ let g:test ="Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char"
+ $put =g:test
+ ]])
+ feed("Golong line: <Esc>40afoobar <Esc>aTARGETÃ' at end<Esc>")
+ source([[
+ exe "norm! $3B\<C-v>eAx\<Esc>"
+ "
+ let g:test ="Test 9: a multibyte sign and colorcolumn"
+ let attr=[]
+ let attr2=[]
+ $put =''
+ $put ='a b c'
+ $put ='a b c'
+ set list nolinebreak cc=3
+ ]])
+ feed(':sign define foo text=<C-v>uff0b<CR>')
+ source([[
+ sign place 1 name=foo line=50 buffer=2
+ norm! 2kztj
+ let line1=line('.')
+ ]])
+ feed('0GGlGGlGGlGGl')
+ source([[
+ let line2=line('.')
+ let attr2=attr
+ let attr=[]
+ ]])
+ feed('0GGlGGlGGlGGl')
+ source([[
+ redraw!
+ let line=ScreenChar(winwidth(0),3)
+ call DoRecordScreen()
+ " expected: attr[2] is different because of colorcolumn
+ if attr[0] != attr2[0] || attr[1] != attr2[1] || attr[2] != attr2[2]
+ call append('$', "Screen attributes are different!")
+ else
+ call append('$', "Screen attributes are the same!")
+ endif
]])
-- Assert buffer contents.
@@ -102,6 +185,25 @@ describe('linebreak', function()
#define >CDEFGH>----1
#define >_FILE>--------->--->---1
#define >_CONSOLE>---------->---2
- #define >_FILE_AND_CONSOLE>---------3 ]])
+ #define >_FILE_AND_CONSOLE>---------3
+ bbeeeeee ; some text
+
+ Test 5: set linebreak list listchars and concealing part2
+ eeeeee>--->-;>some text
+ Test 6: Screenattributes for comment
+ /* and some more */
+ ScreenAttributes for test6:
+ Attribut 0 and 1 and 3 and 5 are different!
+ Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char
+ 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 TARGETÃx' at end
+
+ a b c
+ a b c
+
+ Test 9: a multibyte sign and colorcolumn
+ ¶
+ +a b c¶
+ a b c¶
+ Screen attributes are the same!]])
end)
end)
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua
index 4d377904f9..a0d19926cb 100644
--- a/test/functional/legacy/mapping_spec.lua
+++ b/test/functional/legacy/mapping_spec.lua
@@ -2,12 +2,12 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local execute, expect, wait = helpers.execute, helpers.expect, helpers.wait
describe('mapping', function()
before_each(clear)
- it('is working', function()
+ it('abbreviations with р (0x80)', function()
insert([[
test starts here:
]])
@@ -16,6 +16,46 @@ describe('mapping', function()
execute('inoreab чкпр vim')
feed('GAчкпр <esc>')
+ expect([[
+ test starts here:
+ vim ]])
+ end)
+
+ it('Ctrl-c works in Insert mode', function()
+ -- Mapping of ctrl-c in insert mode
+ execute('set cpo-=< cpo-=k')
+ execute('inoremap <c-c> <ctrl-c>')
+ execute('cnoremap <c-c> dummy')
+ execute('cunmap <c-c>')
+ feed('GA<cr>')
+ feed('TEST2: CTRL-C |')
+ wait()
+ feed('<c-c>A|<cr><esc>')
+ wait()
+ execute('unmap <c-c>')
+ execute('unmap! <c-c>')
+
+ expect([[
+
+ TEST2: CTRL-C |<ctrl-c>A|
+ ]])
+ end)
+
+ it('Ctrl-c works in Visual mode', function()
+ execute([[vnoremap <c-c> :<C-u>$put ='vmap works'<cr>]])
+ feed('GV')
+ -- XXX: For some reason the mapping is only triggered
+ -- when <C-c> is in a separate feed command.
+ wait()
+ feed('<c-c>')
+ execute('vunmap <c-c>')
+
+ expect([[
+
+ vmap works]])
+ end)
+
+ it('langmap', function()
-- langmap should not get remapped in insert mode.
execute('inoremap { FAIL_ilangmap')
execute('set langmap=+{ langnoremap')
@@ -37,14 +77,30 @@ describe('mapping', function()
-- Assert buffer contents.
expect([[
- test starts here:
- vim
+
+
+
+
+]])
end)
+ it('feedkeys', function()
+ insert([[
+ a b c d
+ a b c d
+ ]])
+
+ -- Vim's issue #212 (feedkeys insert mapping at current position)
+ execute('nnoremap . :call feedkeys(".", "in")<cr>')
+ feed('/^a b<cr>')
+ feed('0qqdw.ifoo<esc>qj0@q<esc>')
+ execute('unmap .')
+ expect([[
+ fooc d
+ fooc d
+ ]])
+ end)
+
it('i_CTRL-G_U', function()
-- <c-g>U<cursor> works only within a single line
execute('imapclear')
diff --git a/test/functional/legacy/marks_spec.lua b/test/functional/legacy/marks_spec.lua
new file mode 100644
index 0000000000..8e9ceb1653
--- /dev/null
+++ b/test/functional/legacy/marks_spec.lua
@@ -0,0 +1,53 @@
+local helpers = require('test.functional.helpers')
+local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('marks', function()
+ before_each(function()
+ clear()
+ end)
+
+ it('restores a deleted mark after delete-undo-redo-undo', function()
+ insert([[
+
+ textline A
+ textline B
+ textline C
+
+ Results:]])
+
+ execute([[:/^\t/+1]])
+ feed([[maddu<C-R>u]])
+ source([[
+ let g:a = string(getpos("'a"))
+ $put ='Mark after delete-undo-redo-undo: '.g:a
+ ]])
+
+ expect([=[
+
+ textline A
+ textline B
+ textline C
+
+ Results:
+ Mark after delete-undo-redo-undo: [0, 3, 2, 0]]=])
+ end)
+
+ it("CTRL-A and CTRL-X updates last changed mark '[, ']", function()
+ insert([[
+ CTRL-A CTRL-X:
+ 123 123 123
+ 123 123 123
+ 123 123 123]])
+
+ source([[
+ /^123/
+ execute "normal! \<C-A>`[v`]rAjwvjw\<C-X>`[v`]rX"]])
+
+ expect([=[
+ CTRL-A CTRL-X:
+ AAA 123 123
+ 123 XXXXXXX
+ XXX 123 123]=])
+ end)
+end)
diff --git a/test/functional/legacy/match_conceal_spec.lua b/test/functional/legacy/match_conceal_spec.lua
new file mode 100644
index 0000000000..0ffa3cae7a
--- /dev/null
+++ b/test/functional/legacy/match_conceal_spec.lua
@@ -0,0 +1,228 @@
+-- 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 87371c8294..fac3b03191 100644
--- a/test/functional/legacy/nested_function_spec.lua
+++ b/test/functional/legacy/nested_function_spec.lua
@@ -1,7 +1,7 @@
-- Tests for nested function.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect, source = helpers.execute, helpers.expect, helpers.source
describe('test_nested_function', function()
diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua
index 773acb9663..21e99c4aa1 100644
--- a/test/functional/legacy/options_spec.lua
+++ b/test/functional/legacy/options_spec.lua
@@ -1,13 +1,27 @@
--- Test if ":options" throws any exception. The options window seems to mess
--- other tests, so restart nvim in the teardown hook
-
local helpers = require('test.functional.helpers')
local command, clear = helpers.command, helpers.clear
+local source, expect = helpers.source, helpers.expect
describe('options', function()
setup(clear)
- it('is working', function()
+ it('should not throw any exception', function()
command('options')
end)
end)
+
+describe('set', function()
+ setup(clear)
+
+ it("should keep two comma when 'path' is changed", function()
+ source([[
+ set path=foo,,bar
+ set path-=bar
+ set path+=bar
+ $put =&path]])
+
+ expect([[
+
+ foo,,bar]])
+ end)
+end)
diff --git a/test/functional/legacy/qf_title_spec.lua b/test/functional/legacy/qf_title_spec.lua
index aa005117be..01c781cc05 100644
--- a/test/functional/legacy/qf_title_spec.lua
+++ b/test/functional/legacy/qf_title_spec.lua
@@ -1,8 +1,8 @@
-- Tests for quickfix window's title
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('qf_title', function()
setup(clear)
diff --git a/test/functional/legacy/quickfix_spec.lua b/test/functional/legacy/quickfix_spec.lua
new file mode 100644
index 0000000000..88f86815b3
--- /dev/null
+++ b/test/functional/legacy/quickfix_spec.lua
@@ -0,0 +1,17 @@
+-- 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
new file mode 100644
index 0000000000..075b24b897
--- /dev/null
+++ b/test/functional/legacy/search_mbyte_spec.lua
@@ -0,0 +1,26 @@
+local helpers = require('test.functional.helpers')
+local insert = helpers.insert
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('search_mbyte', function()
+ before_each(clear)
+
+ it("search('multi-byte char', 'bce')", function()
+ insert([=[
+ Results:
+
+ Test bce:
+ A]=])
+
+ execute('/^Test bce:/+1')
+ execute([[$put =search('A', 'bce', line('.'))]])
+
+ -- Assert buffer contents.
+ expect([=[
+ Results:
+
+ Test bce:
+ A
+ 4]=])
+ end)
+end)
diff --git a/test/functional/legacy/searchpos_spec.lua b/test/functional/legacy/searchpos_spec.lua
new file mode 100644
index 0000000000..1c9b1ccee6
--- /dev/null
+++ b/test/functional/legacy/searchpos_spec.lua
@@ -0,0 +1,35 @@
+local helpers = require('test.functional.helpers')
+local call = helpers.call
+local clear = helpers.clear
+local execute = helpers.execute
+local eq = helpers.eq
+local eval = helpers.eval
+local insert = helpers.insert
+
+describe('searchpos', function()
+ before_each(clear)
+
+ it('is working', function()
+ insert([[
+ 1a3
+ 123xyz]])
+
+ call('cursor', 1, 1)
+ eq({1, 1, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
+ call('cursor', 1, 2)
+ eq({2, 1, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
+
+ execute('set cpo-=c')
+ call('cursor', 1, 2)
+ eq({1, 2, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
+ call('cursor', 1, 3)
+ eq({1, 3, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
+
+ -- Now with \zs, first match is in column 0, "a" is matched.
+ call('cursor', 1, 3)
+ eq({2, 4, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW')]]))
+ -- With z flag start at cursor column, don't see the "a".
+ call('cursor', 1, 3)
+ eq({2, 4, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz')]]))
+ end)
+end)
diff --git a/test/functional/legacy/set_spec.lua b/test/functional/legacy/set_spec.lua
new file mode 100644
index 0000000000..f81fcd3700
--- /dev/null
+++ b/test/functional/legacy/set_spec.lua
@@ -0,0 +1,15 @@
+-- Tests for :set
+
+local helpers = require('test.functional.helpers')
+local clear, execute, eval, eq =
+ helpers.clear, helpers.execute, helpers.eval, helpers.eq
+
+describe(':set', function()
+ before_each(clear)
+
+ it('recognizes a trailing comma with +=', function()
+ execute('set wildignore=*.png,')
+ execute('set wildignore+=*.jpg')
+ eq('*.png,*.jpg', eval('&wildignore'))
+ end)
+end)
diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua
index 89b2bf3b73..5a834c39e3 100644
--- a/test/functional/legacy/signs_spec.lua
+++ b/test/functional/legacy/signs_spec.lua
@@ -1,7 +1,6 @@
-- Tests for signs
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('signs', function()
diff --git a/test/functional/legacy/tagcase_spec.lua b/test/functional/legacy/tagcase_spec.lua
new file mode 100644
index 0000000000..9a8c6fbe42
--- /dev/null
+++ b/test/functional/legacy/tagcase_spec.lua
@@ -0,0 +1,150 @@
+local helpers = require('test.functional.helpers')
+local clear = helpers.clear
+local eq = helpers.eq
+local eval = helpers.eval
+local exc_exec = helpers.exc_exec
+local expect = helpers.expect
+local insert = helpers.insert
+local source = helpers.source
+local write_file = helpers.write_file
+
+describe("'tagcase' option", function()
+ setup(function()
+ write_file('Xtags', [[
+ Bar Xtext 3
+ Foo Xtext 2
+ foo Xtext 4]])
+ end)
+
+ before_each(function()
+ clear()
+ source([[
+ lang mess C
+ set tags=Xtags]])
+ end)
+
+ teardown(function()
+ os.remove('Xtags')
+ end)
+
+ it('should have correct default values', function()
+ source([[
+ set ic&
+ setg tc&
+ setl tc&
+ ]])
+
+ eq(0, eval('&ic'))
+ eq('followic', eval('&g:tc'))
+ eq('followic', eval('&l:tc'))
+ eq('followic', eval('&tc'))
+ end)
+
+ it('should accept <empty> only for setlocal', function()
+ -- Verify that the local setting accepts <empty> but that the global setting
+ -- does not. The first of these (setting the local value to <empty>) should
+ -- succeed; the other two should fail.
+ eq(0, exc_exec('setl tc='))
+ eq('Vim(setglobal):E474: Invalid argument: tc=', exc_exec('setg tc='))
+ eq('Vim(set):E474: Invalid argument: tc=', exc_exec('set tc='))
+ end)
+
+ it("should work with 'ignorecase' correctly in all combinations", function()
+ -- Verify that the correct number of matching tags is found for all values of
+ -- 'ignorecase' and global and local values 'tagcase', in all combinations.
+ insert([[
+
+ Foo
+ Bar
+ foo
+
+ end text]])
+
+ source([[
+ for &ic in [0, 1]
+ for &g:tc in ["followic", "ignore", "match"]
+ for &l:tc in ["", "followic", "ignore", "match"]
+ call append('$', "ic=".&ic." g:tc=".&g:tc." l:tc=".&l:tc." tc=".&tc)
+ call append('$', len(taglist("^foo$")))
+ call append('$', len(taglist("^Foo$")))
+ endfor
+ endfor
+ endfor
+
+ 1,/^end text$/d]])
+
+ expect([[
+ ic=0 g:tc=followic l:tc= tc=followic
+ 1
+ 1
+ ic=0 g:tc=followic l:tc=followic tc=followic
+ 1
+ 1
+ ic=0 g:tc=followic l:tc=ignore tc=ignore
+ 2
+ 2
+ ic=0 g:tc=followic l:tc=match tc=match
+ 1
+ 1
+ ic=0 g:tc=ignore l:tc= tc=ignore
+ 2
+ 2
+ ic=0 g:tc=ignore l:tc=followic tc=followic
+ 1
+ 1
+ ic=0 g:tc=ignore l:tc=ignore tc=ignore
+ 2
+ 2
+ ic=0 g:tc=ignore l:tc=match tc=match
+ 1
+ 1
+ ic=0 g:tc=match l:tc= tc=match
+ 1
+ 1
+ ic=0 g:tc=match l:tc=followic tc=followic
+ 1
+ 1
+ ic=0 g:tc=match l:tc=ignore tc=ignore
+ 2
+ 2
+ ic=0 g:tc=match l:tc=match tc=match
+ 1
+ 1
+ ic=1 g:tc=followic l:tc= tc=followic
+ 2
+ 2
+ ic=1 g:tc=followic l:tc=followic tc=followic
+ 2
+ 2
+ ic=1 g:tc=followic l:tc=ignore tc=ignore
+ 2
+ 2
+ ic=1 g:tc=followic l:tc=match tc=match
+ 1
+ 1
+ ic=1 g:tc=ignore l:tc= tc=ignore
+ 2
+ 2
+ ic=1 g:tc=ignore l:tc=followic tc=followic
+ 2
+ 2
+ ic=1 g:tc=ignore l:tc=ignore tc=ignore
+ 2
+ 2
+ ic=1 g:tc=ignore l:tc=match tc=match
+ 1
+ 1
+ ic=1 g:tc=match l:tc= tc=match
+ 1
+ 1
+ ic=1 g:tc=match l:tc=followic tc=followic
+ 2
+ 2
+ ic=1 g:tc=match l:tc=ignore tc=ignore
+ 2
+ 2
+ ic=1 g:tc=match l:tc=match tc=match
+ 1
+ 1]])
+ end)
+end)
diff --git a/test/functional/legacy/textobjects_spec.lua b/test/functional/legacy/textobjects_spec.lua
new file mode 100644
index 0000000000..1e8e0b0bcb
--- /dev/null
+++ b/test/functional/legacy/textobjects_spec.lua
@@ -0,0 +1,61 @@
+local helpers = require('test.functional.helpers')
+local call = helpers.call
+local clear = helpers.clear
+local execute = helpers.execute
+local expect = helpers.expect
+local source = helpers.source
+
+describe('Text object', function()
+ before_each(function()
+ clear()
+ execute('set shada=')
+ source([[
+ function SelectionOut(data)
+ new
+ call setline(1, a:data)
+ call setreg('"', '')
+ normal! ggfrmavi)y
+ $put =getreg('\"')
+ call setreg('"', '')
+ normal! `afbmavi)y
+ $put =getreg('\"')
+ call setreg('"', '')
+ normal! `afgmavi)y
+ $put =getreg('\"')
+ endfunction
+ ]])
+ end)
+
+ it('Test for vi) without cpo-M', function()
+ execute('set cpo-=M')
+ call('SelectionOut', '(red \\(blue) green)')
+
+ expect([[
+ (red \(blue) green)
+ red \(blue
+ red \(blue
+ ]])
+ end)
+
+ it('Test for vi) with cpo-M #1', function()
+ execute('set cpo+=M')
+ call('SelectionOut', '(red \\(blue) green)')
+
+ expect([[
+ (red \(blue) green)
+ red \(blue) green
+ blue
+ red \(blue) green]])
+ end)
+
+ it('Test for vi) with cpo-M #2', function()
+ execute('set cpo+=M')
+ call('SelectionOut', '(red (blue\\) green)')
+
+ expect([[
+ (red (blue\) green)
+ red (blue\) green
+ blue\
+ red (blue\) green]])
+ end)
+end)
diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua
new file mode 100644
index 0000000000..41274b3a04
--- /dev/null
+++ b/test/functional/legacy/undolevels_spec.lua
@@ -0,0 +1,58 @@
+local helpers = require('test.functional.helpers')
+local source, clear = helpers.source, helpers.clear
+local eq, nvim = helpers.eq, helpers.meths
+
+describe('undolevel', function()
+ setup(clear)
+
+ it('is working', function()
+ source([[
+ func FillBuffer()
+ for i in range(1,13)
+ put=i
+ " Set 'undolevels' to split undo.
+ exe "setg ul=" . &g:ul
+ endfor
+ endfunc
+
+ func Test_global_local_undolevels()
+ new one
+ set undolevels=5
+ call FillBuffer()
+ " will only undo the last 5 changes, end up with 13 - (5 + 1) = 7 lines
+ earlier 10
+ call assert_equal(5, &g:undolevels)
+ call assert_equal(-123456, &l:undolevels)
+ call assert_equal('7', getline('$'))
+
+ new two
+ setlocal undolevels=2
+ call FillBuffer()
+ " will only undo the last 2 changes, end up with 13 - (2 + 1) = 10 lines
+ earlier 10
+ call assert_equal(5, &g:undolevels)
+ call assert_equal(2, &l:undolevels)
+ call assert_equal('10', getline('$'))
+
+ setlocal ul=10
+ call assert_equal(5, &g:undolevels)
+ call assert_equal(10, &l:undolevels)
+
+ " Setting local value in "two" must not change local value in "one"
+ wincmd p
+ call assert_equal(5, &g:undolevels)
+ call assert_equal(-123456, &l:undolevels)
+
+ new three
+ setglobal ul=50
+ call assert_equal(50, &g:undolevels)
+ call assert_equal(-123456, &l:undolevels)
+
+ endfunc
+
+ call Test_global_local_undolevels()
+ ]])
+
+ eq({}, nvim.get_vvar('errors'))
+ end)
+end)
diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua
index ef717042d0..d33ba6b5fd 100644
--- a/test/functional/legacy/utf8_spec.lua
+++ b/test/functional/legacy/utf8_spec.lua
@@ -3,9 +3,11 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
+local eq, eval = helpers.eq, helpers.eval
+local source = helpers.source
describe('utf8', function()
- setup(clear)
+ before_each(clear)
it('is working', function()
insert('start:')
@@ -27,4 +29,55 @@ describe('utf8', function()
xあああ
bxbb]])
end)
+
+ it('strchars()', function()
+ eq(1, eval('strchars("a")'))
+ eq(1, eval('strchars("a", 0)'))
+ eq(1, eval('strchars("a", 1)'))
+
+ eq(3, eval('strchars("あいa")'))
+ eq(3, eval('strchars("あいa", 0)'))
+ eq(3, eval('strchars("あいa", 1)'))
+
+ eq(2, eval('strchars("A\\u20dd")'))
+ eq(2, eval('strchars("A\\u20dd", 0)'))
+ eq(1, eval('strchars("A\\u20dd", 1)'))
+
+ eq(3, eval('strchars("A\\u20dd\\u20dd")'))
+ eq(3, eval('strchars("A\\u20dd\\u20dd", 0)'))
+ eq(1, eval('strchars("A\\u20dd\\u20dd", 1)'))
+
+ eq(1, eval('strchars("\\u20dd")'))
+ eq(1, eval('strchars("\\u20dd", 0)'))
+ eq(1, eval('strchars("\\u20dd", 1)'))
+ end)
+
+ it('customlist completion', function()
+ source([[
+ function! CustomComplete1(lead, line, pos)
+ return ['あ', 'い']
+ endfunction
+ command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo]])
+ feed(":Test1 <C-L>'<C-B>$put='<CR>")
+
+ source([[
+ function! CustomComplete2(lead, line, pos)
+ return ['あたし', 'あたま', 'あたりめ']
+ endfunction
+ command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo]])
+ feed(":Test2 <C-L>'<C-B>$put='<CR>")
+
+ source([[
+ function! CustomComplete3(lead, line, pos)
+ return ['Nこ', 'Nん', 'Nぶ']
+ endfunction
+ command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo]])
+ feed(":Test3 <C-L>'<C-B>$put='<CR>")
+
+ expect([[
+
+ Test1
+ Test2 あた
+ Test3 N]])
+ end)
end)
diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua
new file mode 100644
index 0000000000..ba7be8f21b
--- /dev/null
+++ b/test/functional/legacy/wordcount_spec.lua
@@ -0,0 +1,171 @@
+-- Test for wordcount() function
+
+local helpers = require('test.functional.helpers')
+local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local clear, execute = helpers.clear, helpers.execute
+local eq, eval = helpers.eq, helpers.eval
+
+describe('wordcount', function()
+ before_each(clear)
+
+ it('is working', function()
+ execute('set selection=inclusive')
+ execute('fileformat=unix')
+ execute('fileformats=unix')
+
+ insert([=[
+ RESULT test:]=])
+
+ execute('new')
+ source([=[
+ function DoRecordWin(...)
+ wincmd k
+ if exists("a:1")
+ call cursor(a:1)
+ endif
+ let result=[]
+ call add(result, getline(1, '$'))
+ call add(result, wordcount())
+ wincmd j
+ return result
+ endfunction
+ ]=])
+
+ source([=[
+ function PutInWindow(args)
+ wincmd k
+ %d _
+ call append(1, a:args)
+ wincmd j
+ endfunction
+ ]=])
+
+ source([=[
+ function! STL()
+ if mode() =~? 'V'
+ let g:visual_stat=wordcount()
+ endif
+ return string(wordcount())
+ endfunction
+ ]=])
+
+ -- Test 1: empty window
+ eq(eval('DoRecordWin()'),
+ eval([=[
+ [[''], {'chars': 0, 'cursor_chars': 0, 'words': 0, 'cursor_words': 0, 'bytes': 0, 'cursor_bytes': 0}]
+ ]=])
+ )
+
+ -- Test 2: some words, cursor at start
+ execute([[call PutInWindow('one two three')]])
+ eq(eval('DoRecordWin([1, 1, 0])'),
+ eval([=[
+ [['', 'one two three'], {'chars': 15, 'cursor_chars': 1, 'words': 3, 'cursor_words': 0, 'bytes': 15, 'cursor_bytes': 1}]
+ ]=])
+ )
+
+ -- Test 3: some words, cursor at end
+ execute([[call PutInWindow('one two three')]])
+ eq(eval('DoRecordWin([2, 99, 0])'),
+ eval([=[
+ [['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 14}]
+ ]=])
+ )
+
+ -- Test 4: some words, cursor at end, ve=all
+ execute('set ve=all')
+ execute([[call PutInWindow('one two three')]])
+ eq(eval('DoRecordWin([2,99,0])'),
+ eval([=[
+ [['', 'one two three'], {'chars': 15, 'cursor_chars': 15, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 15}]
+ ]=])
+ )
+ execute('set ve=')
+
+ -- Test 5: several lines with words
+ execute([=[call PutInWindow(['one two three', 'one two three', 'one two three'])]=])
+ eq(eval('DoRecordWin([4,99,0])'),
+ eval([=[
+ [['', 'one two three', 'one two three', 'one two three'], {'chars': 43, 'cursor_chars': 42, 'words': 9, 'cursor_words': 9, 'bytes': 43, 'cursor_bytes': 42}]
+ ]=])
+ )
+
+ -- Test 6: one line with BOM set
+ execute([[call PutInWindow('one two three')]])
+ execute('wincmd k')
+ execute('set bomb')
+ execute('wincmd j')
+ eq(eval('DoRecordWin([2,99,0])'),
+ eval([=[
+ [['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 18, 'cursor_bytes': 14}]
+ ]=])
+ )
+ execute('wincmd k')
+ execute('set nobomb')
+ execute('wincmd j')
+
+ -- Test 7: one line with multibyte words
+ execute([=[call PutInWindow(['Äne M¤ne Müh'])]=])
+ eq(eval('DoRecordWin([2,99,0])'),
+ eval([=[
+ [['', 'Äne M¤ne Müh'], {'chars': 14, 'cursor_chars': 13, 'words': 3, 'cursor_words': 3, 'bytes': 17, 'cursor_bytes': 16}]
+ ]=])
+ )
+
+ -- Test 8: several lines with multibyte words
+ execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ eq(eval('DoRecordWin([3,99,0])'),
+ eval([=[
+ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'cursor_chars': 31, 'words': 7, 'cursor_words': 7, 'bytes': 36, 'cursor_bytes': 35}]
+ ]=])
+ )
+
+ -- Test 9: visual mode, complete buffer
+ execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ execute('wincmd k')
+ execute('set ls=2 stl=%{STL()}')
+ -- -- Start visual mode quickly and select complete buffer.
+ execute('0')
+ feed('V2jy<cr>')
+ execute('set stl= ls=1')
+ execute('let log=DoRecordWin([3,99,0])')
+ execute('let log[1]=g:visual_stat')
+ eq(eval('log'),
+ eval([=[
+ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 32, 'visual_words': 7, 'visual_bytes': 36}]
+ ]=])
+ )
+
+ -- Test 10: visual mode (empty)
+ execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ execute('wincmd k')
+ execute('set ls=2 stl=%{STL()}')
+ -- Start visual mode quickly and select complete buffer.
+ execute('0')
+ feed('v$y<cr>')
+ execute('set stl= ls=1')
+ execute('let log=DoRecordWin([3,99,0])')
+ execute('let log[1]=g:visual_stat')
+ eq(eval('log'),
+ eval([=[
+ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 1, 'visual_words': 0, 'visual_bytes': 1}]
+ ]=])
+ )
+
+ -- Test 11: visual mode, single line
+ execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ execute('wincmd k')
+ execute('set ls=2 stl=%{STL()}')
+ -- Start visual mode quickly and select complete buffer.
+ execute('2')
+ feed('0v$y<cr>')
+ execute('set stl= ls=1')
+ execute('let log=DoRecordWin([3,99,0])')
+ execute('let log[1]=g:visual_stat')
+ eq(eval('log'),
+ eval([=[
+ [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 13, 'visual_words': 3, 'visual_bytes': 16}]
+ ]=])
+ )
+ end)
+end)
diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua
index e7a260bcd9..efdfc1d09f 100644
--- a/test/functional/legacy/writefile_spec.lua
+++ b/test/functional/legacy/writefile_spec.lua
@@ -1,7 +1,6 @@
-- Tests for writefile()
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('writefile', function()