annotate src/testdir/test_global.vim @ 29252:49805cb64d1d

Added tag v8.2.5144 for changeset aea330cb546f14e3d65b8f8fddaba1a0fa0aae5d
author Bram Moolenaar <Bram@vim.org>
date Tue, 21 Jun 2022 19:15:03 +0200
parents 0fa3be75ddc7
children 34bb46847ba0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1 " Test for :global and :vglobal
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
2
20707
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
3 source check.vim
11273
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_yank_put_clipboard()
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 new
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call setline(1, ['a', 'b', 'c'])
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 set clipboard=unnamed
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 g/^/normal yyp
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6))
19738
0208534b8a84 patch 8.2.0425: code for modeless selection not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
11 set clipboard=unnamed,unnamedplus
0208534b8a84 patch 8.2.0425: code for modeless selection not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
12 call setline(1, ['a', 'b', 'c'])
0208534b8a84 patch 8.2.0425: code for modeless selection not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
13 g/^/normal yyp
0208534b8a84 patch 8.2.0425: code for modeless selection not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
14 call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6))
11273
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 set clipboard&
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 bwipe!
96d83cd2904a patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 endfunc
11494
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
18
20707
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
19 func Test_global_set_clipboard()
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
20 CheckFeature clipboard_working
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
21 new
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
22 set clipboard=unnamedplus
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
23 let @+='clipboard' | g/^/set cb= | let @" = 'unnamed' | put
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
24 call assert_equal(['','unnamed'], getline(1, '$'))
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
25 set clipboard&
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
26 bwipe!
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
27 endfunc
ec89debe5037 patch 8.2.0907: when using :global clipboard isn't set correctly
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
28
11494
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
29 func Test_nested_global()
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
30 new
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
31 call setline(1, ['nothing', 'found', 'found bad', 'bad'])
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
32 call assert_fails('g/found/3v/bad/s/^/++/', 'E147:')
11494
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
33 g/found/v/bad/s/^/++/
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
34 call assert_equal(['nothing', '++found', 'found bad', 'bad'], getline(1, 4))
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
35 bwipe!
8e5ec22db3d8 patch 8.0.0630: it is not easy to work on lines without a match
Christian Brabandt <cb@256bit.org>
parents: 11273
diff changeset
36 endfunc
19231
b8fd7364befd patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents: 11494
diff changeset
37
b8fd7364befd patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents: 11494
diff changeset
38 func Test_global_error()
b8fd7364befd patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents: 11494
diff changeset
39 call assert_fails('g\\a', 'E10:')
b8fd7364befd patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents: 11494
diff changeset
40 call assert_fails('g', 'E148:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20707
diff changeset
41 call assert_fails('g/\(/y', 'E54:')
19231
b8fd7364befd patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents: 11494
diff changeset
42 endfunc
b8fd7364befd patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents: 11494
diff changeset
43
19277
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
44 " Test for printing lines using :g with different search patterns
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
45 func Test_global_print()
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
46 new
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
47 call setline(1, ['foo', 'bar', 'foo', 'foo'])
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
48 let @/ = 'foo'
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
49 let t = execute("g/")->trim()->split("\n")
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
50 call assert_equal(['foo', 'foo', 'foo'], t)
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
51
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
52 " Test for Vi compatible patterns
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
53 let @/ = 'bar'
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
54 let t = execute('g\/')->trim()->split("\n")
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
55 call assert_equal(['bar'], t)
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
56
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
57 normal gg
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
58 s/foo/foo/
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
59 let t = execute('g\&')->trim()->split("\n")
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
60 call assert_equal(['foo', 'foo', 'foo'], t)
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
61
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
62 let @/ = 'bar'
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
63 let t = execute('g?')->trim()->split("\n")
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
64 call assert_equal(['bar'], t)
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
65
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
66 " Test for the 'Pattern found in every line' message
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
67 let v:statusmsg = ''
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
68 v/foo\|bar/p
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
69 call assert_notequal('', v:statusmsg)
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
70
27962
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
71 " In Vim9 script this is an error
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
72 let caught = 'no'
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
73 try
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
74 vim9cmd v/foo\|bar/p
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
75 catch /E538/
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
76 let caught = 'yes'
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
77 call assert_match('E538: Pattern found in every line: foo\|bar', v:exception)
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
78 endtry
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
79 call assert_equal('yes', caught)
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
80
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
81 " In Vim9 script not matching is an error
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
82 let caught = 'no'
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
83 try
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
84 vim9cmd g/foobarnotfound/p
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
85 catch /E486/
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
86 let caught = 'yes'
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
87 call assert_match('E486: Pattern not found: foobarnotfound', v:exception)
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
88 endtry
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
89 call assert_equal('yes', caught)
0fa3be75ddc7 patch 8.2.4506: "pattern not found" for :global is not an error message
Bram Moolenaar <Bram@vim.org>
parents: 24992
diff changeset
90
19277
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
91 close!
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
92 endfunc
1b02482e6a61 patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19231
diff changeset
93
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
94 " Test for global command with newline character
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
95 func Test_global_newline()
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
96 new
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
97 call setline(1, ['foo'])
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
98 exe "g/foo/s/f/h/\<NL>s/o$/w/"
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
99 call assert_equal('how', getline(1))
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
100 call setline(1, ["foo\<NL>bar"])
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
101 exe "g/foo/s/foo\\\<NL>bar/xyz/"
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
102 call assert_equal('xyz', getline(1))
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
103 close!
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
104 endfunc
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19277
diff changeset
105
24992
026718ffbfa8 patch 8.2.3033: no error when using alpha delimiter with :global
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
106 func Test_wrong_delimiter()
026718ffbfa8 patch 8.2.3033: no error when using alpha delimiter with :global
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
107 call assert_fails('g x^bxd', 'E146:')
026718ffbfa8 patch 8.2.3033: no error when using alpha delimiter with :global
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
108 endfunc
026718ffbfa8 patch 8.2.3033: no error when using alpha delimiter with :global
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
109
19231
b8fd7364befd patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents: 11494
diff changeset
110 " vim: shiftwidth=2 sts=2 expandtab