]> granicus.if.org Git - vim/commitdiff
patch 8.2.1955: Vim9: not all command modifiers are tested v8.2.1955
authorBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 17:53:35 +0000 (18:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 17:53:35 +0000 (18:53 +0100)
Problem:    Vim9: not all command modifiers are tested.
Solution:   Add tests for remaining modifiers.

src/testdir/test_vim9_cmd.vim
src/version.c

index 71c47cdcefa8b815919fa5f2f5aa7e54607c3502..6751483f04c402b2af7764b18cdc2b2fb32fc0f3 100644 (file)
@@ -478,15 +478,62 @@ def Test_command_modifiers_keep()
 enddef
 
 def Test_command_modifier_other()
-  # TODO
-  # hide
-  # noautocmd
-  # noswapfile
-  # sandbox
-  # silent
-  # silent!
-  # unsilent
-  # verbose
+  new Xsomefile
+  setline(1, 'changed')
+  var buf = bufnr()
+  hide edit Xotherfile
+  var info = getbufinfo(buf)
+  assert_equal(1, info[0].hidden)
+  assert_equal(1, info[0].changed)
+  edit Xsomefile
+  bwipe!
+
+  au BufNewFile Xfile g:readFile = 1
+  g:readFile = 0
+  edit Xfile
+  assert_equal(1, g:readFile)
+  bwipe!
+  g:readFile = 0
+  noautocmd edit Xfile
+  assert_equal(0, g:readFile)
+
+  noswapfile edit XnoSwap
+  assert_equal(0, &l:swapfile)
+  bwipe!
+
+  var caught = false
+  try
+    sandbox !ls
+  catch /E48:/
+    caught = true
+  endtry
+  assert_true(caught)
+
+  :8verbose g:verbose_now = &verbose
+  assert_equal(8, g:verbose_now)
+  unlet g:verbose_now
+enddef
+
+def EchoHere()
+  echomsg 'here'
+enddef
+def EchoThere()
+  unsilent echomsg 'there'
+enddef
+
+def Test_modifier_silent_unsilent()
+  echomsg 'last one'
+  silent echomsg "text"
+  assert_equal("\nlast one", execute(':1messages'))
+
+  silent! echoerr "error"
+
+  echomsg 'last one'
+  silent EchoHere()
+  assert_equal("\nlast one", execute(':1messages'))
+
+  silent EchoThere()
+  assert_equal("\nthere", execute(':1messages'))
 enddef
 
 def Test_range_after_command_modifier()
@@ -587,17 +634,5 @@ def Test_f_args()
   CheckScriptSuccess(lines)
 enddef
 
-def Test_modifier_silent()
-  echomsg 'last one'
-  silent echomsg "text"
-  redir => g:testmsg
-    :1messages
-  redir END
-  assert_equal("\nlast one", g:testmsg)
-  unlet g:testmsg
-
-  silent! echoerr "error"
-enddef
-
 
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
index 231a4f0388030c46792b64ba4a165baff7c13c00..d4cddb8fbc044409a05456e73d524f1b19700fb5 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1955,
 /**/
     1954,
 /**/