annotate src/testdir/test_bufline.vim @ 16720:9c90cf08cfa8 v8.1.1362

patch 8.1.1362: code and data in tests can be hard to read commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 20 22:12:34 2019 +0200 patch 8.1.1362: code and data in tests can be hard to read Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 May 2019 22:15:06 +0200
parents 81be817c9d9a
children bfc5a2962f38
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
12351
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
4
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_setbufline_getbufline()
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 new
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 let b = bufnr('%')
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 hide
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 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
10 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
11 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
12 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
13 exe "bd!" b
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 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
15
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 split Xtest
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 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
18 let b = bufnr('%')
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 wincmd w
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(1, setbufline(b, 5, ['x']))
16368
a3b5cbd2effe patch 8.1.1189: mode is not cleared when leaving Insert mode
Bram Moolenaar <Bram@vim.org>
parents: 14826
diff changeset
21 call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x']))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal(0, setbufline(b, 4, ['d', 'e']))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal(['c'], getbufline(b, 3))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 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
25 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
26 call assert_equal([], getbufline(b, 6))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 exe "bwipe! " . b
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 endfunc
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
29
12794
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
30 func Test_setbufline_getbufline_fold()
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
31 split Xtest
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
32 setlocal foldmethod=expr foldexpr=0
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
33 let b = bufnr('%')
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
34 new
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
35 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
36 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
37 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
38 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
39 exe "bwipe!" b
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
40 bwipe!
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
41 endfunc
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
42
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
43 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
44 split Xtest
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
45 setlocal foldmethod=expr foldexpr=0
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
46 let b = bufnr('%')
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
47 tab new
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
48 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
49 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
50 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
51 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
52 exe "bwipe!" b
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
53 bwipe!
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
54 endfunc
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
55
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
56 func Test_setline_startup()
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
57 let cmd = GetVimCommand('Xscript')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
58 if cmd == ''
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
59 return
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
60 endif
12351
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
61 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
62 call system(cmd)
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
63 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
64
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
65 call delete('Xscript')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
66 call delete('Xtest')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
67 endfunc
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
68
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
69 func Test_appendbufline()
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
70 new
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
71 let b = bufnr('%')
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
72 hide
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
73 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
74 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
75 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
76 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
77 exe "bd!" b
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
78 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
79
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
80 split Xtest
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
81 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
82 let b = bufnr('%')
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
83 wincmd w
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
84 call assert_equal(1, appendbufline(b, -1, ['x']))
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
85 call assert_equal(1, appendbufline(b, 4, ['x']))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
86 call assert_equal(1, appendbufline(1234, 1, ['x']))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
87 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
88 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
89 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
90 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
91 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
92 exe "bwipe! " . b
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
93 endfunc
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
94
14826
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112 [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
113
14826
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
114 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
115 return
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
116 endif
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
117 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
118 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
119 call delete("Xerror")
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
120 call delete("Xdone")
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
121 endfunc
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
122
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
123 func Test_deletebufline()
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
124 new
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
125 let b = bufnr('%')
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
126 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
127 hide
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
128 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
129 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
130 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
131 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
132 exe "bd!" b
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
133 call assert_equal(1, deletebufline(b, 1))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
134
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
135 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
136
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
137 split Xtest
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
138 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
139 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
140 let b = bufnr('%')
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
141 wincmd w
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
142 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
143 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
144 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
145 exe "bwipe! " . b
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
146 endfunc