annotate src/testdir/test_buffer.vim @ 21024:02b03915855d v8.2.1063

patch 8.2.1063: Vim9: no line break allowed before || or && Commit: https://github.com/vim/vim/commit/be7ee488761a5582a5605197c3951a17f20d072e Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 26 21:38:51 2020 +0200 patch 8.2.1063: Vim9: no line break allowed before || or && Problem: Vim9: no line break allowed before || or &&. Solution: Check for operator after line break.
author Bram Moolenaar <Bram@vim.org>
date Fri, 26 Jun 2020 21:45:16 +0200
parents 55b3849ded11
children 6a4806e326dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for Vim buffer
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
20990
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
3 source check.vim
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
4
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " Test for the :bunload command with an offset
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 func Test_bunload_with_offset()
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 %bwipe!
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 call writefile(['B1'], 'b1')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 call writefile(['B2'], 'b2')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 call writefile(['B3'], 'b3')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 call writefile(['B4'], 'b4')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 " Load four buffers. Unload the second and third buffers and then
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 " execute .+3bunload to unload the last buffer.
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 edit b1
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 new b2
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 new b3
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 new b4
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 bunload b2
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 bunload b3
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 exe bufwinnr('b1') . 'wincmd w'
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 .+3bunload
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 call assert_equal(0, getbufinfo('b4')[0].loaded)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 call assert_equal('b1',
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 " Load four buffers. Unload the third and fourth buffers. Execute .+3bunload
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 " and check whether the second buffer is unloaded.
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 ball
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 bunload b3
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 bunload b4
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 exe bufwinnr('b1') . 'wincmd w'
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 .+3bunload
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 call assert_equal(0, getbufinfo('b2')[0].loaded)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call assert_equal('b1',
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 " Load four buffers. Unload the second and third buffers and from the last
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 " buffer execute .-3bunload to unload the first buffer.
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 ball
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 bunload b2
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 bunload b3
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 exe bufwinnr('b4') . 'wincmd w'
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 .-3bunload
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 call assert_equal(0, getbufinfo('b1')[0].loaded)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 call assert_equal('b4',
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 " Load four buffers. Unload the first and second buffers. Execute .-3bunload
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 " from the last buffer and check whether the third buffer is unloaded.
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 ball
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 bunload b1
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 bunload b2
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 exe bufwinnr('b4') . 'wincmd w'
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 .-3bunload
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 call assert_equal(0, getbufinfo('b3')[0].loaded)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 call assert_equal('b4',
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 %bwipe!
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 call delete('b1')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 call delete('b2')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 call delete('b3')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 call delete('b4')
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
66
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
67 call assert_fails('1,4bunload', 'E16:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
68 call assert_fails(',100bunload', 'E16:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
69
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
70 " Use a try-catch for this test. When assert_fails() is used for this
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
71 " test, the command fails with E515: instead of E90:
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
72 let caught_E90 = 0
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
73 try
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
74 $bunload
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
75 catch /E90:/
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
76 let caught_E90 = 1
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
77 endtry
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
78 call assert_equal(1, caught_E90)
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
79 call assert_fails('$bunload', 'E515:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
80 endfunc
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
81
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
82 " Test for :buffer, :bnext, :bprevious, :brewind, :blast and :bmodified
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
83 " commands
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
84 func Test_buflist_browse()
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
85 %bwipe!
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
86 call assert_fails('buffer 1000', 'E86:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
87
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
88 call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xfile1')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
89 call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xfile2')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
90 call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xfile3')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
91 edit Xfile1
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
92 let b1 = bufnr()
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
93 edit Xfile2
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
94 let b2 = bufnr()
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
95 edit +/baz4 Xfile3
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
96 let b3 = bufnr()
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
97
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
98 call assert_fails('buffer ' .. b1 .. ' abc', 'E488:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
99 call assert_equal(b3, bufnr())
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
100 call assert_equal(4, line('.'))
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
101 exe 'buffer +/bar2 ' .. b2
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
102 call assert_equal(b2, bufnr())
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
103 call assert_equal(2, line('.'))
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
104 exe 'buffer +/bar1'
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
105 call assert_equal(b2, bufnr())
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
106 call assert_equal(1, line('.'))
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
107
19425
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
108 brewind +
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
109 call assert_equal(b1, bufnr())
19425
67fbe280a502 patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
110 call assert_equal(4, line('.'))
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
111
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
112 blast +/baz2
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
113 call assert_equal(b3, bufnr())
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
114 call assert_equal(2, line('.'))
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
115
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
116 bprevious +/bar4
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
117 call assert_equal(b2, bufnr())
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
118 call assert_equal(4, line('.'))
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
119
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
120 bnext +/baz3
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
121 call assert_equal(b3, bufnr())
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
122 call assert_equal(3, line('.'))
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
123
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
124 call assert_fails('bmodified', 'E84:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
125 call setbufvar(b2, '&modified', 1)
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
126 exe 'bmodified +/bar3'
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
127 call assert_equal(b2, bufnr())
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
128 call assert_equal(3, line('.'))
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
129
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
130 " With no listed buffers in the list, :bnext and :bprev should fail
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
131 %bwipe!
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
132 set nobuflisted
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
133 call assert_fails('bnext', 'E85:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
134 call assert_fails('bprev', 'E85:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
135 set buflisted
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
136
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
137 call assert_fails('sandbox bnext', 'E48:')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
138
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
139 call delete('Xfile1')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
140 call delete('Xfile2')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
141 call delete('Xfile3')
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
142 %bwipe!
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
143 endfunc
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
144
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
145 " Test for :bdelete
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
146 func Test_bdelete_cmd()
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
147 %bwipe!
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
148 call assert_fails('bdelete 5', 'E516:')
19740
a653d1a165ef patch 8.2.0426: some errors were not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
149 call assert_fails('1,1bdelete 1 2', 'E488:')
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
150
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
151 " Deleting a unlisted and unloaded buffer
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
152 edit Xfile1
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
153 let bnr = bufnr()
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
154 set nobuflisted
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
155 enew
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
156 call assert_fails('bdelete ' .. bnr, 'E516:')
20990
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
157
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
158 " Deleting more than one buffer
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
159 new Xbuf1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
160 new Xbuf2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
161 exe 'bdel ' .. bufnr('Xbuf2') .. ' ' .. bufnr('Xbuf1')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
162 call assert_equal(1, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
163 call assert_equal(0, getbufinfo('Xbuf1')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
164 call assert_equal(0, getbufinfo('Xbuf2')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
165
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
166 " Deleting more than one buffer and an invalid buffer
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
167 new Xbuf1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
168 new Xbuf2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
169 let cmd = "exe 'bdel ' .. bufnr('Xbuf2') .. ' xxx ' .. bufnr('Xbuf1')"
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
170 call assert_fails(cmd, 'E94:')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
171 call assert_equal(2, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
172 call assert_equal(1, getbufinfo('Xbuf1')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
173 call assert_equal(0, getbufinfo('Xbuf2')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
174
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
175 %bwipe!
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177
20041
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
178 func Test_buffer_error()
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
179 new foo1
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
180 new foo2
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
181
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
182 call assert_fails('buffer foo', 'E93:')
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
183 call assert_fails('buffer bar', 'E94:')
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
184 call assert_fails('buffer 0', 'E939:')
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
185
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
186 %bwipe
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
187 endfunc
3601e816a569 patch 8.2.0576: some errors are not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19740
diff changeset
188
20990
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
189 " Test for the status messages displayed when unloading, deleting or wiping
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
190 " out buffers
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
191 func Test_buffer_statusmsg()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
192 CheckEnglish
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
193 set report=1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
194 new Xbuf1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
195 new Xbuf2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
196 let bnr = bufnr()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
197 exe "normal 2\<C-G>"
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
198 call assert_match('buf ' .. bnr .. ':', v:statusmsg)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
199 bunload Xbuf1 Xbuf2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
200 call assert_equal('2 buffers unloaded', v:statusmsg)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
201 bdel Xbuf1 Xbuf2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
202 call assert_equal('2 buffers deleted', v:statusmsg)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
203 bwipe Xbuf1 Xbuf2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
204 call assert_equal('2 buffers wiped out', v:statusmsg)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
205 set report&
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
206 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
207
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
208 " Test for quitting the 'swapfile exists' dialog with the split buffer
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
209 " command.
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
210 func Test_buffer_sbuf_cleanup()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
211 call writefile([], 'Xfile')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
212 " first open the file in a buffer
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
213 new Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
214 let bnr = bufnr()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
215 close
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
216 " create the swap file
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
217 call writefile([], '.Xfile.swp')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
218 " Remove the catch-all that runtest.vim adds
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
219 au! SwapExists
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
220 augroup BufTest
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
221 au!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
222 autocmd SwapExists Xfile let v:swapchoice='q'
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
223 augroup END
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
224 exe 'sbuf ' . bnr
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
225 call assert_equal(1, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
226 call assert_equal(0, getbufinfo('Xfile')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
227
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
228 " test for :sball
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
229 sball
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
230 call assert_equal(1, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
231 call assert_equal(0, getbufinfo('Xfile')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
232
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
233 %bw!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
234 set shortmess+=F
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
235 let v:statusmsg = ''
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
236 edit Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
237 call assert_equal('', v:statusmsg)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
238 call assert_equal(1, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
239 call assert_equal(0, getbufinfo('Xfile')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
240 set shortmess&
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
241
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
242 call delete('Xfile')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
243 call delete('.Xfile.swp')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
244 augroup BufTest
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
245 au!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
246 augroup END
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
247 augroup! BufTest
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
248 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
249
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
250 " Test for deleting a modified buffer with :confirm
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
251 func Test_bdel_with_confirm()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
252 CheckUnix
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
253 CheckNotGui
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
254 CheckFeature dialog_con
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
255 new
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
256 call setline(1, 'test')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
257 call assert_fails('bdel', 'E89:')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
258 call feedkeys('c', 'L')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
259 confirm bdel
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
260 call assert_equal(2, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
261 call assert_equal(1, &modified)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
262 call feedkeys('n', 'L')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
263 confirm bdel
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
264 call assert_equal(1, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
265 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
266
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
267 " Test for editing another buffer from a modified buffer with :confirm
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
268 func Test_goto_buf_with_confirm()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
269 CheckUnix
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
270 CheckNotGui
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
271 CheckFeature dialog_con
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
272 new Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
273 enew
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
274 call setline(1, 'test')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
275 call assert_fails('b Xfile', 'E37:')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
276 call feedkeys('c', 'L')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
277 call assert_fails('confirm b Xfile', 'E37:')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
278 call assert_equal(1, &modified)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
279 call assert_equal('', @%)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
280 call feedkeys('y', 'L')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
281 call assert_fails('confirm b Xfile', 'E37:')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
282 call assert_equal(1, &modified)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
283 call assert_equal('', @%)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
284 call feedkeys('n', 'L')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
285 confirm b Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
286 call assert_equal('Xfile', @%)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
287 close!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
288 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
289
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
290 " Test for splitting buffer with 'switchbuf'
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
291 func Test_buffer_switchbuf()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
292 new Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
293 wincmd w
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
294 set switchbuf=useopen
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
295 sbuf Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
296 call assert_equal(1, winnr())
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
297 call assert_equal(2, winnr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
298 set switchbuf=usetab
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
299 tabnew
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
300 sbuf Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
301 call assert_equal(1, tabpagenr())
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
302 call assert_equal(2, tabpagenr('$'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
303 set switchbuf&
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
304 %bw
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
305 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
306
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
307 " Test for BufAdd autocommand wiping out the buffer
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
308 func Test_bufadd_autocmd_bwipe()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
309 %bw!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
310 augroup BufAdd_Wipe
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
311 au!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
312 autocmd BufAdd Xfile %bw!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
313 augroup END
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
314 edit Xfile
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
315 call assert_equal('', @%)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
316 call assert_equal(0, bufexists('Xfile'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
317 augroup BufAdd_Wipe
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
318 au!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
319 augroup END
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
320 augroup! BufAdd_Wipe
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
321 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
322
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
323 " Test for trying to load a buffer with text locked
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
324 " <C-\>e in the command line is used to lock the text
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
325 func Test_load_buf_with_text_locked()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
326 new Xfile1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
327 edit Xfile2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
328 let cmd = ":\<C-\>eexecute(\"normal \<C-O>\")\<CR>\<C-C>"
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
329 call assert_fails("call feedkeys(cmd, 'xt')", 'E565:')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
330 %bw!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
331 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
332
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
333 " Test for using CTRL-^ to edit the alternative file keeping the cursor
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
334 " position with 'nostartofline'. Also test using the 'buf' command.
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
335 func Test_buffer_edit_altfile()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
336 call writefile(repeat(['one two'], 50), 'Xfile1')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
337 call writefile(repeat(['five six'], 50), 'Xfile2')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
338 set nosol
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
339 edit Xfile1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
340 call cursor(25, 5)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
341 edit Xfile2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
342 call cursor(30, 4)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
343 exe "normal \<C-^>"
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
344 call assert_equal([0, 25, 5, 0], getpos('.'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
345 exe "normal \<C-^>"
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
346 call assert_equal([0, 30, 4, 0], getpos('.'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
347 buf Xfile1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
348 call assert_equal([0, 25, 5, 0], getpos('.'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
349 buf Xfile2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
350 call assert_equal([0, 30, 4, 0], getpos('.'))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
351 set sol&
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
352 call delete('Xfile1')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
353 call delete('Xfile2')
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
354 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
355
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
356 " Test for running the :sball command with a maximum window count and a
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
357 " modified buffer
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
358 func Test_sball_with_count()
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
359 %bw!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
360 edit Xfile1
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
361 call setline(1, ['abc'])
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
362 new Xfile2
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
363 new Xfile3
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
364 new Xfile4
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
365 2sball
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
366 call assert_equal(bufnr('Xfile4'), winbufnr(1))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
367 call assert_equal(bufnr('Xfile1'), winbufnr(2))
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
368 call assert_equal(0, getbufinfo('Xfile2')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
369 call assert_equal(0, getbufinfo('Xfile3')[0].loaded)
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
370 %bw!
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
371 endfunc
55b3849ded11 patch 8.2.1046: insufficient tests for src/buffer.c
Bram Moolenaar <Bram@vim.org>
parents: 20041
diff changeset
372
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 " vim: shiftwidth=2 sts=2 expandtab