summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-30 20:21:58 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-30 20:21:58 +0200
commit1a333bc44a5d7e51575b1c3cd864fb37fd5b5f2b (patch)
treefc805899666a0a7e3a55e586588ff5e4e7d8f5fe /src
parentdc5471d482c372f547006325d7c8f16d6cc9d371 (diff)
downloadvim-1a333bc44a5d7e51575b1c3cd864fb37fd5b5f2b.zip
patch 8.0.1022: test 80 is old style
Problem: Test 80 is old style. Solution: Turn it into a new style test. (Yegappan Lakshmanan)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile16
-rw-r--r--src/testdir/Make_all.mak1
-rw-r--r--src/testdir/Make_vms.mms2
-rw-r--r--src/testdir/test80.in201
-rw-r--r--src/testdir/test80.ok131
-rw-r--r--src/testdir/test_substitute.vim180
-rw-r--r--src/version.c2
7 files changed, 191 insertions, 342 deletions
diff --git a/src/Makefile b/src/Makefile
index ecf14bc49..1d1ded80f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2100,17 +2100,17 @@ test1 \
test_listchars \
test_search_mbyte \
test_wordcount \
- test3 test4 test5 test6 test7 test8 test9 \
- test11 test12 test14 test15 test17 test18 test19 \
- test20 test21 test22 test25 test27 test28 test29 \
+ test3 test4 test5 test7 test8 \
+ test11 test12 test14 test15 test17 test19 \
+ test20 test25 test28 test29 \
test30 test31 test32 test33 test34 test36 test37 test38 test39 \
test40 test41 test42 test43 test44 test45 test48 test49 \
- test50 test51 test52 test53 test54 test55 test56 test57 test59 \
+ test50 test52 test53 test54 test55 test56 test57 test59 \
test60 test64 test66 test68 test69 \
- test70 test72 test73 test74 test77 test78 test79 \
- test80 test83 test84 test85 test86 test87 test88 \
- test91 test94 test95 test98 test99 \
- test100 test101 test103 test104 test107 test108:
+ test70 test72 test73 test77 test78 test79 \
+ test83 test85 test86 test87 test88 \
+ test94 test95 test99 \
+ test108:
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
# Run individual NEW style test, assuming that Vim was already compiled.
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 2a267d653..ad95b1b6e 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -50,7 +50,6 @@ SCRIPTS_ALL = \
test70.out \
test73.out \
test79.out \
- test80.out \
test88.out \
test94.out \
test95.out \
diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms
index 4181e0b3b..e48789b6f 100644
--- a/src/testdir/Make_vms.mms
+++ b/src/testdir/Make_vms.mms
@@ -86,7 +86,7 @@ SCRIPT = test1.out test3.out test4.out test5.out \
test64.out \
test66.out test68.out test69.out \
test72.out \
- test77a.out test78.out test79.out test80.out \
+ test77a.out test78.out test79.out \
test88.out \
test94.out \
test95.out test99.out \
diff --git a/src/testdir/test80.in b/src/testdir/test80.in
deleted file mode 100644
index e78e92118..000000000
--- a/src/testdir/test80.in
+++ /dev/null
@@ -1,201 +0,0 @@
-Test for *sub-replace-special* and *sub-replace-expression* on substitute().
-Test for submatch() on substitute().
-Test for *:s%* on :substitute.
-
-STARTTEST
-:so small.vim
-ENDTEST
-
-TEST_1:
-
-STARTTEST
-:set magic
-:set cpo&
-:$put =\"\n\nTEST_1:\"
-:$put =substitute('A', 'A', '&&', '')
-:$put =substitute('B', 'B', '\&', '')
-:$put =substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')
-:$put =substitute('D', 'D', 'd', '')
-:$put =substitute('E', 'E', '~', '')
-:$put =substitute('F', 'F', '\~', '')
-:$put =substitute('G', 'G', '\ugg', '')
-:$put =substitute('H', 'H', '\Uh\Eh', '')
-:$put =substitute('I', 'I', '\lII', '')
-:$put =substitute('J', 'J', '\LJ\EJ', '')
-:$put =substitute('K', 'K', '\Uk\ek', '')
-:$put =substitute('lLl', 'L', ' ', '')
-:$put =substitute('mMm', 'M', '\r', '')
-:$put =substitute('nNn', 'N', '\ ', '')
-:$put =substitute('oOo', 'O', '\n', '')
-:$put =substitute('pPp', 'P', '\b', '')
-:$put =substitute('qQq', 'Q', '\t', '')
-:$put =substitute('rRr', 'R', '\\', '')
-:$put =substitute('sSs', 'S', '\c', '')
-:$put =substitute('uUu', 'U', \"\n\", '')
-:$put =substitute('vVv', 'V', \"\b\", '')
-:$put =substitute('wWw', 'W', \"\\\", '')
-:$put =substitute('xXx', 'X', \"\r\", '')
-:$put =substitute('Y', 'Y', '\L\uyYy\l\EY', '')
-:$put =substitute('Z', 'Z', '\U\lZzZ\u\Ez', '')
-/^TEST_2
-ENDTEST
-
-TEST_2:
-
-STARTTEST
-:set nomagic
-:set cpo&
-:$put =\"\n\nTEST_2:\"
-:$put =substitute('A', 'A', '&&', '')
-:$put =substitute('B', 'B', '\&', '')
-:$put =substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')
-:$put =substitute('D', 'D', 'd', '')
-:$put =substitute('E', 'E', '~', '')
-:$put =substitute('F', 'F', '\~', '')
-:$put =substitute('G', 'G', '\ugg', '')
-:$put =substitute('H', 'H', '\Uh\Eh', '')
-:$put =substitute('I', 'I', '\lII', '')
-:$put =substitute('J', 'J', '\LJ\EJ', '')
-:$put =substitute('K', 'K', '\Uk\ek', '')
-:$put =substitute('lLl', 'L', ' ', '')
-:$put =substitute('mMm', 'M', '\r', '')
-:$put =substitute('nNn', 'N', '\ ', '')
-:$put =substitute('oOo', 'O', '\n', '')
-:$put =substitute('pPp', 'P', '\b', '')
-:$put =substitute('qQq', 'Q', '\t', '')
-:$put =substitute('rRr', 'R', '\\', '')
-:$put =substitute('sSs', 'S', '\c', '')
-:$put =substitute('tTt', 'T', \"\r\", '')
-:$put =substitute('uUu', 'U', \"\n\", '')
-:$put =substitute('vVv', 'V', \"\b\", '')
-:$put =substitute('wWw', 'W', \"\\\", '')
-:$put =substitute('X', 'X', '\L\uxXx\l\EX', '')
-:$put =substitute('Y', 'Y', '\U\lYyY\u\Ey', '')
-/^TEST_3
-ENDTEST
-
-TEST_3:
-
-STARTTEST
-:set magic&
-:set cpo&
-:$put =\"\n\nTEST_3:\"
-:let y = substitute('aAa', 'A', '\="\\"', '') | $put =y
-:let y = substitute('bBb', 'B', '\="\\\\"', '') | $put =y
-:let y = substitute('cCc', 'C', '\=" "', '') | $put =y
-:let y = substitute('dDd', 'D', '\="\\ "', '') | $put =y
-:let y = substitute('eEe', 'E', '\="\\\\ "', '') | $put =y
-:let y = substitute('fFf', 'F', '\="\\r"', '') | $put =y
-:let y = substitute('jJj', 'J', '\="\\n"', '') | $put =y
-:let y = substitute('kKk', 'K', '\="\r"', '') | $put =y
-:let y = substitute('lLl', 'L', '\="\n"', '') | $put =y
-/^TEST_4
-ENDTEST
-
-TEST_4:
-
-STARTTEST
-:set magic&
-:set cpo&
-:$put =\"\n\nTEST_4:\"
-:let y = substitute('aAa', 'A', '\=substitute(submatch(0), ".", "\\", "")', '') | $put =y
-:let y = substitute('bBb', 'B', '\=substitute(submatch(0), ".", "\\\\", "")', '') | $put =y
-:let y = substitute('cCc', 'C', '\=substitute(submatch(0), ".", " ", "")', '') | $put =y
-:let y = substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\ ", "")', '') | $put =y
-:let y = substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\ ", "")', '') | $put =y
-:let y = substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', '') | $put =y
-:let y = substitute('jJj', 'J', '\=substitute(submatch(0), ".", "\\n", "")', '') | $put =y
-:let y = substitute('kKk', 'K', '\=substitute(submatch(0), ".", "\r", "")', '') | $put =y
-:let y = substitute('lLl', 'L', '\=substitute(submatch(0), ".", "\n", "")', '') | $put =y
-/^TEST_5
-ENDTEST
-
-TEST_5:
-
-STARTTEST
-:set magic&
-:set cpo&
-:$put =\"\n\nTEST_5:\"
-:$put =substitute('A123456789', 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)', '')
-:$put =substitute('A123456789', 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\=string([submatch(0, 1), submatch(9, 1), submatch(8, 1), submatch(7, 1), submatch(6, 1), submatch(5, 1), submatch(4, 1), submatch(3, 1), submatch(2, 1), submatch(1, 1)])', '')
-/^TEST_6
-ENDTEST
-
-TEST_6:
-
-STARTTEST
-:set magic&
-:$put =\"\n\nTEST_6:\"
-:set cpo+=/
-:$put =substitute('A', 'A', 'a', '')
-:$put =substitute('B', 'B', '%', '')
-:set cpo-=/
-:$put =substitute('C', 'C', 'c', '')
-:$put =substitute('D', 'D', '%', '')
-/^TEST_7
-ENDTEST
-
-TEST_7:
-
-STARTTEST
-:set magic&
-:set cpo&
-:$put =\"\n\nTEST_7:\"
-:$put =substitute('A A', 'A.', '\=submatch(0)', '')
-:$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
-:$put =substitute(\"B\nB\", 'B.', '\=string(submatch(0, 1))', '')
-:$put =substitute('-bb', '\zeb', 'a', 'g')
-:$put =substitute('-bb', '\ze', 'c', 'g')
-/^TEST_8
-ENDTEST
-
-TEST_8:
-
-STARTTEST
-:set magic&
-:set cpo&
-:$put =\"\n\nTEST_8:\"
-:$put =',,X'
-:s/\(^\|,\)\ze\(,\|X\)/\1N/g
-:$put =',,Y'
-:s/\(^\|,\)\ze\(,\|Y\)/\1N/gc
-a:$put =',,Z'
-:s/\(^\|,\)\ze\(,\|Z\)/\1N/gc
-yy/^TEST_9:
-ENDTEST
-
-TEST_9:
-
-STARTTEST
-:set magic&
-:set cpo&
-:$put =\"\n\nTEST_9:\"
-:$put ='xxx'
-:s/x/X/gc
-yyq/^TEST_10:
-ENDTEST
-
-TEST_10:
-
-STARTTEST
-:set magic&
-:set cpo&
-:$put =\"\n\nTEST_10:\"
-:let y = substitute('123', '\zs', 'a', 'g') | $put =y
-:let y = substitute('123', '\zs.', 'a', 'g') | $put =y
-:let y = substitute('123', '.\zs', 'a', 'g') | $put =y
-:let y = substitute('123', '\ze', 'a', 'g') | $put =y
-:let y = substitute('123', '\ze.', 'a', 'g') | $put =y
-:let y = substitute('123', '.\ze', 'a', 'g') | $put =y
-:let y = substitute('123', '1\|\ze', 'a', 'g') | $put =y
-:let y = substitute('123', '1\zs\|[23]', 'a', 'g') | $put =y
-/^TEST_11
-ENDTEST
-
-TEST_11:
-
-STARTTEST
-:/^Results/,$wq! test.out
-ENDTEST
-
-Results of test72:
diff --git a/src/testdir/test80.ok b/src/testdir/test80.ok
deleted file mode 100644
index b42f604a0..000000000
--- a/src/testdir/test80.ok
+++ /dev/null
@@ -1,131 +0,0 @@
-Results of test72:
-
-
-TEST_1:
-AA
-&
-C123456789987654321
-d
-~
-~
-Gg
-Hh
-iI
-jJ
-Kk
-l l
-m m
-n n
-o
-o
-pp
-q q
-r\r
-scs
-u
-u
-vv
-w\w
-x x
-YyyY
-zZZz
-
-
-TEST_2:
-AA
-&
-C123456789987654321
-d
-~
-~
-Gg
-Hh
-iI
-jJ
-Kk
-l l
-m m
-n n
-o
-o
-pp
-q q
-r\r
-scs
-t t
-u
-u
-vv
-w\w
-XxxX
-yYYy
-
-
-TEST_3:
-a\a
-b\\b
-c c
-d\ d
-e\\ e
-f\rf
-j\nj
-k k
-l
-l
-
-
-TEST_4:
-a\a
-b\b
-c c
-d d
-e\ e
-f f
-j
-j
-k k
-l
-l
-
-
-TEST_5:
-A123456789987654321
-[['A123456789'], ['9'], ['8'], ['7'], ['6'], ['5'], ['4'], ['3'], ['2'], ['1']]
-
-
-TEST_6:
-a
-%
-c
-%
-
-
-TEST_7:
-A A
-B
-B
-['B
-']B
--abab
-c-cbcbc
-
-
-TEST_8:
-N,,NX
-N,,NY
-N,,NZ
-
-
-TEST_9:
-XXx
-
-
-TEST_10:
-a1a2a3a
-aaa
-1a2a3a
-a1a2a3a
-a1a2a3
-aaa
-aa2a3a
-1aaa
diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim
index f2dfdc701..cd598dc3c 100644
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -114,3 +114,183 @@ func Test_substitute_repeat()
call feedkeys("Qsc\<CR>y", 'tx')
bwipe!
endfunc
+
+" Test for *sub-replace-special* and *sub-replace-expression* on substitute().
+func Test_sub_replace_1()
+ " Run the tests with 'magic' on
+ set magic
+ set cpo&
+ call assert_equal('AA', substitute('A', 'A', '&&', ''))
+ call assert_equal('&', substitute('B', 'B', '\&', ''))
+ call assert_equal('C123456789987654321', substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', ''))
+ call assert_equal('d', substitute('D', 'D', 'd', ''))
+ call assert_equal('~', substitute('E', 'E', '~', ''))
+ call assert_equal('~', substitute('F', 'F', '\~', ''))
+ call assert_equal('Gg', substitute('G', 'G', '\ugg', ''))
+ call assert_equal('Hh', substitute('H', 'H', '\Uh\Eh', ''))
+ call assert_equal('iI', substitute('I', 'I', '\lII', ''))
+ call assert_equal('jJ', substitute('J', 'J', '\LJ\EJ', ''))
+ call assert_equal('Kk', substitute('K', 'K', '\Uk\ek', ''))
+ call assert_equal("l\<C-V>\<C-M>l",
+ \ substitute('lLl', 'L', "\<C-V>\<C-M>", ''))
+ call assert_equal("m\<C-M>m", substitute('mMm', 'M', '\r', ''))
+ call assert_equal("n\<C-V>\<C-M>n",
+ \ substitute('nNn', 'N', "\\\<C-V>\<C-M>", ''))
+ call assert_equal("o\no", substitute('oOo', 'O', '\n', ''))
+ call assert_equal("p\<C-H>p", substitute('pPp', 'P', '\b', ''))
+ call assert_equal("q\tq", substitute('qQq', 'Q', '\t', ''))
+ call assert_equal('r\r', substitute('rRr', 'R', '\\', ''))
+ call assert_equal('scs', substitute('sSs', 'S', '\c', ''))
+ call assert_equal("u\nu", substitute('uUu', 'U', "\n", ''))
+ call assert_equal("v\<C-H>v", substitute('vVv', 'V', "\b", ''))
+ call assert_equal("w\\w", substitute('wWw', 'W', "\\", ''))
+ call assert_equal("x\<C-M>x", substitute('xXx', 'X', "\r", ''))
+ call assert_equal("YyyY", substitute('Y', 'Y', '\L\uyYy\l\EY', ''))
+ call assert_equal("zZZz", substitute('Z', 'Z', '\U\lZzZ\u\Ez', ''))
+endfunc
+
+func Test_sub_replace_2()
+ " Run the tests with 'magic' off
+ set nomagic
+ set cpo&
+ call assert_equal('AA', substitute('A', 'A', '&&', ''))
+ call assert_equal('&', substitute('B', 'B', '\&', ''))
+ call assert_equal('C123456789987654321', substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', ''))
+ call assert_equal('d', substitute('D', 'D', 'd', ''))
+ call assert_equal('~', substitute('E', 'E', '~', ''))
+ call assert_equal('~', substitute('F', 'F', '\~', ''))
+ call assert_equal('Gg', substitute('G', 'G', '\ugg', ''))
+ call assert_equal('Hh', substitute('H', 'H', '\Uh\Eh', ''))
+ call assert_equal('iI', substitute('I', 'I', '\lII', ''))
+ call assert_equal('jJ', substitute('J', 'J', '\LJ\EJ', ''))
+ call assert_equal('Kk', substitute('K', 'K', '\Uk\ek', ''))
+ call assert_equal("l\<C-V>\<C-M>l",
+ \ substitute('lLl', 'L', "\<C-V>\<C-M>", ''))
+ call assert_equal("m\<C-M>m", substitute('mMm', 'M', '\r', ''))
+ call assert_equal("n\<C-V>\<C-M>n",
+ \ substitute('nNn', 'N', "\\\<C-V>\<C-M>", ''))
+ call assert_equal("o\no", substitute('oOo', 'O', '\n', ''))
+ call assert_equal("p\<C-H>p", substitute('pPp', 'P', '\b', ''))
+ call assert_equal("q\tq", substitute('qQq', 'Q', '\t', ''))
+ call assert_equal('r\r', substitute('rRr', 'R', '\\', ''))
+ call assert_equal('scs', substitute('sSs', 'S', '\c', ''))
+ call assert_equal("t\<C-M>t", substitute('tTt', 'T', "\r", ''))
+ call assert_equal("u\nu", substitute('uUu', 'U', "\n", ''))
+ call assert_equal("v\<C-H>v", substitute('vVv', 'V', "\b", ''))
+ call assert_equal('w\w', substitute('wWw', 'W', "\\", ''))
+ call assert_equal('XxxX', substitute('X', 'X', '\L\uxXx\l\EX', ''))
+ call assert_equal('yYYy', substitute('Y', 'Y', '\U\lYyY\u\Ey', ''))
+endfunc
+
+func Test_sub_replace_3()
+ set magic&
+ set cpo&
+ call assert_equal('a\a', substitute('aAa', 'A', '\="\\"', ''))
+ call assert_equal('b\\b', substitute('bBb', 'B', '\="\\\\"', ''))
+ call assert_equal("c\rc", substitute('cCc', 'C', "\\=\"\r\"", ''))
+ call assert_equal("d\\\rd", substitute('dDd', 'D', "\\=\"\\\\\r\"", ''))
+ call assert_equal("e\\\\\re", substitute('eEe', 'E', "\\=\"\\\\\\\\\r\"", ''))
+ call assert_equal('f\rf', substitute('fFf', 'F', '\="\\r"', ''))
+ call assert_equal('j\nj', substitute('jJj', 'J', '\="\\n"', ''))
+ call assert_equal("k\<C-M>k", substitute('kKk', 'K', '\="\r"', ''))
+ call assert_equal("l\nl", substitute('lLl', 'L', '\="\n"', ''))
+endfunc
+
+" Test for submatch() on substitute().
+func Test_sub_replace_4()
+ set magic&
+ set cpo&
+ call assert_equal('a\a', substitute('aAa', 'A',
+ \ '\=substitute(submatch(0), ".", "\\", "")', ''))
+ call assert_equal('b\b', substitute('bBb', 'B',
+ \ '\=substitute(submatch(0), ".", "\\\\", "")', ''))
+ call assert_equal("c\<C-V>\<C-M>c", substitute('cCc', 'C', '\=substitute(submatch(0), ".", "\<C-V>\<C-M>", "")', ''))
+ call assert_equal("d\<C-V>\<C-M>d", substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\\<C-V>\<C-M>", "")', ''))
+ call assert_equal("e\\\<C-V>\<C-M>e", substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\\<C-V>\<C-M>", "")', ''))
+ call assert_equal("f\<C-M>f", substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', ''))
+ call assert_equal("j\nj", substitute('jJj', 'J', '\=substitute(submatch(0), ".", "\\n", "")', ''))
+ call assert_equal("k\rk", substitute('kKk', 'K', '\=substitute(submatch(0), ".", "\r", "")', ''))
+ call assert_equal("l\nl", substitute('lLl', 'L', '\=substitute(submatch(0), ".", "\n", "")', ''))
+endfunc
+
+func Test_sub_replace_5()
+ set magic&
+ set cpo&
+ call assert_equal('A123456789987654321', substitute('A123456789',
+ \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
+ \ '\=submatch(0) . submatch(9) . submatch(8) . ' .
+ \ 'submatch(7) . submatch(6) . submatch(5) . ' .
+ \ 'submatch(4) . submatch(3) . submatch(2) . submatch(1)',
+ \ ''))
+ call assert_equal("[['A123456789'], ['9'], ['8'], ['7'], ['6'], " .
+ \ "['5'], ['4'], ['3'], ['2'], ['1']]",
+ \ substitute('A123456789',
+ \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
+ \ '\=string([submatch(0, 1), submatch(9, 1), ' .
+ \ 'submatch(8, 1), submatch(7, 1), submatch(6, 1), ' .
+ \ 'submatch(5, 1), submatch(4, 1), submatch(3, 1), ' .
+ \ 'submatch(2, 1), submatch(1, 1)])',
+ \ ''))
+endfunc
+
+func Test_sub_replace_6()
+ set magic&
+ set cpo+=/
+ call assert_equal('a', substitute('A', 'A', 'a', ''))
+ call assert_equal('%', substitute('B', 'B', '%', ''))
+ set cpo-=/
+ call assert_equal('c', substitute('C', 'C', 'c', ''))
+ call assert_equal('%', substitute('D', 'D', '%', ''))
+endfunc
+
+func Test_sub_replace_7()
+ set magic&
+ set cpo&
+ call assert_equal('AA', substitute('AA', 'A.', '\=submatch(0)', ''))
+ call assert_equal("B\nB", substitute("B\nB", 'B.', '\=submatch(0)', ''))
+ call assert_equal("['B\n']B", substitute("B\nB", 'B.', '\=string(submatch(0, 1))', ''))
+ call assert_equal('-abab', substitute('-bb', '\zeb', 'a', 'g'))
+ call assert_equal('c-cbcbc', substitute('-bb', '\ze', 'c', 'g'))
+endfunc
+
+" Test for *:s%* on :substitute.
+func Test_sub_replace_8()
+ new
+ set magic&
+ set cpo&
+ $put =',,X'
+ s/\(^\|,\)\ze\(,\|X\)/\1N/g
+ call assert_equal('N,,NX', getline("$"))
+ $put =',,Y'
+ let cmd = ':s/\(^\|,\)\ze\(,\|Y\)/\1N/gc'
+ call feedkeys(cmd . "\<CR>a", "xt")
+ call assert_equal('N,,NY', getline("$"))
+ :$put =',,Z'
+ let cmd = ':s/\(^\|,\)\ze\(,\|Z\)/\1N/gc'
+ call feedkeys(cmd . "\<CR>yy", "xt")
+ call assert_equal('N,,NZ', getline("$"))
+ enew! | close
+endfunc
+
+func Test_sub_replace_9()
+ new
+ set magic&
+ set cpo&
+ $put ='xxx'
+ call feedkeys(":s/x/X/gc\<CR>yyq", "xt")
+ call assert_equal('XXx', getline("$"))
+ enew! | close
+endfunc
+
+func Test_sub_replace_10()
+ set magic&
+ set cpo&
+ call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g'))
+ call assert_equal('aaa', substitute('123', '\zs.', 'a', 'g'))
+ call assert_equal('1a2a3a', substitute('123', '.\zs', 'a', 'g'))
+ call assert_equal('a1a2a3a', substitute('123', '\ze', 'a', 'g'))
+ call assert_equal('a1a2a3', substitute('123', '\ze.', 'a', 'g'))
+ call assert_equal('aaa', substitute('123', '.\ze', 'a', 'g'))
+ call assert_equal('aa2a3a', substitute('123', '1\|\ze', 'a', 'g'))
+ call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g'))
+endfunc
diff --git a/src/version.c b/src/version.c
index e0be7aa26..1b69d2b0c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1022,
+/**/
1021,
/**/
1020,