annotate src/testdir/test_bufline.vim @ 23788:d12ef361d9de v8.2.2435

patch 8.2.2435: setline() gives an error for some types Commit: https://github.com/vim/vim/commit/3445320839a38b3b0c253513b125da8298ec27d6 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 31 13:08:38 2021 +0100 patch 8.2.2435: setline() gives an error for some types Problem: setline() gives an error for some types. Solution: Allow any type, convert each item to a string.
author Bram Moolenaar <Bram@vim.org>
date Sun, 31 Jan 2021 13:15:04 +0100
parents 08940efa6b4e
children 54b583156d53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
1 " Tests for setbufline(), getbufline(), appendbufline(), deletebufline()
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
12568
440d934bd616 patch 8.0.1162: shared script for tests cannot be included twice
Christian Brabandt <cb@256bit.org>
parents: 12351
diff changeset
3 source shared.vim
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
4 source screendump.vim
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17518
diff changeset
5 source check.vim
12351
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
6
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 func Test_setbufline_getbufline()
23788
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
8 " similar to Test_set_get_bufline()
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 new
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let b = bufnr('%')
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 hide
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal(['foo'], getbufline(b, 1))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
14 call assert_equal(['bar'], getbufline(b, '$'))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 exe "bd!" b
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal([], getbufline(b, 1, 2))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 split Xtest
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call setline(1, ['a', 'b', 'c'])
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 let b = bufnr('%')
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 wincmd w
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
23
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
24 call assert_equal(1, setbufline(b, 5, 'x'))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_equal(1, setbufline(b, 5, ['x']))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
26 call assert_equal(1, setbufline(b, 5, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
27 call assert_equal(1, setbufline(b, 5, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
28
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
29 call assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1))
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
30 call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
31 call assert_equal(1, []->setbufline(bufnr('$') + 1, 1))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
32 call assert_equal(1, test_null_list()->setbufline(bufnr('$') + 1, 1))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
33
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
34 call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
35
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call assert_equal(0, setbufline(b, 4, ['d', 'e']))
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
37 call assert_equal(['c'], b->getbufline(3))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal(['d'], getbufline(b, 4))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal(['e'], getbufline(b, 5))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_equal([], getbufline(b, 6))
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
41 call assert_equal([], getbufline(b, 2, 1))
23788
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
42
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
43 call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()])
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
44 call assert_equal(["function('eval')",
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
45 \ "{'key': 123}",
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
46 \ "no process"],
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
47 \ getbufline(b, 2, 4))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 exe "bwipe! " . b
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endfunc
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
50
12794
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
51 func Test_setbufline_getbufline_fold()
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
52 split Xtest
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
53 setlocal foldmethod=expr foldexpr=0
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
54 let b = bufnr('%')
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
55 new
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
56 call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
57 call assert_equal(['foo'], getbufline(b, 1))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
58 call assert_equal(['bar'], getbufline(b, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
59 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
60 exe "bwipe!" b
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
61 bwipe!
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
62 endfunc
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
63
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
64 func Test_setbufline_getbufline_fold_tab()
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
65 split Xtest
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
66 setlocal foldmethod=expr foldexpr=0
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
67 let b = bufnr('%')
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
68 tab new
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
69 call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
70 call assert_equal(['foo'], getbufline(b, 1))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
71 call assert_equal(['bar'], getbufline(b, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
72 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
73 exe "bwipe!" b
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
74 bwipe!
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
75 endfunc
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
76
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
77 func Test_setline_startup()
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
78 let cmd = GetVimCommand('Xscript')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
79 if cmd == ''
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
80 return
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
81 endif
12351
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
82 call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript')
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
83 call system(cmd)
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
84 call assert_equal(['Hello'], readfile('Xtest'))
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
85
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
86 call delete('Xscript')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
87 call delete('Xtest')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
88 endfunc
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
89
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
90 func Test_appendbufline()
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
91 new
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
92 let b = bufnr('%')
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
93 hide
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
94 call assert_equal(0, appendbufline(b, 0, ['foo', 'bar']))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
95 call assert_equal(['foo'], getbufline(b, 1))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
96 call assert_equal(['bar'], getbufline(b, 2))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
97 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
98 exe "bd!" b
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
99 call assert_equal([], getbufline(b, 1, 2))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
100
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
101 split Xtest
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
102 call setline(1, ['a', 'b', 'c'])
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
103 let b = bufnr('%')
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
104 wincmd w
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
105
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
106 call assert_equal(1, appendbufline(b, -1, 'x'))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
107 call assert_equal(1, appendbufline(b, -1, ['x']))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
108 call assert_equal(1, appendbufline(b, -1, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
109 call assert_equal(1, appendbufline(b, -1, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
110
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
111 call assert_equal(1, appendbufline(b, 4, 'x'))
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
112 call assert_equal(1, appendbufline(b, 4, ['x']))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
113 call assert_equal(1, appendbufline(b, 4, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
114 call assert_equal(1, appendbufline(b, 4, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
115
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
116 call assert_equal(1, appendbufline(1234, 1, 'x'))
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
117 call assert_equal(1, appendbufline(1234, 1, ['x']))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
118 call assert_equal(1, appendbufline(1234, 1, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
119 call assert_equal(1, appendbufline(1234, 1, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
121 call assert_equal(0, appendbufline(b, 1, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
122 call assert_equal(0, appendbufline(b, 1, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
123 call assert_equal(1, appendbufline(b, 3, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
124 call assert_equal(1, appendbufline(b, 3, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
125
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
126 call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
127
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
128 call assert_equal(0, appendbufline(b, 3, ['d', 'e']))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
129 call assert_equal(['c'], getbufline(b, 3))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
130 call assert_equal(['d'], getbufline(b, 4))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
131 call assert_equal(['e'], getbufline(b, 5))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
132 call assert_equal([], getbufline(b, 6))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
133 exe "bwipe! " . b
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
134 endfunc
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
135
14826
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
136 func Test_appendbufline_no_E315()
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
137 let after =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
138 set stl=%f ls=2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
139 new
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
140 let buf = bufnr("%")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
141 quit
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
142 vsp
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
143 exec "buffer" buf
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
144 wincmd w
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
145 call appendbufline(buf, 0, "abc")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
146 redraw
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
147 while getbufline(buf, 1)[0] =~ "^\\s*$"
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
148 sleep 10m
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
149 endwhile
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
150 au VimLeavePre * call writefile([v:errmsg], "Xerror")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
151 au VimLeavePre * call writefile(["done"], "Xdone")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
152 qall!
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
153 [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
154
14826
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
155 if !RunVim([], after, '--clean')
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
156 return
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
157 endif
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
158 call assert_notmatch("^E315:", readfile("Xerror")[0])
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
159 call assert_equal("done", readfile("Xdone")[0])
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
160 call delete("Xerror")
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
161 call delete("Xdone")
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
162 endfunc
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
163
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
164 func Test_deletebufline()
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
165 new
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
166 let b = bufnr('%')
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
167 call setline(1, ['aaa', 'bbb', 'ccc'])
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
168 hide
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
169 call assert_equal(0, deletebufline(b, 2))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
170 call assert_equal(['aaa', 'ccc'], getbufline(b, 1, 2))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
171 call assert_equal(0, deletebufline(b, 2, 8))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
172 call assert_equal(['aaa'], getbufline(b, 1, 2))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
173 exe "bd!" b
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
174 call assert_equal(1, b->deletebufline(1))
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
175
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
176 call assert_equal(1, deletebufline(-1, 1))
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
177
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
178 split Xtest
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
179 call setline(1, ['a', 'b', 'c'])
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
180 call cursor(line('$'), 1)
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
181 let b = bufnr('%')
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
182 wincmd w
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
183 call assert_equal(1, deletebufline(b, 4))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
184 call assert_equal(0, deletebufline(b, 1))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
185 call assert_equal(['b', 'c'], getbufline(b, 1, 2))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
186 exe "bwipe! " . b
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
187 endfunc
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
188
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
189 func Test_appendbufline_redraw()
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17518
diff changeset
190 CheckScreendump
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17518
diff changeset
191
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
192 let lines =<< trim END
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
193 new foo
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
194 let winnr = 'foo'->bufwinnr()
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
195 let buf = bufnr('foo')
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
196 wincmd p
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
197 call appendbufline(buf, '$', range(1,200))
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
198 exe winnr .. 'wincmd w'
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
199 norm! G
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
200 wincmd p
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
201 call deletebufline(buf, 1, '$')
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
202 call appendbufline(buf, '$', 'Hello Vim world...')
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
203 END
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
204 call writefile(lines, 'XscriptMatchCommon')
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
205 let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10})
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
206 call TermWait(buf)
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
207 call VerifyScreenDump(buf, 'Test_appendbufline_1', {})
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
208
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
209 call StopVimInTerminal(buf)
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
210 call delete('XscriptMatchCommon')
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
211 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
212
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
213 " vim: shiftwidth=2 sts=2 expandtab