summaryrefslogtreecommitdiff
path: root/src/testdir/test_substitute.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-09-02 19:50:48 +0200
committerBram Moolenaar <Bram@vim.org>2016-09-02 19:50:48 +0200
commitcd055da370114f66c960be9c8b1eb0f33a9e0a85 (patch)
treeec108b086ec04c67bc4f71e40b8128f9f021b60b /src/testdir/test_substitute.vim
parentda9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1 (diff)
downloadvim-git-cd055da370114f66c960be9c8b1eb0f33a9e0a85.tar.gz
patch 7.4.2307v7.4.2307
Problem: Several tests are old style. Solution: Turn them into new style tests. (Yegappan Lakshmanan)
Diffstat (limited to 'src/testdir/test_substitute.vim')
-rw-r--r--src/testdir/test_substitute.vim41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim
new file mode 100644
index 000000000..e2b6de03c
--- /dev/null
+++ b/src/testdir/test_substitute.vim
@@ -0,0 +1,41 @@
+" Tests for multi-line regexps with ":s".
+
+function! Test_multiline_subst()
+ enew!
+ call append(0, ["1 aa",
+ \ "bb",
+ \ "cc",
+ \ "2 dd",
+ \ "ee",
+ \ "3 ef",
+ \ "gh",
+ \ "4 ij",
+ \ "5 a8",
+ \ "8b c9",
+ \ "9d",
+ \ "6 e7",
+ \ "77f",
+ \ "xxxxx"])
+
+ 1
+ " test if replacing a line break works with a back reference
+ /^1/,/^2/s/\n\(.\)/ \1/
+ " test if inserting a line break works with a back reference
+ /^3/,/^4/s/\(.\)$/\r\1/
+ " test if replacing a line break with another line break works
+ /^5/,/^6/s/\(\_d\{3}\)/x\1x/
+ call assert_equal('1 aa bb cc 2 dd ee', getline(1))
+ call assert_equal('3 e', getline(2))
+ call assert_equal('f', getline(3))
+ call assert_equal('g', getline(4))
+ call assert_equal('h', getline(5))
+ call assert_equal('4 i', getline(6))
+ call assert_equal('j', getline(7))
+ call assert_equal('5 ax8', getline(8))
+ call assert_equal('8xb cx9', getline(9))
+ call assert_equal('9xd', getline(10))
+ call assert_equal('6 ex7', getline(11))
+ call assert_equal('7x7f', getline(12))
+ call assert_equal('xxxxx', getline(13))
+ enew!
+endfunction