Mercurial > vim
annotate src/testdir/test_substitute.vim @ 29115:f371242b6a23 v8.2.5078
patch 8.2.5078: substitute test has a one second delay
Commit: https://github.com/vim/vim/commit/3269efdf014dd3b6e60e330950d40a7cc5d13d3a
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun Jun 12 11:13:05 2022 +0100
patch 8.2.5078: substitute test has a one second delay
Problem: Substitute test has a one second delay.
Solution: Use ":silent!". Add another test case. (closes https://github.com/vim/vim/issues/10558)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 12 Jun 2022 12:15:03 +0200 |
parents | 55ce8628cd9b |
children | 9e0b45df95b0 |
rev | line source |
---|---|
28205
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1 " Tests for the substitute (:s) command |
10072
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
3 source shared.vim |
24820
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
4 source check.vim |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
5 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
6 func Test_multiline_subst() |
10072
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 enew! |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call append(0, ["1 aa", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 \ "bb", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 \ "cc", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 \ "2 dd", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 \ "ee", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 \ "3 ef", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 \ "gh", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 \ "4 ij", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 \ "5 a8", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 \ "8b c9", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 \ "9d", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 \ "6 e7", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 \ "77f", |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 \ "xxxxx"]) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 1 |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 " 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
|
25 /^1/,/^2/s/\n\(.\)/ \1/ |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " 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
|
27 /^3/,/^4/s/\(.\)$/\r\1/ |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 " 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
|
29 /^5/,/^6/s/\(\_d\{3}\)/x\1x/ |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 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
|
31 call assert_equal('3 e', getline(2)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call assert_equal('f', getline(3)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call assert_equal('g', getline(4)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 call assert_equal('h', getline(5)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call assert_equal('4 i', getline(6)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 call assert_equal('j', getline(7)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_equal('5 ax8', getline(8)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 call assert_equal('8xb cx9', getline(9)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 call assert_equal('9xd', getline(10)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 call assert_equal('6 ex7', getline(11)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call assert_equal('7x7f', getline(12)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 call assert_equal('xxxxx', getline(13)) |
c104f09ae2f4
commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 enew! |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
44 endfunc |
10893
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
45 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
46 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
|
47 " 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
|
48 " command name actually work. |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
49 enew! |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
50 let ln = 'Testing string' |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
51 let variants = [ |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
52 \ { '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
|
53 \ { '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
|
54 \ { '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
|
55 \ { '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
|
56 \ { 'cmd': ':s/t/r/cI', 'exp': 'Tesring string', 'prompt': 'y' }, |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
57 \ { 'cmd': ':s/t/r/c', 'exp': 'Testing string', 'prompt': 'n' }, |
10893
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
58 \ { '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
|
59 \ { '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
|
60 \ { '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
|
61 \ { 'cmd': ':s/t/r/gc', 'exp': 'Tesring srring', 'prompt': 'a' }, |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
62 \ { 'cmd': ':s/i/I/gc', 'exp': 'TestIng string', 'prompt': 'l' }, |
10893
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
63 \ { '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
|
64 \ { '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
|
65 \ { '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
|
66 \ { '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
|
67 \ { '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
|
68 \ { '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
|
69 \ { '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
|
70 \ { '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
|
71 \ { '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
|
72 \ { '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
|
73 \ { '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
|
74 \ { '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
|
75 \ { '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
|
76 \ { '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
|
77 \ { '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
|
78 \ { '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
|
79 \ { '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
|
80 \ { '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
|
81 \ { '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
|
82 \ { '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
|
83 \ { '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
|
84 \ { '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
|
85 \ { '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
|
86 \ { '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
|
87 \ { '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
|
88 \ { '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
|
89 \ { '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
|
90 \ { '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
|
91 \ { '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
|
92 \ { '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
|
93 \ { 'cmd': ':s//r/r', 'exp': 'Testr string' }, |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
94 \ { 'cmd': ':s/i/I/gc', 'exp': 'Testing string', 'prompt': 'q' }, |
10893
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
95 \] |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
96 |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
97 for var in variants |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
98 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
|
99 let cmd = var.cmd |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
100 if run == 2 && cmd =~ "/.*/.*/." |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
101 " 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
|
102 let cmd = substitute(cmd, '/.*/', '', '') |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
103 endif |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
104 call setline(1, [ln]) |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
105 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
|
106 let @/='ing' |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
107 let v:errmsg = '' |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
108 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
|
109 " 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
|
110 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
|
111 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
|
112 endfor |
fbed07965b6a
patch 8.0.0336: flags of :substitute not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
10072
diff
changeset
|
113 endfor |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
12686
diff
changeset
|
114 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
|
115 |
15760
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
116 " 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
|
117 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
|
118 new |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
119 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
|
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/p') |
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("\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
|
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/l') |
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("\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
|
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/#') |
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 def^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/p#') |
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("\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
|
132 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
133 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
|
134 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
|
135 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
136 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
|
137 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
|
138 |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
139 bwipe! |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
140 endfunc |
aa80c63f34bb
patch 8.1.0887: the 'l' flag in :subsitute is sticky
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
141 |
10970
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
142 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
|
143 " 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
|
144 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
|
145 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
|
146 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
|
147 bwipe! |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10893
diff
changeset
|
148 endfunc |
12285
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
149 |
15768
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
150 " 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
|
151 " 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
|
152 func Test_substitute_join() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
153 new |
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//') |
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//g') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
163 call assert_equal("", 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//p') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
169 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
|
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//l') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
175 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
|
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 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
|
180 let a = execute('%s/\n//#') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
185 call setline(1, ['foo', 'bar', 'baz', 'qux']) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
186 call execute('1,2s/\n//') |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
187 call assert_equal(['foobarbaz', 'qux'], getline(1, '$')) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
188 |
15768
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
189 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
190 endfunc |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
191 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
192 func Test_substitute_count() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
193 new |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
194 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
|
195 2 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
196 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
197 s/foo/bar/3 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
198 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
|
199 \ getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
200 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
201 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
|
202 |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
203 call setline(1, ['foo foo', 'foo foo', 'foo foo', 'foo foo', 'foo foo']) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
204 2,4s/foo/bar/ 10 |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
205 call assert_equal(['foo foo', 'foo foo', 'foo foo', 'bar foo', 'bar foo'], |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
206 \ getline(1, '$')) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
207 |
15768
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
208 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
209 endfunc |
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 " 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
|
212 func Test_substitute_flag_n() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
213 new |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
214 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
|
215 call setline(1, lines) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
216 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
217 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
|
218 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
|
219 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
220 " 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
|
221 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
|
222 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
223 " No substitution should have been done. |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
224 call assert_equal(lines, getline(1, '$')) |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
225 |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
226 %delete _ |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
227 call setline(1, ['A', 'Bar', 'Baz']) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
228 call assert_equal("\n1 match on 1 line", execute('s/\nB\@=//gn')) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
229 |
15768
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
230 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
231 endfunc |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
232 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
233 func Test_substitute_errors() |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
234 new |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
235 call setline(1, 'foobar') |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
236 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
237 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
|
238 call assert_fails('s/foo/bar/@', 'E488:') |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
19969
diff
changeset
|
239 call assert_fails('s/\(/bar/', 'E54:') |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18576
diff
changeset
|
240 call assert_fails('s afooabara', 'E146:') |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18576
diff
changeset
|
241 call assert_fails('s\\a', 'E10:') |
15768
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
242 |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
243 setl nomodifiable |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
244 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
|
245 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
246 call assert_fails("let s=substitute([], 'a', 'A', 'g')", 'E730:') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
247 call assert_fails("let s=substitute('abcda', [], 'A', 'g')", 'E730:') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
248 call assert_fails("let s=substitute('abcda', 'a', [], 'g')", 'E730:') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
249 call assert_fails("let s=substitute('abcda', 'a', 'A', [])", 'E730:') |
22375
595ea7f099cd
patch 8.2.1736: failure to compile a pattern not tested much
Bram Moolenaar <Bram@vim.org>
parents:
22143
diff
changeset
|
250 call assert_fails("let s=substitute('abc', '\\%(', 'A', 'g')", 'E53:') |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
251 |
15768
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
252 bwipe! |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
253 endfunc |
ed264e126766
patch 8.1.0891: substitute command inssuficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15760
diff
changeset
|
254 |
12285
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
255 " 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
|
256 func Test_sub_replace_1() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
257 " 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
|
258 set magic |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
259 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
260 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 \ 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
|
273 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
|
274 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
|
275 \ 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
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 call assert_equal("zZZz", substitute('Z', 'Z', '\U\lZzZ\u\Ez', '')) |
19969
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
287 " \v or \V after $ |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
288 call assert_equal('abxx', substitute('abcd', 'xy$\v|cd$', 'xx', '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
289 call assert_equal('abxx', substitute('abcd', 'xy$\V\|cd\$', 'xx', '')) |
12285
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
290 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
291 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
292 func Test_sub_replace_2() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
293 " 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
|
294 set nomagic |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
295 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 \ 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
|
309 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
|
310 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
|
311 \ 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
324 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
325 func Test_sub_replace_3() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
326 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
327 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
338 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
339 " Test for submatch() on substitute(). |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
340 func Test_sub_replace_4() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
341 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
342 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
343 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
|
344 \ '\=substitute(submatch(0), ".", "\\", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
345 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
|
346 \ '\=substitute(submatch(0), ".", "\\\\", "")', '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
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_5() |
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('A123456789987654321', substitute('A123456789', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
360 \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
361 \ '\=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
|
362 \ '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
|
363 \ '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
|
364 \ '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
365 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
|
366 \ "['5'], ['4'], ['3'], ['2'], ['1']]", |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
367 \ substitute('A123456789', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
368 \ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
369 \ '\=string([submatch(0, 1), submatch(9, 1), ' . |
18017
988e5a868b60
patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17910
diff
changeset
|
370 \ 'submatch(8, 1), 7->submatch(1), submatch(6, 1), ' . |
12285
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
371 \ '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
|
372 \ '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
|
373 \ '')) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
374 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
375 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
376 func Test_sub_replace_6() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
377 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
378 set cpo+=/ |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
379 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
|
380 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
|
381 set cpo-=/ |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
382 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
|
383 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
|
384 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
385 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
386 func Test_sub_replace_7() |
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 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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
395 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
396 " Test for *:s%* on :substitute. |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
397 func Test_sub_replace_8() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
398 new |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
399 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
400 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
401 $put =',,X' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
402 s/\(^\|,\)\ze\(,\|X\)/\1N/g |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
403 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
|
404 $put =',,Y' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
405 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
|
406 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
|
407 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
|
408 :$put =',,Z' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
409 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
|
410 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
|
411 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
|
412 enew! | close |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
413 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
414 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
415 func Test_sub_replace_9() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
416 new |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
417 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
418 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
419 $put ='xxx' |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
420 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
|
421 call assert_equal('XXx', getline("$")) |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
422 enew! | close |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
423 endfunc |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
424 |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
425 func Test_sub_replace_10() |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
426 set magic& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
427 set cpo& |
4963348ed734
patch 8.0.1022: test 80 is old style
Christian Brabandt <cb@256bit.org>
parents:
10970
diff
changeset
|
428 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 endfunc |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
437 |
18572
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
438 func SubReplacer(text, submatches) |
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
439 return a:text .. a:submatches[0] .. a:text |
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
440 endfunc |
18576
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
441 func SubReplacer20(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, submatches) |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
442 return a:t3 .. a:submatches[0] .. a:t11 |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
443 endfunc |
18572
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
444 |
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
445 func Test_substitute_partial() |
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
446 call assert_equal('1foo2foo3', substitute('123', '2', function('SubReplacer', ['foo']), 'g')) |
18576
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
447 |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
448 " 19 arguments plus one is just OK |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
449 let Replacer = function('SubReplacer20', repeat(['foo'], 19)) |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
450 call assert_equal('1foo2foo3', substitute('123', '2', Replacer, 'g')) |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
451 |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
452 " 20 arguments plus one is too many |
e9675870c480
patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents:
18572
diff
changeset
|
453 let Replacer = function('SubReplacer20', repeat(['foo'], 20)) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
454 call assert_fails("call substitute('123', '2', Replacer, 'g')", 'E118:') |
18572
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
455 endfunc |
23fef64352a1
patch 8.1.2280: crash when passing partial to substitute()
Bram Moolenaar <Bram@vim.org>
parents:
18483
diff
changeset
|
456 |
24820
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
457 func Test_substitute_float() |
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
458 CheckFeature float |
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
459 |
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
460 call assert_equal('number 1.23', substitute('number ', '$', { -> 1.23 }, '')) |
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
461 vim9 assert_equal('number 1.23', substitute('number ', '$', () => 1.23, '')) |
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
462 endfunc |
b1093c1ac109
patch 8.2.2948: substitute() accepts a number but not a float expression
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
463 |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
464 " 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
|
465 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
466 " 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
|
467 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
|
468 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
469 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
|
470 let start = line('.') + 1 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
471 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
|
472 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
|
473 call cursor(start, 1) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
474 exe t[1] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
475 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
|
476 endfor |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
477 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
478 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
479 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
480 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
|
481 set magic |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
482 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
483 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
484 " 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
|
485 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
|
486 \ ['B', 's/B/\&/', ['&']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
487 \ ['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
|
488 \ ['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
|
489 \ ['E', 's/E/~/', ['d']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
490 \ ['F', 's/F/\~/', ['~']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
491 \ ['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
|
492 \ ['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
|
493 \ ['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
|
494 \ ['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
|
495 \ ['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
|
496 \ ['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
|
497 \ ['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
|
498 \ ['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
|
499 \ ['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
|
500 \ ['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
|
501 \ ['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
|
502 \ ['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
|
503 \ ['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
|
504 \ ['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
|
505 \ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']], |
29115
f371242b6a23
patch 8.2.5078: substitute test has a one second delay
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
506 \ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']], |
f371242b6a23
patch 8.2.5078: substitute test has a one second delay
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
507 \ ['\', 's/\\/\\\\/', ['\\']] |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
508 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
509 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
|
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_2() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
513 set nomagic |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
514 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
515 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
516 " 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
|
517 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
|
518 \ ['B', 's/B/\&/', ['B']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
519 \ ['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
|
520 \ ['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
|
521 \ ['E', 's/E/~/', ['~']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
522 \ ['F', 's/F/\~/', ['~']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
523 \ ['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
|
524 \ ['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
|
525 \ ['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
|
526 \ ['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
|
527 \ ['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
|
528 \ ['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
|
529 \ ['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
|
530 \ ['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
|
531 \ ['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
|
532 \ ['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
|
533 \ ['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
|
534 \ ['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
|
535 \ ['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
|
536 \ ['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
|
537 \ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']], |
29115
f371242b6a23
patch 8.2.5078: substitute test has a one second delay
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
538 \ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']], |
f371242b6a23
patch 8.2.5078: substitute test has a one second delay
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
539 \ ['\', 's/\\/\\\\/', ['\\']] |
12686
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 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
|
542 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
543 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
544 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
|
545 set nomagic |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
546 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
547 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
548 " 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
|
549 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
|
550 \ ['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
|
551 \ ['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
|
552 \ ['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
|
553 \ ['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
|
554 \ ['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
|
555 \ ['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
|
556 \ ['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
|
557 \ ['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
|
558 \ ['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
|
559 \ ['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
|
560 \ ['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
|
561 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
562 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
|
563 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
564 |
17910
f084f846442a
patch 8.1.1951: mouse double click test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
16716
diff
changeset
|
565 " Test for submatch() on :substitute. |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
566 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
|
567 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
568 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
569 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
570 " 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
|
571 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
|
572 \ ['a\a']], |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
573 \ ['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
|
574 \ ['b\b']], |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
575 \ ['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
|
576 \ ["c\<C-V>", 'c']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
577 \ ['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
|
578 \ ["d\<C-V>", 'd']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
579 \ ['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
|
580 \ ["e\\\<C-V>", 'e']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
581 \ ['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
|
582 \ ['f', 'f']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
583 \ ['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
|
584 \ ["g\<C-V>", 'g']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
585 \ ['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
|
586 \ ["h\<C-V>", 'h']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
587 \ ['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
|
588 \ ["i\\\<C-V>", 'i']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
589 \ ['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
|
590 \ ['j', 'j']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
591 \ ['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
|
592 \ ['k', 'k']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
593 \ ['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
|
594 \ ['l', 'l']], |
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 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
|
597 endfunc |
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 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
|
600 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
601 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
602 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
603 " 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
|
604 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
|
605 \ ['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
|
606 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
607 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
|
608 endfunc |
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 " 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
|
611 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
|
612 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
613 set cpo+=/ |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
614 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
615 " 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
|
616 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
|
617 \ ['B', 's/B/%/', ['a']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
618 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
619 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
|
620 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
621 set cpo-=/ |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
622 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
|
623 \ ['D', 's/D/%/', ['%']], |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
624 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
625 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
|
626 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
627 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
628 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
629 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
630 " 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
|
631 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
|
632 set magic& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
633 set cpo& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
634 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
635 " 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
|
636 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
|
637 \ ["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
|
638 \ ["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
|
639 \ ["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
|
640 \ ["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
|
641 \ ] |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
642 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
|
643 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
644 exe "normal oQ\nQ\<Esc>k" |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
645 call assert_fails('s/Q[^\n]Q/\=submatch(0)."foobar"/', 'E486:') |
12686
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
646 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
647 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
648 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
649 func TitleString() |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
650 let check = 'foo' =~ 'bar' |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
651 return "" |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
652 endfunc |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
653 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
654 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
|
655 set titlestring=%{TitleString()} |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
656 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
657 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
658 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
|
659 call cursor(1,1) |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
660 /^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
|
661 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
|
662 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
|
663 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
|
664 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
|
665 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
|
666 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
|
667 |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
668 enew! |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
669 set titlestring& |
aa658b33f25a
patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
12285
diff
changeset
|
670 endfunc |
16113
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
671 |
16716
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
672 func Test_sub_cmd_9() |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
673 new |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
674 let input = ['1 aaa', '2 aaa', '3 aaa'] |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
675 call setline(1, input) |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
676 func Foo() |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
677 return submatch(0) |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
678 endfunc |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
679 %s/aaa/\=Foo()/gn |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
680 call assert_equal(input, getline(1, '$')) |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
681 call assert_equal(1, &modifiable) |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
682 |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
683 delfunc Foo |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
684 bw! |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
685 endfunc |
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
686 |
16113
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
687 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
|
688 " normal error results in all replacements |
16716
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
689 func Foo() |
16113
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
690 foobar |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
691 endfunc |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
692 new |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
693 call setline(1, ['1 aaa', '2 aaa', '3 aaa']) |
29115
f371242b6a23
patch 8.2.5078: substitute test has a one second delay
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
694 " need silent! to avoid a delay when entering Insert mode |
f371242b6a23
patch 8.2.5078: substitute test has a one second delay
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
695 silent! %s/aaa/\=Foo()/g |
16113
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
696 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
|
697 |
29115
f371242b6a23
patch 8.2.5078: substitute test has a one second delay
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
698 " Throw without try-catch causes abort after the first line. |
16113
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
699 " 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
|
700 |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
701 " 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
|
702 func! Foo() |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
703 throw 'error' |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
704 endfunc |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
705 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
|
706 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
|
707 try |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
708 %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
|
709 catch |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
710 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
|
711 endtry |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
712 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
|
713 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
|
714 |
16686
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
715 " Same, but using "n" flag so that "sandbox" gets set |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
716 call setline(1, ['1 aaa', '2 aaa', '3 aaa']) |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
717 let error_caught = 0 |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
718 try |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
719 %s/aaa/\=Foo()/gn |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
720 catch |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
721 let error_caught = 1 |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
722 endtry |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
723 call assert_equal(1, error_caught) |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
724 call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3)) |
6ea3f93b4428
patch 8.1.1345: stuck in sandbox with ":s/../=Function/gn"
Bram Moolenaar <Bram@vim.org>
parents:
16419
diff
changeset
|
725 |
16716
5a541d459ef7
patch 8.1.1360: buffer left 'nomodifiable' after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16686
diff
changeset
|
726 delfunc Foo |
16113
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
727 bwipe! |
9994c50f7879
patch 8.1.1061: when substitute string throws error, substitute happens anyway
Bram Moolenaar <Bram@vim.org>
parents:
15768
diff
changeset
|
728 endfunc |
16419
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
729 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
730 " 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
|
731 func Test_replace_with_tilde() |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
732 new |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
733 " Set the last replace string to empty |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
734 s/^$// |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
735 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
|
736 normal gg |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
737 s/u/~u~/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
738 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
|
739 s/i/~u~/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
740 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
|
741 s/o/~~~/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
742 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
|
743 close! |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
744 endfunc |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
745 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
746 func Test_replace_keeppatterns() |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
747 new |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
748 a |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
749 foobar |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
750 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
751 substitute foo asdf |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
752 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
753 one two |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
754 . |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
755 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
756 normal gg |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
757 /^substitute |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
758 s/foo/bar/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
759 call assert_equal('foo', @/) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
760 call assert_equal('substitute bar asdf', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
761 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
762 /^substitute |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
763 keeppatterns s/asdf/xyz/ |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
764 call assert_equal('^substitute', @/) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
765 call assert_equal('substitute bar xyz', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
766 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
767 exe "normal /bar /e\<CR>" |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
768 call assert_equal(15, col('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
769 normal - |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
770 keeppatterns /xyz |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
771 call assert_equal('bar ', @/) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
772 call assert_equal('substitute bar xyz', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
773 exe "normal 0dn" |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
774 call assert_equal('xyz', getline('.')) |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
775 |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
776 close! |
aebcd20a8a3f
patch 8.1.1214: old style tests
Bram Moolenaar <Bram@vim.org>
parents:
16113
diff
changeset
|
777 endfunc |
18483
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
778 |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
779 func Test_sub_beyond_end() |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
780 new |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
781 call setline(1, '#') |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
782 let @/ = '^#\n\zs' |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
783 s///e |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
784 call assert_equal('#', getline(1)) |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
785 bwipe! |
54e5fa1f9cfc
patch 8.1.2236: ml_get error if pattern matches beyond last line
Bram Moolenaar <Bram@vim.org>
parents:
18017
diff
changeset
|
786 endfunc |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18576
diff
changeset
|
787 |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
788 " Test for repeating last substitution using :~ and :&r |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
789 func Test_repeat_last_sub() |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
790 new |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
791 call setline(1, ['blue green yellow orange white']) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
792 s/blue/red/ |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
793 let @/ = 'yellow' |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
794 ~ |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
795 let @/ = 'white' |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
796 :&r |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
797 let @/ = 'green' |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
798 s//gray |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
799 call assert_equal('red gray red orange red', getline(1)) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
800 close! |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
801 endfunc |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
802 |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
803 " Test for Vi compatible substitution: |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
804 " \/{string}/, \?{string}? and \&{string}& |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
805 func Test_sub_vi_compatibility() |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
806 new |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
807 call setline(1, ['blue green yellow orange blue']) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
808 let @/ = 'orange' |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
809 s\/white/ |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
810 let @/ = 'blue' |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
811 s\?amber? |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
812 let @/ = 'white' |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
813 s\&green& |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
814 call assert_equal('amber green yellow white green', getline(1)) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
815 close! |
27980
40e35cefeac6
patch 8.2.4515: old subsitute syntax is still supported
Bram Moolenaar <Bram@vim.org>
parents:
27449
diff
changeset
|
816 |
40e35cefeac6
patch 8.2.4515: old subsitute syntax is still supported
Bram Moolenaar <Bram@vim.org>
parents:
27449
diff
changeset
|
817 call assert_fails('vim9cmd s\/white/', 'E1270:') |
40e35cefeac6
patch 8.2.4515: old subsitute syntax is still supported
Bram Moolenaar <Bram@vim.org>
parents:
27449
diff
changeset
|
818 call assert_fails('vim9cmd s\?white?', 'E1270:') |
40e35cefeac6
patch 8.2.4515: old subsitute syntax is still supported
Bram Moolenaar <Bram@vim.org>
parents:
27449
diff
changeset
|
819 call assert_fails('vim9cmd s\&white&', 'E1270:') |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
820 endfunc |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
821 |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
822 " Test for substitute with the new text longer than the original text |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
823 func Test_sub_expand_text() |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
824 new |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
825 call setline(1, 'abcabcabcabcabcabcabcabc') |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
826 s/b/\=repeat('B', 10)/g |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
827 call assert_equal(repeat('aBBBBBBBBBBc', 8), getline(1)) |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
828 close! |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
829 endfunc |
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
830 |
19308
6fd567c927c0
patch 8.2.0212: missing search/substitute pattern hardly tested
Bram Moolenaar <Bram@vim.org>
parents:
19277
diff
changeset
|
831 " Test for command failures when the last substitute pattern is not set. |
6fd567c927c0
patch 8.2.0212: missing search/substitute pattern hardly tested
Bram Moolenaar <Bram@vim.org>
parents:
19277
diff
changeset
|
832 func Test_sub_with_no_last_pat() |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
833 let lines =<< trim [SCRIPT] |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
834 call assert_fails('~', 'E33:') |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
19969
diff
changeset
|
835 call assert_fails('s//abc/g', 'E35:') |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
19969
diff
changeset
|
836 call assert_fails('s\/bar', 'E35:') |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
19969
diff
changeset
|
837 call assert_fails('s\&bar&', 'E33:') |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
838 call writefile(v:errors, 'Xresult') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
839 qall! |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
840 [SCRIPT] |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
841 call writefile(lines, 'Xscript') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
842 if RunVim([], [], '--clean -S Xscript') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
843 call assert_equal([], readfile('Xresult')) |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
844 endif |
19308
6fd567c927c0
patch 8.2.0212: missing search/substitute pattern hardly tested
Bram Moolenaar <Bram@vim.org>
parents:
19277
diff
changeset
|
845 |
19370
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
846 let lines =<< trim [SCRIPT] |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
847 set cpo+=/ |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
848 call assert_fails('s/abc/%/', 'E33:') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
849 call writefile(v:errors, 'Xresult') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
850 qall! |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
851 [SCRIPT] |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
852 call writefile(lines, 'Xscript') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
853 if RunVim([], [], '--clean -S Xscript') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
854 call assert_equal([], readfile('Xresult')) |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
855 endif |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
856 |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
857 call delete('Xscript') |
02111977dd05
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
19308
diff
changeset
|
858 call delete('Xresult') |
19308
6fd567c927c0
patch 8.2.0212: missing search/substitute pattern hardly tested
Bram Moolenaar <Bram@vim.org>
parents:
19277
diff
changeset
|
859 endfunc |
6fd567c927c0
patch 8.2.0212: missing search/substitute pattern hardly tested
Bram Moolenaar <Bram@vim.org>
parents:
19277
diff
changeset
|
860 |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
861 func Test_substitute() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
862 call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g')) |
19969
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
863 " Substitute with special keys |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
864 call assert_equal("a\<End>c", substitute('abc', "a.c", "a\<End>c", '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
865 endfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
866 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
867 func Test_substitute_expr() |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
868 let g:val = 'XXX' |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
869 call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
870 call assert_equal('XXX', substitute('yyy', 'y*', {-> g:val}, '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
871 call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
872 \ '\=nr2char("0x" . submatch(1))', 'g')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
873 call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
874 \ {-> nr2char("0x" . submatch(1))}, 'g')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
875 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
876 call assert_equal('231', substitute('123', '\(.\)\(.\)\(.\)', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
877 \ {-> submatch(2) . submatch(3) . submatch(1)}, '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
878 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
879 func Recurse() |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
880 return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
881 endfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
882 " recursive call works |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
883 call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
884 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
885 call assert_fails("let s=submatch([])", 'E745:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
886 call assert_fails("let s=submatch(2, [])", 'E745:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
887 endfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
888 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
889 func Test_invalid_submatch() |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
890 " This was causing invalid memory access in Vim-7.4.2232 and older |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
891 call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')", 'E935:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
892 call assert_fails('eval submatch(-1)', 'E935:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
893 call assert_equal('', submatch(0)) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
894 call assert_equal('', submatch(1)) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
895 call assert_equal([], submatch(0, 1)) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
896 call assert_equal([], submatch(1, 1)) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
897 endfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
898 |
22143
3ec9e302ec94
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
899 func Test_submatch_list_concatenate() |
3ec9e302ec94
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
900 let pat = 'A\(.\)' |
3ec9e302ec94
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
901 let Rep = {-> string([submatch(0, 1)] + [[submatch(1)]])} |
3ec9e302ec94
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
902 call substitute('A1', pat, Rep, '')->assert_equal("[['A1'], ['1']]") |
3ec9e302ec94
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
903 endfunc |
3ec9e302ec94
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
904 |
19969
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
905 func Test_substitute_expr_arg() |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
906 call assert_equal('123456789-123456789=', substitute('123456789', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
907 \ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
908 \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . m[8] . m[9] . '='}, '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
909 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
910 call assert_equal('123456-123456=789', substitute('123456789', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
911 \ '\(.\)\(.\)\(.\)\(a*\)\(n*\)\(.\)\(.\)\(.\)\(x*\)', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
912 \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . m[4] . m[5] . m[6] . m[7] . m[8] . m[9] . '='}, '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
913 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
914 call assert_equal('123456789-123456789x=', substitute('123456789', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
915 \ '\(.\)\(.\)\(.*\)', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
916 \ {m -> m[0] . '-' . m[1] . m[2] . m[3] . 'x' . m[4] . m[5] . m[6] . m[7] . m[8] . m[9] . '='}, '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
917 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
918 call assert_fails("call substitute('xxx', '.', {m -> string(add(m, 'x'))}, '')", 'E742:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
919 call assert_fails("call substitute('xxx', '.', {m -> string(insert(m, 'x'))}, '')", 'E742:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
920 call assert_fails("call substitute('xxx', '.', {m -> string(extend(m, ['x']))}, '')", 'E742:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
921 call assert_fails("call substitute('xxx', '.', {m -> string(remove(m, 1))}, '')", 'E742:') |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
922 endfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
923 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
924 " Test for using a function to supply the substitute string |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
925 func Test_substitute_using_func() |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
926 func Xfunc() |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
927 return '1234' |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
928 endfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
929 call assert_equal('a1234f', substitute('abcdef', 'b..e', |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
930 \ function("Xfunc"), '')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
931 delfunc Xfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
932 endfunc |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
933 |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
934 " Test for using submatch() with a multiline match |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
935 func Test_substitute_multiline_submatch() |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
936 new |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
937 call setline(1, ['line1', 'line2', 'line3', 'line4']) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
938 %s/^line1\(\_.\+\)line4$/\=submatch(1)/ |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
939 call assert_equal(['', 'line2', 'line3', ''], getline(1, '$')) |
b07672d13ff9
patch 8.2.0540: regexp and other code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
940 close! |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
941 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19783
diff
changeset
|
942 |
24580
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
943 func Test_substitute_skipped_range() |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
944 new |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
945 if 0 |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
946 /1/5/2/2/\n |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
947 endif |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
948 call assert_equal([0, 1, 1, 0, 1], getcurpos()) |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
949 bwipe! |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
950 endfunc |
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
951 |
25617
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
952 " Test using the 'gdefault' option (when on, flag 'g' is default on). |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
953 func Test_substitute_gdefault() |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
954 new |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
955 |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
956 " First check without 'gdefault' |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
957 call setline(1, 'foo bar foo') |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
958 s/foo/FOO/ |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
959 call assert_equal('FOO bar foo', getline(1)) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
960 call setline(1, 'foo bar foo') |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
961 s/foo/FOO/g |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
962 call assert_equal('FOO bar FOO', getline(1)) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
963 call setline(1, 'foo bar foo') |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
964 s/foo/FOO/gg |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
965 call assert_equal('FOO bar foo', getline(1)) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
966 |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
967 " Then check with 'gdefault' |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
968 set gdefault |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
969 call setline(1, 'foo bar foo') |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
970 s/foo/FOO/ |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
971 call assert_equal('FOO bar FOO', getline(1)) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
972 call setline(1, 'foo bar foo') |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
973 s/foo/FOO/g |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
974 call assert_equal('FOO bar foo', getline(1)) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
975 call setline(1, 'foo bar foo') |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
976 s/foo/FOO/gg |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
977 call assert_equal('FOO bar FOO', getline(1)) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
978 |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
979 " Setting 'compatible' should reset 'gdefault' |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
980 call assert_equal(1, &gdefault) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
981 set compatible |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
982 call assert_equal(0, &gdefault) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
983 set nocompatible |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
984 call assert_equal(0, &gdefault) |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
985 |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
986 bw! |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
987 endfunc |
28f1b7c38ba1
patch 8.2.3345: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24820
diff
changeset
|
988 |
27449
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
989 " This was using "old_sub" after it was freed. |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
990 func Test_using_old_sub() |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
991 set compatible maxfuncdepth=10 |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
992 new |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
993 call setline(1, 'some text.') |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
994 func Repl() |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
995 ~ |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
996 s/ |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
997 endfunc |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
998 silent! s/\%')/\=Repl() |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
999 |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
1000 delfunc Repl |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
1001 bwipe! |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
1002 set nocompatible |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
1003 endfunc |
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
1004 |
28909
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1005 " This was switching windows in between computing the length and using it. |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1006 func Test_sub_change_window() |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1007 silent! lfile |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1008 sil! norm o0000000000000000000000000000000000000000000000000000 |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1009 func Repl() |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1010 lopen |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1011 endfunc |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1012 silent! s/\%')/\=Repl() |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1013 bwipe! |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1014 bwipe! |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1015 delfunc Repl |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1016 endfunc |
1890fa76a634
patch 8.2.4977: memory access error when substitute expression changes window
Bram Moolenaar <Bram@vim.org>
parents:
28205
diff
changeset
|
1017 |
29002
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1018 " This was undoign a change in between computing the length and using it. |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1019 func Do_Test_sub_undo_change() |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1020 new |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1021 norm o0000000000000000000000000000000000000000000000000000 |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1022 silent! s/\%')/\=Repl() |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1023 bwipe! |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1024 endfunc |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1025 |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1026 func Test_sub_undo_change() |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1027 func Repl() |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1028 silent! norm g- |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1029 endfunc |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1030 call Do_Test_sub_undo_change() |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1031 |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1032 func! Repl() |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1033 silent earlier |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1034 endfunc |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1035 call Do_Test_sub_undo_change() |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1036 |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1037 delfunc Repl |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1038 endfunc |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28909
diff
changeset
|
1039 |
29042
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1040 " This was opening a command line window from the expression |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1041 func Test_sub_open_cmdline_win() |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1042 " the error only happens in a very specific setup, run a new Vim instance to |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1043 " get a clean starting point. |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1044 let lines =<< trim [SCRIPT] |
29044
55ce8628cd9b
patch 8.2.5044: command line test fails
Bram Moolenaar <Bram@vim.org>
parents:
29042
diff
changeset
|
1045 set vb t_vb= |
29042
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1046 norm o0000000000000000000000000000000000000000000000000000 |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1047 func Replace() |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1048 norm q/ |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1049 endfunc |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1050 s/\%')/\=Replace() |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1051 redir >Xresult |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1052 messages |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1053 redir END |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1054 qall! |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1055 [SCRIPT] |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1056 call writefile(lines, 'Xscript') |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1057 if RunVim([], [], '-u NONE -S Xscript') |
29044
55ce8628cd9b
patch 8.2.5044: command line test fails
Bram Moolenaar <Bram@vim.org>
parents:
29042
diff
changeset
|
1058 call assert_match('E565: Not allowed to change text or change window', |
55ce8628cd9b
patch 8.2.5044: command line test fails
Bram Moolenaar <Bram@vim.org>
parents:
29042
diff
changeset
|
1059 \ readfile('Xresult')->join('XX')) |
29042
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1060 endif |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1061 |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1062 call delete('Xscript') |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1063 call delete('Xresult') |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1064 endfunc |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
1065 |
28205
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1066 " Test for the 2-letter and 3-letter :substitute commands |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1067 func Test_substitute_short_cmd() |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1068 new |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1069 call setline(1, ['one', 'one one one']) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1070 s/one/two |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1071 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1072 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1073 " :sc |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1074 call feedkeys(":sc\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1075 call assert_equal('two one one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1076 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1077 " :scg |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1078 call setline(2, 'one one one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1079 call feedkeys(":scg\<CR>nyq", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1080 call assert_equal('one two one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1081 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1082 " :sci |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1083 call setline(2, 'ONE One onE') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1084 call feedkeys(":sci\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1085 call assert_equal('two One onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1086 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1087 " :scI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1088 set ignorecase |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1089 call setline(2, 'ONE One one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1090 call feedkeys(":scI\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1091 call assert_equal('ONE One two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1092 set ignorecase& |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1093 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1094 " :scn |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1095 call setline(2, 'one one one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1096 let t = execute('scn')->split("\n") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1097 call assert_equal(['1 match on 1 line'], t) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1098 call assert_equal('one one one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1099 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1100 " :scp |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1101 call setline(2, "\tone one one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1102 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1103 call feedkeys(":scp\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1104 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1105 call assert_equal(' two one one', output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1106 call assert_equal("\ttwo one one", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1107 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1108 " :scl |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1109 call setline(2, "\tone one one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1110 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1111 call feedkeys(":scl\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1112 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1113 call assert_equal("^Itwo one one$", output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1114 call assert_equal("\ttwo one one", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1115 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1116 " :sgc |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1117 call setline(2, 'one one one one one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1118 call feedkeys(":sgc\<CR>nyyq", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1119 call assert_equal('one two two one one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1120 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1121 " :sg |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1122 call setline(2, 'one one one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1123 sg |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1124 call assert_equal('two two two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1125 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1126 " :sgi |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1127 call setline(2, 'ONE One onE') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1128 sgi |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1129 call assert_equal('two two two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1130 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1131 " :sgI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1132 set ignorecase |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1133 call setline(2, 'ONE One one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1134 sgI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1135 call assert_equal('ONE One two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1136 set ignorecase& |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1137 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1138 " :sgn |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1139 call setline(2, 'one one one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1140 let t = execute('sgn')->split("\n") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1141 call assert_equal(['3 matches on 1 line'], t) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1142 call assert_equal('one one one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1143 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1144 " :sgp |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1145 call setline(2, "\tone one one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1146 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1147 sgp |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1148 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1149 call assert_equal(' two two two', output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1150 call assert_equal("\ttwo two two", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1151 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1152 " :sgl |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1153 call setline(2, "\tone one one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1154 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1155 sgl |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1156 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1157 call assert_equal("^Itwo two two$", output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1158 call assert_equal("\ttwo two two", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1159 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1160 " :sgr |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1161 call setline(2, "one one one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1162 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1163 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1164 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1165 sgr |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1166 call assert_equal('xyz xyz xyz', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1167 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1168 " :sic |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1169 call cursor(1, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1170 s/one/two/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1171 call setline(2, "ONE One one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1172 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1173 call feedkeys(":sic\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1174 call assert_equal('two One one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1175 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1176 " :si |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1177 call setline(2, "ONE One one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1178 si |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1179 call assert_equal('two One one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1180 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1181 " :siI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1182 call setline(2, "ONE One one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1183 siI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1184 call assert_equal('ONE One two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1185 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1186 " :sin |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1187 call setline(2, 'ONE One onE') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1188 let t = execute('sin')->split("\n") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1189 call assert_equal(['1 match on 1 line'], t) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1190 call assert_equal('ONE One onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1191 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1192 " :sip |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1193 call setline(2, "\tONE One onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1194 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1195 sip |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1196 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1197 call assert_equal(' two One onE', output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1198 call assert_equal("\ttwo One onE", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1199 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1200 " :sir |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1201 call setline(2, "ONE One onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1202 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1203 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1204 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1205 sir |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1206 call assert_equal('xyz One onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1207 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1208 " :sIc |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1209 call cursor(1, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1210 s/one/two/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1211 call setline(2, "ONE One one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1212 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1213 call feedkeys(":sIc\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1214 call assert_equal('ONE One two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1215 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1216 " :sIg |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1217 call setline(2, "ONE one onE one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1218 sIg |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1219 call assert_equal('ONE two onE two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1220 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1221 " :sIi |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1222 call setline(2, "ONE One one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1223 sIi |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1224 call assert_equal('two One one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1225 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1226 " :sI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1227 call setline(2, "ONE One one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1228 sI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1229 call assert_equal('ONE One two', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1230 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1231 " :sIn |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1232 call setline(2, 'ONE One one') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1233 let t = execute('sIn')->split("\n") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1234 call assert_equal(['1 match on 1 line'], t) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1235 call assert_equal('ONE One one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1236 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1237 " :sIp |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1238 call setline(2, "\tONE One one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1239 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1240 sIp |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1241 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1242 call assert_equal(' ONE One two', output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1243 call assert_equal("\tONE One two", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1244 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1245 " :sIl |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1246 call setline(2, "\tONE onE one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1247 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1248 sIl |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1249 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1250 call assert_equal("^IONE onE two$", output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1251 call assert_equal("\tONE onE two", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1252 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1253 " :sIr |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1254 call setline(2, "ONE one onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1255 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1256 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1257 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1258 sIr |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1259 call assert_equal('ONE xyz onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1260 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1261 " :src |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1262 call setline(2, "ONE one one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1263 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1264 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1265 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1266 call feedkeys(":src\<CR>y", 'xt') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1267 call assert_equal('ONE xyz one', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1268 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1269 " :srg |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1270 call setline(2, "one one one") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1271 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1272 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1273 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1274 srg |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1275 call assert_equal('xyz xyz xyz', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1276 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1277 " :sri |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1278 call setline(2, "ONE one onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1279 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1280 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1281 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1282 sri |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1283 call assert_equal('xyz one onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1284 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1285 " :srI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1286 call setline(2, "ONE one onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1287 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1288 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1289 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1290 srI |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1291 call assert_equal('ONE xyz onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1292 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1293 " :srn |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1294 call setline(2, "ONE one onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1295 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1296 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1297 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1298 let t = execute('srn')->split("\n") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1299 call assert_equal(['1 match on 1 line'], t) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1300 call assert_equal('ONE one onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1301 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1302 " :srp |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1303 call setline(2, "\tONE one onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1304 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1305 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1306 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1307 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1308 srp |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1309 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1310 call assert_equal(' ONE xyz onE', output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1311 call assert_equal("\tONE xyz onE", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1312 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1313 " :srl |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1314 call setline(2, "\tONE one onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1315 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1316 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1317 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1318 redir => output |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1319 srl |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1320 redir END |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1321 call assert_equal("^IONE xyz onE$", output->split("\n")[-1]) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1322 call assert_equal("\tONE xyz onE", getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1323 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1324 " :sr |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1325 call setline(2, "ONE one onE") |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1326 call cursor(2, 1) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1327 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1328 let @/ = 'one' |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1329 sr |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1330 call assert_equal('ONE xyz onE', getline(2)) |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1331 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1332 " :sce |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1333 s/abc/xyz/e |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1334 call assert_fails("sc", 'E486:') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1335 sce |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1336 " :sge |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1337 call assert_fails("sg", 'E486:') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1338 sge |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1339 " :sie |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1340 call assert_fails("si", 'E486:') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1341 sie |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1342 " :sIe |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1343 call assert_fails("sI", 'E486:') |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1344 sIe |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1345 |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1346 bw! |
553ff405b719
patch 8.2.4628: not enough testing for 2/3 letter substitute commands
Bram Moolenaar <Bram@vim.org>
parents:
27980
diff
changeset
|
1347 endfunc |
27449
b4c147ad4912
patch 8.2.4253: using freed memory when substitute with function call
Bram Moolenaar <Bram@vim.org>
parents:
25617
diff
changeset
|
1348 |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18576
diff
changeset
|
1349 " vim: shiftwidth=2 sts=2 expandtab |