summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-06-13 21:52:48 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-13 21:52:48 +0200
commit2d6d718dde7163c971d37b8f4f1ed8f2d25de130 (patch)
tree6f2deb1e3ca27a26a719dd2dff28b583ba3714e7
parent5ffefbb35aba2448099314a9e09714d2f3b2b1bd (diff)
downloadvim-git-2d6d718dde7163c971d37b8f4f1ed8f2d25de130.tar.gz
patch 8.2.2994: various code is not fully testedv8.2.2994
Problem: Various code is not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #8378)
-rw-r--r--src/testdir/test_excmd.vim2
-rw-r--r--src/testdir/test_mapping.vim20
-rw-r--r--src/testdir/test_modeline.vim26
-rw-r--r--src/testdir/test_options.vim17
-rw-r--r--src/testdir/test_paste.vim60
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c2
7 files changed, 127 insertions, 2 deletions
diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim
index de82b5b77..514a4cfb7 100644
--- a/src/testdir/test_excmd.vim
+++ b/src/testdir/test_excmd.vim
@@ -596,7 +596,7 @@ func Sandbox_tests()
" some options cannot be changed in a sandbox
call assert_fails('set exrc', 'E48:')
call assert_fails('set cdpath', 'E48:')
- if has('xim')
+ if has('xim') && has('gui_gtk')
call assert_fails('set imstyle', 'E48:')
endif
endfunc
diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim
index 7fcd8062c..a447ba32f 100644
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -485,6 +485,11 @@ func Test_list_mappings()
call assert_equal(['n ,k <Nop>'],
\ execute('nmap ,k')->trim()->split("\n"))
+ " map with space at the beginning
+ exe "nmap \<C-V> w <Nop>"
+ call assert_equal(['n <Space>w <Nop>'],
+ \ execute("nmap \<C-V> w")->trim()->split("\n"))
+
nmapclear
endfunc
@@ -1411,4 +1416,19 @@ func Test_abbreviate_multi_byte()
bwipe!
endfunc
+" Test for abbreviations with 'latin1' encoding
+func Test_abbreviate_latin1_encoding()
+ set encoding=latin1
+ call assert_fails('abbr ab#$c ABC', 'E474:')
+ new
+ iabbr <buffer> #i #include
+ iabbr <buffer> ## #enddef
+ exe "normal i#i\<C-]>"
+ call assert_equal('#include', getline(1))
+ exe "normal 0Di##\<C-]>"
+ call assert_equal('#enddef', getline(1))
+ %bw!
+ set encoding=utf-8
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_modeline.vim b/src/testdir/test_modeline.vim
index 2618d307b..19c99b55e 100644
--- a/src/testdir/test_modeline.vim
+++ b/src/testdir/test_modeline.vim
@@ -334,4 +334,30 @@ func Test_modeline_setoption_verbose()
call delete('Xmodeline')
endfunc
+" Test for the 'modeline' default value in compatible and non-compatible modes
+" for root and non-root accounts
+func Test_modeline_default()
+ set compatible
+ call assert_false(&modeline)
+ set nocompatible
+ call assert_equal(IsRoot() ? 0 : 1, &modeline)
+ set compatible&vi
+ call assert_false(&modeline)
+ set compatible&vim
+ call assert_equal(IsRoot() ? 0 : 1, &modeline)
+ set compatible& modeline&
+endfunc
+
+" Some options cannot be set from the modeline when 'diff' option is set
+func Test_modeline_diff_buffer()
+ call writefile(['vim: diff foldmethod=marker wrap'], 'Xfile')
+ set foldmethod& nowrap
+ new Xfile
+ call assert_equal('manual', &foldmethod)
+ call assert_false(&wrap)
+ set wrap&
+ call delete('Xfile')
+ bw
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 2f64d1287..2d87920fa 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -1160,4 +1160,21 @@ func Test_cmdheight()
set cmdheight&
endfunc
+" To specify a control character as a option value, '^' can be used
+func Test_opt_control_char()
+ set wildchar=^v
+ call assert_equal("\<C-V>", nr2char(&wildchar))
+ set wildcharm=^r
+ call assert_equal("\<C-R>", nr2char(&wildcharm))
+ " Bug: This doesn't work for the 'cedit' and 'termwinkey' options
+ set wildchar& wildcharm&
+endfunc
+
+" Test for the 'errorbells' option
+func Test_opt_errorbells()
+ set errorbells
+ call assert_beeps('s/a1b2/x1y2/')
+ set noerrorbells
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim
index df732f156..ef35cec80 100644
--- a/src/testdir/test_paste.vim
+++ b/src/testdir/test_paste.vim
@@ -159,8 +159,68 @@ func Test_pastetoggle()
call feedkeys("i\<F4>", 'xt')
call assert_false(&paste)
call assert_equal('Hello', getline(1))
+ " command-line completion for 'pastetoggle' value
+ call feedkeys(":set pastetoggle=\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set pastetoggle=<F4>', @:)
set pastetoggle&
bwipe!
endfunc
+" Test for restoring option values when 'paste' is disabled
+func Test_paste_opt_restore()
+ set autoindent expandtab ruler showmatch
+ if has('rightleft')
+ set revins hkmap
+ endif
+ set smarttab softtabstop=3 textwidth=27 wrapmargin=12
+ if has('vartabs')
+ set varsofttabstop=10,20
+ endif
+
+ " enabling 'paste' should reset the above options
+ set paste
+ call assert_false(&autoindent)
+ call assert_false(&expandtab)
+ if has('rightleft')
+ call assert_false(&revins)
+ call assert_false(&hkmap)
+ endif
+ call assert_false(&ruler)
+ call assert_false(&showmatch)
+ call assert_false(&smarttab)
+ call assert_equal(0, &softtabstop)
+ call assert_equal(0, &textwidth)
+ call assert_equal(0, &wrapmargin)
+ if has('vartabs')
+ call assert_equal('', &varsofttabstop)
+ endif
+
+ " disabling 'paste' should restore the option values
+ set nopaste
+ call assert_true(&autoindent)
+ call assert_true(&expandtab)
+ if has('rightleft')
+ call assert_true(&revins)
+ call assert_true(&hkmap)
+ endif
+ call assert_true(&ruler)
+ call assert_true(&showmatch)
+ call assert_true(&smarttab)
+ call assert_equal(3, &softtabstop)
+ call assert_equal(27, &textwidth)
+ call assert_equal(12, &wrapmargin)
+ if has('vartabs')
+ call assert_equal('10,20', &varsofttabstop)
+ endif
+
+ set autoindent& expandtab& ruler& showmatch&
+ if has('rightleft')
+ set revins& hkmap&
+ endif
+ set smarttab& softtabstop& textwidth& wrapmargin&
+ if has('vartabs')
+ set varsofttabstop&
+ endif
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index b685257e5..58bd42016 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2994,
+/**/
2993,
/**/
2992,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index be8f30452..12f41f125 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -454,7 +454,7 @@ item_exists(char_u *name, size_t len, int cmd UNUSED, cctx_T *cctx)
if (name[len] == '(' || (p[0] == '-' && p[1] == '>'))
{
// Do not check for an internal function, since it might also be a
- // valid command, such as ":split" versuse "split()".
+ // valid command, such as ":split" versus "split()".
// Skip "g:" before a function name.
is_global = (name[0] == 'g' && name[1] == ':');
return find_func(is_global ? name + 2 : name, is_global, cctx) != NULL;