diff src/testdir/test_substitute.vim @ 16419:aebcd20a8a3f v8.1.1214

patch 8.1.1214: old style tests commit https://github.com/vim/vim/commit/c6b37db1ba704455daa8f9e78bc1c2492fb81f40 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 27 18:00:34 2019 +0200 patch 8.1.1214: old style tests Problem: Old style tests. Solution: Move tests from test14 to new style test files. (Yegappan Lakshmanan, closes #4308)
author Bram Moolenaar <Bram@vim.org>
date Sat, 27 Apr 2019 18:15:05 +0200
parents 9994c50f7879
children 6ea3f93b4428
line wrap: on
line diff
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -640,3 +640,52 @@ func Test_nocatch_sub_failure_handling()
 
   bwipe!
 endfunc
+
+" Test ":s/pat/sub/" with different ~s in sub.
+func Test_replace_with_tilde()
+  new
+  " Set the last replace string to empty
+  s/^$//
+  call append(0, ['- Bug in "vPPPP" on this text:'])
+  normal gg
+  s/u/~u~/
+  call assert_equal('- Bug in "vPPPP" on this text:', getline(1))
+  s/i/~u~/
+  call assert_equal('- Bug uuun "vPPPP" on this text:', getline(1))
+  s/o/~~~/
+  call assert_equal('- Bug uuun "vPPPP" uuuuuuuuun this text:', getline(1))
+  close!
+endfunc
+
+func Test_replace_keeppatterns()
+  new
+  a
+foobar
+
+substitute foo asdf
+
+one two
+.
+
+  normal gg
+  /^substitute
+  s/foo/bar/
+  call assert_equal('foo', @/)
+  call assert_equal('substitute bar asdf', getline('.'))
+
+  /^substitute
+  keeppatterns s/asdf/xyz/
+  call assert_equal('^substitute', @/)
+  call assert_equal('substitute bar xyz', getline('.'))
+
+  exe "normal /bar /e\<CR>"
+  call assert_equal(15, col('.'))
+  normal -
+  keeppatterns /xyz
+  call assert_equal('bar ', @/)
+  call assert_equal('substitute bar xyz', getline('.'))
+  exe "normal 0dn"
+  call assert_equal('xyz', getline('.'))
+
+  close!
+endfunc