diff src/testdir/test_substitute.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 1b02482e6a61
children 02111977dd05
line wrap: on
line diff
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -803,4 +803,19 @@ func Test_sub_expand_text()
   close!
 endfunc
 
+" Test for command failures when the last substitute pattern is not set.
+func Test_sub_with_no_last_pat()
+  call test_clear_search_pat()
+  call assert_fails('~', 'E33:')
+  call assert_fails('s//abc/g', 'E476:')
+  call assert_fails('s\/bar', 'E476:')
+  call assert_fails('s\&bar&', 'E476:')
+
+  call test_clear_search_pat()
+  let save_cpo = &cpo
+  set cpo+=/
+  call assert_fails('s/abc/%/', 'E33:')
+  let &cpo = save_cpo
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab