diff src/testdir/test_options.vim @ 19991:f27473034f26 v8.2.0551

patch 8.2.0551: not all code for options is tested Commit: https://github.com/vim/vim/commit/1363a30cef382b912bf092969e040333c5c293c6 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 12 13:50:26 2020 +0200 patch 8.2.0551: not all code for options is tested Problem: Not all code for options is tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5913)
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 Apr 2020 14:00:04 +0200
parents b07672d13ff9
children d13f8ae3b1de
line wrap: on
line diff
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -269,8 +269,53 @@ func Test_set_completion()
 
   call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
   call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
+  set tags&
 
-  set tags&
+  " Expanding the option names
+  call feedkeys(":set \<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"set all', @:)
+
+  " Expanding a second set of option names
+  call feedkeys(":set wrapscan \<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"set wrapscan all', @:)
+
+  " Expanding a special keycode
+  call feedkeys(":set <Home>\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"set <Home>', @:)
+
+  " Expanding an invalid special keycode
+  call feedkeys(":set <abcd>\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal("\"set <abcd>\<Tab>", @:)
+
+  " Expanding a terminal keycode
+  call feedkeys(":set t_AB\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal("\"set t_AB", @:)
+
+  " Expanding an invalid option name
+  call feedkeys(":set abcde=\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal("\"set abcde=\<Tab>", @:)
+
+  " Expanding after a = for a boolean option
+  call feedkeys(":set wrapscan=\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal("\"set wrapscan=\<Tab>", @:)
+
+  " Expanding a numeric option
+  call feedkeys(":set tabstop+=\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal("\"set tabstop+=" .. &tabstop, @:)
+
+  " Expanding a non-boolean option
+  call feedkeys(":set invtabstop=\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal("\"set invtabstop=", @:)
+
+  " Expand options for 'spellsuggest'
+  call feedkeys(":set spellsuggest=best,file:xyz\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal("\"set spellsuggest=best,file:xyz", @:)
+
+  " Expand value for 'key'
+  set key=abcd
+  call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"set key=*****', @:)
+  set key=
 endfunc
 
 func Test_set_errors()
@@ -327,7 +372,14 @@ func Test_set_errors()
   endif
   call assert_fails('set backupext=~ patchmode=~', 'E589:')
   call assert_fails('set winminheight=10 winheight=9', 'E591:')
+  set winminheight& winheight&
+  set winheight=10 winminheight=10
+  call assert_fails('set winheight=9', 'E591:')
+  set winminheight& winheight&
   call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
+  set winminwidth& winwidth&
+  call assert_fails('set winwidth=9 winminwidth=10', 'E592:')
+  set winwidth& winminwidth&
   call assert_fails("set showbreak=\x01", 'E595:')
   call assert_fails('set t_foo=', 'E846:')
   call assert_fails('set tabstop??', 'E488:')
@@ -338,9 +390,11 @@ func Test_set_errors()
   call assert_fails('set autoindent@', 'E488:')
   call assert_fails('set wildchar=<abc>', 'E474:')
   call assert_fails('set cmdheight=1a', 'E521:')
+  call assert_fails('set invcmdheight', 'E474:')
   if has('python') && has('python3')
     call assert_fails('set pyxversion=6', 'E474:')
   endif
+  call assert_fails("let &tabstop='ab'", 'E521:')
 endfunc
 
 func CheckWasSet(name)
@@ -798,7 +852,9 @@ endfunc
 func Test_opt_sandbox()
   for opt in ['backupdir', 'cdpath', 'exrc']
     call assert_fails('sandbox set ' .. opt .. '?', 'E48:')
+    call assert_fails('sandbox let &' .. opt .. ' = 1', 'E48:')
   endfor
+  call assert_fails('sandbox let &modelineexpr = 1', 'E48:')
 endfunc
 
 " Test for setting an option with local value to global value