Mercurial > vim
annotate src/testdir/test_substitute.vim @ 16623:23a9d0c624fa v8.1.1314
patch 8.1.1314: MSVC makefile is not nicely indented
commit https://github.com/vim/vim/commit/c049b52b9013055bcb8abbd8545d35591bc84094
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 10 21:38:54 2019 +0200
patch 8.1.1314: MSVC makefile is not nicely indented
Problem: MSVC makefile is not nicely indented.
Solution: Addjust spaces in preprocessor directives. (Ken Takata)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 10 May 2019 21:45:06 +0200 |
parents | aebcd20a8a3f |
children | 6ea3f93b4428 |
rev | line source |
---|---|
10072
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for multi-line regexps with ":s". |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
3 func Test_multiline_subst() |
10072
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 enew! |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 call append(0, ["1 aa", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 \ "bb", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 \ "cc", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 \ "2 dd", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 \ "ee", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 \ "3 ef", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 \ "gh", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 \ "4 ij", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 \ "5 a8", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 \ "8b c9", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 \ "9d", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 \ "6 e7", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 \ "77f", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 \ "xxxxx"]) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 1 |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 " test if replacing a line break works with a back reference |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 /^1/,/^2/s/\n\(.\)/ \1/ |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " test if inserting a line break works with a back reference |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 /^3/,/^4/s/\(.\)$/\r\1/ |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 " test if replacing a line break with another line break works |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 /^5/,/^6/s/\(\_d\{3}\)/x\1x/ |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 call assert_equal('1 aa bb cc 2 dd ee', getline(1)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call assert_equal('3 e', getline(2)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 call assert_equal('f', getline(3)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 call assert_equal('g', getline(4)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 call assert_equal('h', getline(5)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call assert_equal('4 i', getline(6)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call assert_equal('j', getline(7)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 call assert_equal('5 ax8', getline(8)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call assert_equal('8xb cx9', getline(9)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 call assert_equal('9xd', getline(10)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_equal('6 ex7', getline(11)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 call assert_equal('7x7f', getline(12)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 call assert_equal('xxxxx', getline(13)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 enew! |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
41 endfunc |
10893
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
42 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
43 func Test_substitute_variants() |
10893
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
44 " Validate that all the 2-/3-letter variants which embed the flags into the |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
45 " command name actually work. |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
46 enew! |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
47 let ln = 'Testing string' |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
48 let variants = [ |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
49 \ { 'cmd': ':s/Test/test/c', 'exp': 'testing string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
50 \ { 'cmd': ':s/foo/bar/ce', 'exp': ln }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
51 \ { 'cmd': ':s/t/r/cg', 'exp': 'Tesring srring', 'prompt': 'a' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
52 \ { 'cmd': ':s/t/r/ci', 'exp': 'resting string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
53 \ { 'cmd': ':s/t/r/cI', 'exp': 'Tesring string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
54 \ { 'cmd': ':s/t/r/cn', 'exp': ln }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
55 \ { 'cmd': ':s/t/r/cp', 'exp': 'Tesring string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
56 \ { 'cmd': ':s/t/r/cl', 'exp': 'Tesring string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
57 \ { 'cmd': ':s/t/r/gc', 'exp': 'Tesring srring', 'prompt': 'a' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
58 \ { 'cmd': ':s/foo/bar/ge', 'exp': ln }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
59 \ { 'cmd': ':s/t/r/g', 'exp': 'Tesring srring' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
60 \ { 'cmd': ':s/t/r/gi', 'exp': 'resring srring' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
61 \ { 'cmd': ':s/t/r/gI', 'exp': 'Tesring srring' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
62 \ { 'cmd': ':s/t/r/gn', 'exp': ln }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
63 \ { 'cmd': ':s/t/r/gp', 'exp': 'Tesring srring' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
64 \ { 'cmd': ':s/t/r/gl', 'exp': 'Tesring srring' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
65 \ { 'cmd': ':s//r/gr', 'exp': 'Testr strr' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
66 \ { 'cmd': ':s/t/r/ic', 'exp': 'resting string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
67 \ { 'cmd': ':s/foo/bar/ie', 'exp': ln }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
68 \ { 'cmd': ':s/t/r/i', 'exp': 'resting string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
69 \ { 'cmd': ':s/t/r/iI', 'exp': 'Tesring string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
70 \ { 'cmd': ':s/t/r/in', 'exp': ln }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
71 \ { 'cmd': ':s/t/r/ip', 'exp': 'resting string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
72 \ { 'cmd': ':s//r/ir', 'exp': 'Testr string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
73 \ { 'cmd': ':s/t/r/Ic', 'exp': 'Tesring string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
74 \ { 'cmd': ':s/foo/bar/Ie', 'exp': ln }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
75 \ { 'cmd': ':s/t/r/Ig', 'exp': 'Tesring srring' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
76 \ { 'cmd': ':s/t/r/Ii', 'exp': 'resting string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
77 \ { 'cmd': ':s/t/r/I', 'exp': 'Tesring string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
78 \ { 'cmd': ':s/t/r/Ip', 'exp': 'Tesring string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
79 \ { 'cmd': ':s/t/r/Il', 'exp': 'Tesring string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
80 \ { 'cmd': ':s//r/Ir', 'exp': 'Testr string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
81 \ { 'cmd': ':s//r/rc', 'exp': 'Testr string', 'prompt': 'y' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
82 \ { 'cmd': ':s//r/rg', 'exp': 'Testr strr' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
83 \ { 'cmd': ':s//r/ri', 'exp': 'Testr string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
84 \ { 'cmd': ':s//r/rI', 'exp': 'Testr string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
85 \ { 'cmd': ':s//r/rn', 'exp': 'Testing string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
86 \ { 'cmd': ':s//r/rp', 'exp': 'Testr string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
87 \ { 'cmd': ':s//r/rl', 'exp': 'Testr string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
88 \ { 'cmd': ':s//r/r', 'exp': 'Testr string' }, |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
89 \] |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
90 |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
91 for var in variants |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
92 for run in [1, 2] |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
93 let cmd = var.cmd |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
94 if run == 2 && cmd =~ "/.*/.*/." |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
95 " Change :s/from/to/{flags} to :s{flags} |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
96 let cmd = substitute(cmd, '/.*/', '', '') |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
97 endif |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
98 call setline(1, [ln]) |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
99 let msg = printf('using "%s"', cmd) |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
100 let @/='ing' |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
101 let v:errmsg = '' |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
102 call feedkeys(cmd . "\<CR>" . get(var, 'prompt', ''), 'ntx') |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
103 " No error should exist (matters for testing e flag) |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
104 call assert_equal('', v:errmsg, msg) |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
105 call assert_equal(var.exp, getline('.'), msg) |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
106 endfor |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
107 endfor |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
108 endfunc |
10970
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
109 |
15760
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
110 " Test the l, p, # flags. |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
111 func Test_substitute_flags_lp() |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
112 new |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
113 call setline(1, "abc\tdef\<C-h>ghi") |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
114 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
115 let a = execute('s/a/a/p') |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
116 call assert_equal("\nabc def^Hghi", a) |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
117 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
118 let a = execute('s/a/a/l') |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
119 call assert_equal("\nabc^Idef^Hghi$", a) |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
120 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
121 let a = execute('s/a/a/#') |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
122 call assert_equal("\n 1 abc def^Hghi", a) |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
123 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
124 let a = execute('s/a/a/p#') |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
125 call assert_equal("\n 1 abc def^Hghi", a) |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
126 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
127 let a = execute('s/a/a/l#') |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
128 call assert_equal("\n 1 abc^Idef^Hghi$", a) |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
129 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
130 let a = execute('s/a/a/') |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
131 call assert_equal("", a) |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
132 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
133 bwipe! |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
134 endfunc |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
135 |
10970
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
136 func Test_substitute_repeat() |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
137 " This caused an invalid memory access. |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
138 split Xfile |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
139 s/^/x |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
140 call feedkeys("Qsc\<CR>y", 'tx') |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
141 bwipe! |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
142 endfunc |
12285
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
143 |
15768
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
144 " Test %s/\n// which is implemented as a special case to use a |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
145 " more efficient join rather than doing a regular substitution. |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
146 func Test_substitute_join() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
147 new |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
148 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
149 call setline(1, ["foo\tbar", "bar\<C-H>foo"]) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
150 let a = execute('%s/\n//') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
151 call assert_equal("", a) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
152 call assert_equal(["foo\tbarbar\<C-H>foo"], getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
153 call assert_equal('\n', histget("search", -1)) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
154 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
155 call setline(1, ["foo\tbar", "bar\<C-H>foo"]) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
156 let a = execute('%s/\n//g') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
157 call assert_equal("", a) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
158 call assert_equal(["foo\tbarbar\<C-H>foo"], getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
159 call assert_equal('\n', histget("search", -1)) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
160 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
161 call setline(1, ["foo\tbar", "bar\<C-H>foo"]) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
162 let a = execute('%s/\n//p') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
163 call assert_equal("\nfoo barbar^Hfoo", a) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
164 call assert_equal(["foo\tbarbar\<C-H>foo"], getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
165 call assert_equal('\n', histget("search", -1)) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
166 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
167 call setline(1, ["foo\tbar", "bar\<C-H>foo"]) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
168 let a = execute('%s/\n//l') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
169 call assert_equal("\nfoo^Ibarbar^Hfoo$", a) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
170 call assert_equal(["foo\tbarbar\<C-H>foo"], getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
171 call assert_equal('\n', histget("search", -1)) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
172 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
173 call setline(1, ["foo\tbar", "bar\<C-H>foo"]) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
174 let a = execute('%s/\n//#') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
175 call assert_equal("\n 1 foo barbar^Hfoo", a) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
176 call assert_equal(["foo\tbarbar\<C-H>foo"], getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
177 call assert_equal('\n', histget("search", -1)) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
178 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
179 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
180 endfunc |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
181 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
182 func Test_substitute_count() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
183 new |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
184 call setline(1, ['foo foo', 'foo foo', 'foo foo', 'foo foo', 'foo foo']) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
185 2 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
186 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
187 s/foo/bar/3 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
188 call assert_equal(['foo foo', 'bar foo', 'bar foo', 'bar foo', 'foo foo'], |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
189 \ getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
190 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
191 call assert_fails('s/foo/bar/0', 'E939:') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
192 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
193 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
194 endfunc |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
195 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
196 " Test substitute 'n' flag (report number of matches, do not substitute). |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
197 func Test_substitute_flag_n() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
198 new |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
199 let lines = ['foo foo', 'foo foo', 'foo foo', 'foo foo', 'foo foo'] |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
200 call setline(1, lines) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
201 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
202 call assert_equal("\n3 matches on 3 lines", execute('2,4s/foo/bar/n')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
203 call assert_equal("\n6 matches on 3 lines", execute('2,4s/foo/bar/gn')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
204 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
205 " c flag (confirm) should be ignored when using n flag. |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
206 call assert_equal("\n3 matches on 3 lines", execute('2,4s/foo/bar/nc')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
207 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
208 " No substitution should have been done. |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
209 call assert_equal(lines, getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
210 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
211 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
212 endfunc |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
213 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
214 func Test_substitute_errors() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
215 new |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
216 call setline(1, 'foobar') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
217 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
218 call assert_fails('s/FOO/bar/', 'E486:') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
219 call assert_fails('s/foo/bar/@', 'E488:') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
220 call assert_fails('s/\(/bar/', 'E476:') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
221 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
222 setl nomodifiable |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
223 call assert_fails('s/foo/bar/', 'E21:') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
224 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
225 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
226 endfunc |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
227 |
12285
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
228 " Test for *sub-replace-special* and *sub-replace-expression* on substitute(). |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
229 func Test_sub_replace_1() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
230 " Run the tests with 'magic' on |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
231 set magic |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
232 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
233 call assert_equal('AA', substitute('A', 'A', '&&', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
234 call assert_equal('&', substitute('B', 'B', '\&', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
235 call assert_equal('C123456789987654321', substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
236 call assert_equal('d', substitute('D', 'D', 'd', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
237 call assert_equal('~', substitute('E', 'E', '~', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
238 call assert_equal('~', substitute('F', 'F', '\~', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
239 call assert_equal('Gg', substitute('G', 'G', '\ugg', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
240 call assert_equal('Hh', substitute('H', 'H', '\Uh\Eh', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
241 call assert_equal('iI', substitute('I', 'I', '\lII', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
242 call assert_equal('jJ', substitute('J', 'J', '\LJ\EJ', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
243 call assert_equal('Kk', substitute('K', 'K', '\Uk\ek', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
244 call assert_equal("l\<C-V>\<C-M>l", |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
245 \ substitute('lLl', 'L', "\<C-V>\<C-M>", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
246 call assert_equal("m\<C-M>m", substitute('mMm', 'M', '\r', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
247 call assert_equal("n\<C-V>\<C-M>n", |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
248 \ substitute('nNn', 'N', "\\\<C-V>\<C-M>", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
249 call assert_equal("o\no", substitute('oOo', 'O', '\n', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
250 call assert_equal("p\<C-H>p", substitute('pPp', 'P', '\b', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
251 call assert_equal("q\tq", substitute('qQq', 'Q', '\t', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
252 call assert_equal('r\r', substitute('rRr', 'R', '\\', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
253 call assert_equal('scs', substitute('sSs', 'S', '\c', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
254 call assert_equal("u\nu", substitute('uUu', 'U', "\n", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
255 call assert_equal("v\<C-H>v", substitute('vVv', 'V', "\b", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
256 call assert_equal("w\\w", substitute('wWw', 'W', "\\", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
257 call assert_equal("x\<C-M>x", substitute('xXx', 'X', "\r", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
258 call assert_equal("YyyY", substitute('Y', 'Y', '\L\uyYy\l\EY', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
259 call assert_equal("zZZz", substitute('Z', 'Z', '\U\lZzZ\u\Ez', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
260 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
261 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
262 func Test_sub_replace_2() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
263 " Run the tests with 'magic' off |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
264 set nomagic |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
265 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
266 call assert_equal('AA', substitute('A', 'A', '&&', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
267 call assert_equal('&', substitute('B', 'B', '\&', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
268 call assert_equal('C123456789987654321', substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
269 call assert_equal('d', substitute('D', 'D', 'd', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
270 call assert_equal('~', substitute('E', 'E', '~', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
271 call assert_equal('~', substitute('F', 'F', '\~', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
272 call assert_equal('Gg', substitute('G', 'G', '\ugg', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
273 call assert_equal('Hh', substitute('H', 'H', '\Uh\Eh', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
274 call assert_equal('iI', substitute('I', 'I', '\lII', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
275 call assert_equal('jJ', substitute('J', 'J', '\LJ\EJ', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
276 call assert_equal('Kk', substitute('K', 'K', '\Uk\ek', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
277 call assert_equal("l\<C-V>\<C-M>l", |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
278 \ substitute('lLl', 'L', "\<C-V>\<C-M>", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
279 call assert_equal("m\<C-M>m", substitute('mMm', 'M', '\r', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
280 call assert_equal("n\<C-V>\<C-M>n", |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
281 \ substitute('nNn', 'N', "\\\<C-V>\<C-M>", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
282 call assert_equal("o\no", substitute('oOo', 'O', '\n', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
283 call assert_equal("p\<C-H>p", substitute('pPp', 'P', '\b', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
284 call assert_equal("q\tq", substitute('qQq', 'Q', '\t', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
285 call assert_equal('r\r', substitute('rRr', 'R', '\\', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
286 call assert_equal('scs', substitute('sSs', 'S', '\c', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
287 call assert_equal("t\<C-M>t", substitute('tTt', 'T', "\r", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
288 call assert_equal("u\nu", substitute('uUu', 'U', "\n", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
289 call assert_equal("v\<C-H>v", substitute('vVv', 'V', "\b", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
290 call assert_equal('w\w', substitute('wWw', 'W', "\\", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
291 call assert_equal('XxxX', substitute('X', 'X', '\L\uxXx\l\EX', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
292 call assert_equal('yYYy', substitute('Y', 'Y', '\U\lYyY\u\Ey', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
293 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
294 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
295 func Test_sub_replace_3() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
296 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
297 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
298 call assert_equal('a\a', substitute('aAa', 'A', '\="\\"', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
299 call assert_equal('b\\b', substitute('bBb', 'B', '\="\\\\"', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
300 call assert_equal("c\rc", substitute('cCc', 'C', "\\=\"\r\"", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
301 call assert_equal("d\\\rd", substitute('dDd', 'D', "\\=\"\\\\\r\"", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
302 call assert_equal("e\\\\\re", substitute('eEe', 'E', "\\=\"\\\\\\\\\r\"", '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
303 call assert_equal('f\rf', substitute('fFf', 'F', '\="\\r"', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
304 call assert_equal('j\nj', substitute('jJj', 'J', '\="\\n"', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
305 call assert_equal("k\<C-M>k", substitute('kKk', 'K', '\="\r"', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
306 call assert_equal("l\nl", substitute('lLl', 'L', '\="\n"', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
307 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
308 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
309 " Test for submatch() on substitute(). |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
310 func Test_sub_replace_4() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
311 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
312 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
313 call assert_equal('a\a', substitute('aAa', 'A', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
314 \ '\=substitute(submatch(0), ".", "\\", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
315 call assert_equal('b\b', substitute('bBb', 'B', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
316 \ '\=substitute(submatch(0), ".", "\\\\", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
317 call assert_equal("c\<C-V>\<C-M>c", substitute('cCc', 'C', '\=substitute(submatch(0), ".", "\<C-V>\<C-M>", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
318 call assert_equal("d\<C-V>\<C-M>d", substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\\<C-V>\<C-M>", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
319 call assert_equal("e\\\<C-V>\<C-M>e", substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\\<C-V>\<C-M>", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
320 call assert_equal("f\<C-M>f", substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
321 call assert_equal("j\nj", substitute('jJj', 'J', '\=substitute(submatch(0), ".", "\\n", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
322 call assert_equal("k\rk", substitute('kKk', 'K', '\=substitute(submatch(0), ".", "\r", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
323 call assert_equal("l\nl", substitute('lLl', 'L', '\=substitute(submatch(0), ".", "\n", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
324 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
325 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
326 func Test_sub_replace_5() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
327 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
328 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
329 call assert_equal('A123456789987654321', substitute('A123456789', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
330 \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
331 \ '\=submatch(0) . submatch(9) . submatch(8) . ' . |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
332 \ 'submatch(7) . submatch(6) . submatch(5) . ' . |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
333 \ 'submatch(4) . submatch(3) . submatch(2) . submatch(1)', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
334 \ '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
335 call assert_equal("[['A123456789'], ['9'], ['8'], ['7'], ['6'], " . |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
336 \ "['5'], ['4'], ['3'], ['2'], ['1']]", |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
337 \ substitute('A123456789', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
338 \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
339 \ '\=string([submatch(0, 1), submatch(9, 1), ' . |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
340 \ 'submatch(8, 1), submatch(7, 1), submatch(6, 1), ' . |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
341 \ 'submatch(5, 1), submatch(4, 1), submatch(3, 1), ' . |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
342 \ 'submatch(2, 1), submatch(1, 1)])', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
343 \ '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
344 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
345 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
346 func Test_sub_replace_6() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
347 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
348 set cpo+=/ |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
349 call assert_equal('a', substitute('A', 'A', 'a', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
350 call assert_equal('%', substitute('B', 'B', '%', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
351 set cpo-=/ |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
352 call assert_equal('c', substitute('C', 'C', 'c', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
353 call assert_equal('%', substitute('D', 'D', '%', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
354 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
355 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
356 func Test_sub_replace_7() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
357 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
358 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
359 call assert_equal('AA', substitute('AA', 'A.', '\=submatch(0)', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
360 call assert_equal("B\nB", substitute("B\nB", 'B.', '\=submatch(0)', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
361 call assert_equal("['B\n']B", substitute("B\nB", 'B.', '\=string(submatch(0, 1))', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
362 call assert_equal('-abab', substitute('-bb', '\zeb', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
363 call assert_equal('c-cbcbc', substitute('-bb', '\ze', 'c', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
364 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
365 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
366 " Test for *:s%* on :substitute. |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
367 func Test_sub_replace_8() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
368 new |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
369 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
370 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
371 $put =',,X' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
372 s/\(^\|,\)\ze\(,\|X\)/\1N/g |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
373 call assert_equal('N,,NX', getline("$")) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
374 $put =',,Y' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
375 let cmd = ':s/\(^\|,\)\ze\(,\|Y\)/\1N/gc' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
376 call feedkeys(cmd . "\<CR>a", "xt") |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
377 call assert_equal('N,,NY', getline("$")) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
378 :$put =',,Z' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
379 let cmd = ':s/\(^\|,\)\ze\(,\|Z\)/\1N/gc' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
380 call feedkeys(cmd . "\<CR>yy", "xt") |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
381 call assert_equal('N,,NZ', getline("$")) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
382 enew! | close |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
383 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
384 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
385 func Test_sub_replace_9() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
386 new |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
387 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
388 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
389 $put ='xxx' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
390 call feedkeys(":s/x/X/gc\<CR>yyq", "xt") |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
391 call assert_equal('XXx', getline("$")) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
392 enew! | close |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
393 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
394 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
395 func Test_sub_replace_10() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
396 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
397 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
398 call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
399 call assert_equal('aaa', substitute('123', '\zs.', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
400 call assert_equal('1a2a3a', substitute('123', '.\zs', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
401 call assert_equal('a1a2a3a', substitute('123', '\ze', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
402 call assert_equal('a1a2a3', substitute('123', '\ze.', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
403 call assert_equal('aaa', substitute('123', '.\ze', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
404 call assert_equal('aa2a3a', substitute('123', '1\|\ze', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
405 call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
406 endfunc |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
407 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
408 " Tests for *sub-replace-special* and *sub-replace-expression* on :substitute. |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
409 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
410 " Execute a list of :substitute command tests |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
411 func Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
412 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
413 for t in a:tests |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
414 let start = line('.') + 1 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
415 let end = start + len(t[2]) - 1 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
416 exe "normal o" . t[0] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
417 call cursor(start, 1) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
418 exe t[1] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
419 call assert_equal(t[2], getline(start, end), t[1]) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
420 endfor |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
421 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
422 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
423 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
424 func Test_sub_cmd_1() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
425 set magic |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
426 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
427 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
428 " List entry format: [input, cmd, output] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
429 let tests = [['A', 's/A/&&/', ['AA']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
430 \ ['B', 's/B/\&/', ['&']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
431 \ ['C123456789', 's/C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/', ['C123456789987654321']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
432 \ ['D', 's/D/d/', ['d']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
433 \ ['E', 's/E/~/', ['d']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
434 \ ['F', 's/F/\~/', ['~']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
435 \ ['G', 's/G/\ugg/', ['Gg']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
436 \ ['H', 's/H/\Uh\Eh/', ['Hh']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
437 \ ['I', 's/I/\lII/', ['iI']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
438 \ ['J', 's/J/\LJ\EJ/', ['jJ']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
439 \ ['K', 's/K/\Uk\ek/', ['Kk']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
440 \ ['lLl', "s/L/\<C-V>\<C-M>/", ["l\<C-V>", 'l']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
441 \ ['mMm', 's/M/\r/', ['m', 'm']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
442 \ ['nNn', "s/N/\\\<C-V>\<C-M>/", ["n\<C-V>", 'n']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
443 \ ['oOo', 's/O/\n/', ["o\no"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
444 \ ['pPp', 's/P/\b/', ["p\<C-H>p"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
445 \ ['qQq', 's/Q/\t/', ["q\tq"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
446 \ ['rRr', 's/R/\\/', ['r\r']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
447 \ ['sSs', 's/S/\c/', ['scs']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
448 \ ['tTt', "s/T/\<C-V>\<C-J>/", ["t\<C-V>\<C-J>t"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
449 \ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
450 \ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
451 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
452 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
453 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
454 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
455 func Test_sub_cmd_2() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
456 set nomagic |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
457 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
458 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
459 " List entry format: [input, cmd, output] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
460 let tests = [['A', 's/A/&&/', ['&&']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
461 \ ['B', 's/B/\&/', ['B']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
462 \ ['C123456789', 's/\mC\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/', ['C123456789987654321']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
463 \ ['D', 's/D/d/', ['d']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
464 \ ['E', 's/E/~/', ['~']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
465 \ ['F', 's/F/\~/', ['~']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
466 \ ['G', 's/G/\ugg/', ['Gg']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
467 \ ['H', 's/H/\Uh\Eh/', ['Hh']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
468 \ ['I', 's/I/\lII/', ['iI']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
469 \ ['J', 's/J/\LJ\EJ/', ['jJ']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
470 \ ['K', 's/K/\Uk\ek/', ['Kk']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
471 \ ['lLl', "s/L/\<C-V>\<C-M>/", ["l\<C-V>", 'l']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
472 \ ['mMm', 's/M/\r/', ['m', 'm']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
473 \ ['nNn', "s/N/\\\<C-V>\<C-M>/", ["n\<C-V>", 'n']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
474 \ ['oOo', 's/O/\n/', ["o\no"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
475 \ ['pPp', 's/P/\b/', ["p\<C-H>p"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
476 \ ['qQq', 's/Q/\t/', ["q\tq"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
477 \ ['rRr', 's/R/\\/', ['r\r']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
478 \ ['sSs', 's/S/\c/', ['scs']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
479 \ ['tTt', "s/T/\<C-V>\<C-J>/", ["t\<C-V>\<C-J>t"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
480 \ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
481 \ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
482 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
483 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
484 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
485 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
486 func Test_sub_cmd_3() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
487 set nomagic |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
488 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
489 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
490 " List entry format: [input, cmd, output] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
491 let tests = [['aAa', "s/A/\\='\\'/", ['a\a']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
492 \ ['bBb', "s/B/\\='\\\\'/", ['b\\b']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
493 \ ['cCc', "s/C/\\='\<C-V>\<C-M>'/", ["c\<C-V>", 'c']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
494 \ ['dDd', "s/D/\\='\\\<C-V>\<C-M>'/", ["d\\\<C-V>", 'd']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
495 \ ['eEe', "s/E/\\='\\\\\<C-V>\<C-M>'/", ["e\\\\\<C-V>", 'e']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
496 \ ['fFf', "s/F/\\='\r'/", ['f', 'f']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
497 \ ['gGg', "s/G/\\='\<C-V>\<C-J>'/", ["g\<C-V>", 'g']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
498 \ ['hHh', "s/H/\\='\\\<C-V>\<C-J>'/", ["h\\\<C-V>", 'h']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
499 \ ['iIi', "s/I/\\='\\\\\<C-V>\<C-J>'/", ["i\\\\\<C-V>", 'i']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
500 \ ['jJj', "s/J/\\='\n'/", ['j', 'j']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
501 \ ['kKk', 's/K/\="\r"/', ['k', 'k']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
502 \ ['lLl', 's/L/\="\n"/', ['l', 'l']] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
503 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
504 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
505 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
506 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
507 " Test for submatch() on :substitue. |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
508 func Test_sub_cmd_4() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
509 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
510 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
511 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
512 " List entry format: [input, cmd, output] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
513 let tests = [ ['aAa', "s/A/\\=substitute(submatch(0), '.', '\\', '')/", |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
514 \ ['a\a']], |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
515 \ ['bBb', "s/B/\\=substitute(submatch(0), '.', '\\', '')/", |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
516 \ ['b\b']], |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
517 \ ['cCc', "s/C/\\=substitute(submatch(0), '.', '\<C-V>\<C-M>', '')/", |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
518 \ ["c\<C-V>", 'c']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
519 \ ['dDd', "s/D/\\=substitute(submatch(0), '.', '\\\<C-V>\<C-M>', '')/", |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
520 \ ["d\<C-V>", 'd']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
521 \ ['eEe', "s/E/\\=substitute(submatch(0), '.', '\\\\\<C-V>\<C-M>', '')/", |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
522 \ ["e\\\<C-V>", 'e']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
523 \ ['fFf', "s/F/\\=substitute(submatch(0), '.', '\\r', '')/", |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
524 \ ['f', 'f']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
525 \ ['gGg', 's/G/\=substitute(submatch(0), ".", "\<C-V>\<C-J>", "")/', |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
526 \ ["g\<C-V>", 'g']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
527 \ ['hHh', 's/H/\=substitute(submatch(0), ".", "\\\<C-V>\<C-J>", "")/', |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
528 \ ["h\<C-V>", 'h']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
529 \ ['iIi', 's/I/\=substitute(submatch(0), ".", "\\\\\<C-V>\<C-J>", "")/', |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
530 \ ["i\\\<C-V>", 'i']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
531 \ ['jJj', "s/J/\\=substitute(submatch(0), '.', '\\n', '')/", |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
532 \ ['j', 'j']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
533 \ ['kKk', "s/K/\\=substitute(submatch(0), '.', '\\r', '')/", |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
534 \ ['k', 'k']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
535 \ ['lLl', "s/L/\\=substitute(submatch(0), '.', '\\n', '')/", |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
536 \ ['l', 'l']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
537 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
538 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
539 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
540 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
541 func Test_sub_cmd_5() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
542 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
543 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
544 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
545 " List entry format: [input, cmd, output] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
546 let tests = [ ['A123456789', 's/A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)/', ['A123456789987654321']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
547 \ ['B123456789', 's/B\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=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)])/', ["[['B123456789'], ['9'], ['8'], ['7'], ['6'], ['5'], ['4'], ['3'], ['2'], ['1']]"]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
548 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
549 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
550 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
551 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
552 " Test for *:s%* on :substitute. |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
553 func Test_sub_cmd_6() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
554 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
555 set cpo+=/ |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
556 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
557 " List entry format: [input, cmd, output] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
558 let tests = [ ['A', 's/A/a/', ['a']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
559 \ ['B', 's/B/%/', ['a']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
560 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
561 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
562 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
563 set cpo-=/ |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
564 let tests = [ ['C', 's/C/c/', ['c']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
565 \ ['D', 's/D/%/', ['%']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
566 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
567 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
568 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
569 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
570 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
571 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
572 " Test for :s replacing \n with line break. |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
573 func Test_sub_cmd_7() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
574 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
575 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
576 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
577 " List entry format: [input, cmd, output] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
578 let tests = [ ["A\<C-V>\<C-M>A", 's/A./\=submatch(0)/', ['A', 'A']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
579 \ ["B\<C-V>\<C-J>B", 's/B./\=submatch(0)/', ['B', 'B']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
580 \ ["C\<C-V>\<C-J>C", 's/C./\=strtrans(string(submatch(0, 1)))/', [strtrans("['C\<C-J>']C")]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
581 \ ["D\<C-V>\<C-J>\nD", 's/D.\nD/\=strtrans(string(submatch(0, 1)))/', [strtrans("['D\<C-J>', 'D']")]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
582 \ ["E\<C-V>\<C-J>\n\<C-V>\<C-J>\n\<C-V>\<C-J>\n\<C-V>\<C-J>\n\<C-V>\<C-J>E", 's/E\_.\{-}E/\=strtrans(string(submatch(0, 1)))/', [strtrans("['E\<C-J>', '\<C-J>', '\<C-J>', '\<C-J>', '\<C-J>E']")]], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
583 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
584 call Run_SubCmd_Tests(tests) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
585 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
586 exe "normal oQ\nQ\<Esc>k" |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
587 call assert_fails('s/Q[^\n]Q/\=submatch(0)."foobar"/', 'E486') |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
588 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
589 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
590 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
591 func TitleString() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
592 let check = 'foo' =~ 'bar' |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
593 return "" |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
594 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
595 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
596 func Test_sub_cmd_8() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
597 set titlestring=%{TitleString()} |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
598 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
599 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
600 call append(0, ['', 'test_one', 'test_two']) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
601 call cursor(1,1) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
602 /^test_one/s/.*/\="foo\nbar"/ |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
603 call assert_equal('foo', getline(2)) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
604 call assert_equal('bar', getline(3)) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
605 call feedkeys(':/^test_two/s/.*/\="foo\nbar"/c', "t") |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
606 call feedkeys("\<CR>y", "xt") |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
607 call assert_equal('foo', getline(4)) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
608 call assert_equal('bar', getline(5)) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
609 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
610 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
611 set titlestring& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
612 endfunc |
16113
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
613 |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
614 func Test_nocatch_sub_failure_handling() |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
615 " normal error results in all replacements |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
616 func! Foo() |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
617 foobar |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
618 endfunc |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
619 new |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
620 call setline(1, ['1 aaa', '2 aaa', '3 aaa']) |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
621 %s/aaa/\=Foo()/g |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
622 call assert_equal(['1 0', '2 0', '3 0'], getline(1, 3)) |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
623 |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
624 " Trow without try-catch causes abort after the first line. |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
625 " We cannot test this, since it would stop executing the test script. |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
626 |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
627 " try/catch does not result in any changes |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
628 func! Foo() |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
629 throw 'error' |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
630 endfunc |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
631 call setline(1, ['1 aaa', '2 aaa', '3 aaa']) |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
632 let error_caught = 0 |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
633 try |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
634 %s/aaa/\=Foo()/g |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
635 catch |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
636 let error_caught = 1 |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
637 endtry |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
638 call assert_equal(1, error_caught) |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
639 call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3)) |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
640 |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
641 bwipe! |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
642 endfunc |
16419
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
643 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
644 " Test ":s/pat/sub/" with different ~s in sub. |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
645 func Test_replace_with_tilde() |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
646 new |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
647 " Set the last replace string to empty |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
648 s/^$// |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
649 call append(0, ['- Bug in "vPPPP" on this text:']) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
650 normal gg |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
651 s/u/~u~/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
652 call assert_equal('- Bug in "vPPPP" on this text:', getline(1)) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
653 s/i/~u~/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
654 call assert_equal('- Bug uuun "vPPPP" on this text:', getline(1)) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
655 s/o/~~~/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
656 call assert_equal('- Bug uuun "vPPPP" uuuuuuuuun this text:', getline(1)) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
657 close! |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
658 endfunc |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
659 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
660 func Test_replace_keeppatterns() |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
661 new |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
662 a |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
663 foobar |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
664 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
665 substitute foo asdf |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
666 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
667 one two |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
668 . |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
669 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
670 normal gg |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
671 /^substitute |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
672 s/foo/bar/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
673 call assert_equal('foo', @/) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
674 call assert_equal('substitute bar asdf', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
675 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
676 /^substitute |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
677 keeppatterns s/asdf/xyz/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
678 call assert_equal('^substitute', @/) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
679 call assert_equal('substitute bar xyz', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
680 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
681 exe "normal /bar /e\<CR>" |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
682 call assert_equal(15, col('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
683 normal - |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
684 keeppatterns /xyz |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
685 call assert_equal('bar ', @/) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
686 call assert_equal('substitute bar xyz', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
687 exe "normal 0dn" |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
688 call assert_equal('xyz', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
689 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
690 close! |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
691 endfunc |