diff src/testdir/test_search.vim @ 19308:6fd567c927c0 v8.2.0212

patch 8.2.0212: missing search/substitute pattern hardly tested Commit: https://github.com/vim/vim/commit/07ada5ff2fd8f22ed3233ae5c4ddf87c7b3f56fe Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 5 20:38:22 2020 +0100 patch 8.2.0212: missing search/substitute pattern hardly tested Problem: Missing search/substitute pattern hardly tested. Solution: Add test_clear_search_pat() and tests. (Yegappan Lakshmanan, closes #5579)
author Bram Moolenaar <Bram@vim.org>
date Wed, 05 Feb 2020 20:45:04 +0100
parents f12eda320c78
children 02111977dd05
line wrap: on
line diff
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -1455,3 +1455,44 @@ func Test_search_special()
   set t_PE=
   exe "norm /\x80PS"
 endfunc
+
+" Test for command failures when the last search pattern is not set.
+func Test_search_with_no_last_pat()
+  call test_clear_search_pat()
+  call assert_fails("normal i\<C-R>/\e", 'E35:')
+  call assert_fails("exe '/'", 'E35:')
+  call assert_fails("exe '?'", 'E35:')
+  call assert_fails("/", 'E35:')
+  call assert_fails("?", 'E35:')
+  call assert_fails("normal n", 'E35:')
+  call assert_fails("normal N", 'E35:')
+  call assert_fails("normal gn", 'E35:')
+  call assert_fails("normal gN", 'E35:')
+  call assert_fails("normal cgn", 'E35:')
+  call assert_fails("normal cgN", 'E35:')
+  let p = []
+  let p = @/
+  call assert_equal('', p)
+  call assert_fails("normal :\<C-R>/", 'E35:')
+  call assert_fails("//p", 'E35:')
+  call assert_fails(";//p", 'E35:')
+  call assert_fails("??p", 'E35:')
+  call assert_fails(";??p", 'E35:')
+  call assert_fails('g//p', 'E476:')
+  call assert_fails('v//p', 'E476:')
+endfunc
+
+" Test for using tilde (~) atom in search. This should use the last used
+" substitute pattern
+func Test_search_tilde_pat()
+  call test_clear_search_pat()
+  set regexpengine=1
+  call assert_fails('exe "normal /~\<CR>"', 'E33:')
+  call assert_fails('exe "normal ?~\<CR>"', 'E33:')
+  set regexpengine=2
+  call assert_fails('exe "normal /~\<CR>"', 'E383:')
+  call assert_fails('exe "normal ?~\<CR>"', 'E383:')
+  set regexpengine&
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab