annotate src/testdir/test_substitute.vim @ 15760:aa80c63f34bb v8.1.0887

patch 8.1.0887: the 'l' flag in :subsitute is sticky commit https://github.com/vim/vim/commit/9474716d39764ac5642e55b5548580cf53bd9bed Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 10 21:55:26 2019 +0100 patch 8.1.0887: the 'l' flag in :subsitute is sticky Problem: The 'l' flag in :subsitute is sticky. Solution: Reset the flag. (Dominique Pelle, closes https://github.com/vim/vim/issues/3925)
author Bram Moolenaar <Bram@vim.org>
date Sun, 10 Feb 2019 22:00:08 +0100
parents 63b02fcf1361
children ed264e126766
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
144 " 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
145 func Test_sub_replace_1()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
146 " 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
147 set magic
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
148 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 \ 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
162 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
163 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
164 \ 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
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
177
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
178 func Test_sub_replace_2()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
179 " 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
180 set nomagic
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
181 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 \ 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
195 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
196 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
197 \ 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
210
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
211 func Test_sub_replace_3()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
212 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
213 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
224
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
225 " Test for submatch() on substitute().
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
226 func Test_sub_replace_4()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
227 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
228 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
229 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
230 \ '\=substitute(submatch(0), ".", "\\", "")', ''))
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
231 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
232 \ '\=substitute(submatch(0), ".", "\\\\", "")', ''))
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
241
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
242 func Test_sub_replace_5()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
243 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
244 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
245 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
246 \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
247 \ '\=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
248 \ '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
249 \ '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
250 \ ''))
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
251 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
252 \ "['5'], ['4'], ['3'], ['2'], ['1']]",
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
253 \ substitute('A123456789',
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
254 \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
255 \ '\=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
256 \ '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
257 \ '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
258 \ '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
259 \ ''))
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_6()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
263 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
264 set cpo+=/
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
265 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
266 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
267 set cpo-=/
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
268 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
269 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
270 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
271
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
272 func Test_sub_replace_7()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
273 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
274 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
275 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
276 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
277 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
278 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
279 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
280 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
281
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
282 " Test for *:s%* on :substitute.
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
283 func Test_sub_replace_8()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
284 new
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
285 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
286 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
287 $put =',,X'
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
288 s/\(^\|,\)\ze\(,\|X\)/\1N/g
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
289 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
290 $put =',,Y'
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
291 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
292 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
293 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
294 :$put =',,Z'
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
295 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
296 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
297 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
298 enew! | close
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
299 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
300
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
301 func Test_sub_replace_9()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
302 new
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
303 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
304 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
305 $put ='xxx'
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
306 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
307 call assert_equal('XXx', getline("$"))
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
308 enew! | close
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
309 endfunc
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
310
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
311 func Test_sub_replace_10()
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
312 set magic&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
313 set cpo&
4963348ed734 patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents: 10970
diff changeset
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 endfunc
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
323
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
324 " 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
325
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
326 " 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
327 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
328 enew!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
329 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
330 let start = line('.') + 1
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
331 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
332 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
333 call cursor(start, 1)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
334 exe t[1]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
335 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
336 endfor
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
337 enew!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
338 endfunc
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
339
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
340 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
341 set magic
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
342 set cpo&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
343
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
344 " 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
345 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
346 \ ['B', 's/B/\&/', ['&']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
347 \ ['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
348 \ ['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
349 \ ['E', 's/E/~/', ['d']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
350 \ ['F', 's/F/\~/', ['~']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
351 \ ['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
352 \ ['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
353 \ ['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
354 \ ['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
355 \ ['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
356 \ ['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
357 \ ['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
358 \ ['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
359 \ ['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
360 \ ['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
361 \ ['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
362 \ ['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
363 \ ['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
364 \ ['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
365 \ ['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
366 \ ['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
367 \ ]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
368 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
369 endfunc
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
370
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
371 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
372 set nomagic
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
373 set cpo&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
374
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
375 " 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
376 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
377 \ ['B', 's/B/\&/', ['B']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
378 \ ['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
379 \ ['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
380 \ ['E', 's/E/~/', ['~']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
381 \ ['F', 's/F/\~/', ['~']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
382 \ ['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
383 \ ['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
384 \ ['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
385 \ ['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
386 \ ['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
387 \ ['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
388 \ ['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
389 \ ['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
390 \ ['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
391 \ ['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
392 \ ['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
393 \ ['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
394 \ ['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
395 \ ['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
396 \ ['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
397 \ ['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
398 \ ]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
399 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
400 endfunc
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
401
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
402 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
403 set nomagic
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
404 set cpo&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
405
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
406 " 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
407 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
408 \ ['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
409 \ ['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
410 \ ['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
411 \ ['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
412 \ ['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
413 \ ['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
414 \ ['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
415 \ ['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
416 \ ['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
417 \ ['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
418 \ ['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
419 \ ]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
420 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
421 endfunc
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
422
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
423 " 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
424 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
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 = [ ['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
430 \ ['a\a']],
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
431 \ ['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
432 \ ['b\b']],
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
433 \ ['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
434 \ ["c\<C-V>", 'c']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
435 \ ['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
436 \ ["d\<C-V>", 'd']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
437 \ ['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
438 \ ["e\\\<C-V>", 'e']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
439 \ ['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
440 \ ['f', 'f']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
441 \ ['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
442 \ ["g\<C-V>", 'g']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
443 \ ['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
444 \ ["h\<C-V>", 'h']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
445 \ ['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
446 \ ["i\\\<C-V>", 'i']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
447 \ ['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
448 \ ['j', 'j']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
449 \ ['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
450 \ ['k', 'k']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
451 \ ['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
452 \ ['l', 'l']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
453 \ ]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
454 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
455 endfunc
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
456
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
457 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
458 set magic&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
459 set cpo&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
460
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
461 " 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
462 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
463 \ ['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
464 \ ]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
465 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
466 endfunc
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
467
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
468 " 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
469 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
470 set magic&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
471 set cpo+=/
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
472
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
473 " 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
474 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
475 \ ['B', 's/B/%/', ['a']],
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
476 \ ]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
477 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
478
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
479 set cpo-=/
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
480 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
481 \ ['D', 's/D/%/', ['%']],
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
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
485 set cpo&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
486 endfunc
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
487
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
488 " 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
489 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
490 set magic&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
491 set cpo&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
492
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
493 " 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
494 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
495 \ ["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
496 \ ["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
497 \ ["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
498 \ ["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
499 \ ]
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
500 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
501
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
502 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
503 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
504 enew!
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 func TitleString()
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
508 let check = 'foo' =~ 'bar'
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
509 return ""
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
510 endfunc
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 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
513 set titlestring=%{TitleString()}
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
514
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
515 enew!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
516 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
517 call cursor(1,1)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
518 /^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
519 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
520 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
521 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
522 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
523 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
524 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
525
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
526 enew!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
527 set titlestring&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12285
diff changeset
528 endfunc