annotate src/testdir/test_quickfix.vim @ 7677:85a7a945fb87 v7.4.1137

commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 19 14:51:54 2016 +0100 patch 7.4.1137 Problem: Illegal memory access when using :copen and :cclose. Solution: Avoid that curbuf is invalid. (suggestion by Justin M. Keyes) Add a test.
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Jan 2016 15:00:06 +0100
parents 87e607fb6853
children bf58e9f8d52a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7502
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for the quickfix commands.
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 if !has('quickfix')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endif
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " Tests for the :clist and :llist commands
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 function XlistTests(cchar)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let Xlist = a:cchar . 'list'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let Xgetexpr = a:cchar . 'getexpr'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " With an empty list, command should return error
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 exe Xgetexpr . ' []'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 exe 'silent! ' . Xlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_true(v:errmsg ==# 'E42: No Errors')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 " Populate the list and then try
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 \ 'non-error 2', 'Xtestfile2:2:2:Line2',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 \ 'non-error 3', 'Xtestfile3:3:1:Line3']"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 " List only valid entries
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 redir => result
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 exe Xlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 redir END
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 let l = split(result, "\n")
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 \ ' 4 Xtestfile2:2 col 2: Line2',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 \ ' 6 Xtestfile3:3 col 1: Line3'], l)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 " List all the entries
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 redir => result
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 exe Xlist . "!"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 redir END
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 let l = split(result, "\n")
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 \ ' 5: non-error 3', ' 6 Xtestfile3:3 col 1: Line3'], l)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 " List a range of errors
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 redir => result
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 exe Xlist . " 3,6"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 redir END
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 let l = split(result, "\n")
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call assert_equal([' 4 Xtestfile2:2 col 2: Line2',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 \ ' 6 Xtestfile3:3 col 1: Line3'], l)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 redir => result
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 exe Xlist . "! 3,4"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 redir END
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 let l = split(result, "\n")
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 redir => result
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 exe Xlist . " -6,-4"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 redir END
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 let l = split(result, "\n")
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 redir => result
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 exe Xlist . "! -5,-3"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 redir END
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 let l = split(result, "\n")
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 function Test_clist()
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call XlistTests('c')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call XlistTests('l')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 " Tests for the :colder, :cnewer, :lolder and :lnewer commands
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 " Note that this test assumes that a quickfix/location list is
7540
b910bb01832a commit https://github.com/vim/vim/commit/cfc0a350a9fa04f1b0cfa1ba31fbd2847376513f
Christian Brabandt <cb@256bit.org>
parents: 7513
diff changeset
75 " already set by the caller.
7502
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 function XageTests(cchar)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 let Xolder = a:cchar . 'older'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 let Xnewer = a:cchar . 'newer'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 let Xgetexpr = a:cchar . 'getexpr'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 if a:cchar == 'c'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 let Xgetlist = 'getqflist()'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 else
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 let Xgetlist = 'getloclist(0)'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 endif
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 " Jumping to a non existent list should return error
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 exe 'silent! ' . Xolder . ' 99'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 call assert_true(v:errmsg ==# 'E380: At bottom of quickfix stack')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 exe 'silent! ' . Xnewer . ' 99'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 call assert_true(v:errmsg ==# 'E381: At top of quickfix stack')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 " Add three quickfix/location lists
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 exe Xgetexpr . " ['Xtestfile1:1:3:Line1']"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 exe Xgetexpr . " ['Xtestfile2:2:2:Line2']"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 exe Xgetexpr . " ['Xtestfile3:3:1:Line3']"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 " Go back two lists
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 exe Xolder
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 call assert_equal('Line2', l[0].text)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 " Go forward two lists
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 exe Xnewer
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 call assert_equal('Line3', l[0].text)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 " Test for the optional count argument
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 exe Xolder . ' 2'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 call assert_equal('Line1', l[0].text)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 exe Xnewer . ' 2'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 call assert_equal('Line3', l[0].text)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 function Test_cage()
7540
b910bb01832a commit https://github.com/vim/vim/commit/cfc0a350a9fa04f1b0cfa1ba31fbd2847376513f
Christian Brabandt <cb@256bit.org>
parents: 7513
diff changeset
119 let list = [{'bufnr': 1, 'lnum': 1}]
b910bb01832a commit https://github.com/vim/vim/commit/cfc0a350a9fa04f1b0cfa1ba31fbd2847376513f
Christian Brabandt <cb@256bit.org>
parents: 7513
diff changeset
120 call setqflist(list)
7502
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 call XageTests('c')
7540
b910bb01832a commit https://github.com/vim/vim/commit/cfc0a350a9fa04f1b0cfa1ba31fbd2847376513f
Christian Brabandt <cb@256bit.org>
parents: 7513
diff changeset
122
b910bb01832a commit https://github.com/vim/vim/commit/cfc0a350a9fa04f1b0cfa1ba31fbd2847376513f
Christian Brabandt <cb@256bit.org>
parents: 7513
diff changeset
123 call setloclist(0, list)
7502
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 call XageTests('l')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 " Tests for the :cwindow, :lwindow :cclose, :lclose, :copen and :lopen
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 " commands
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 function XwindowTests(cchar)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 let Xwindow = a:cchar . 'window'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 let Xclose = a:cchar . 'close'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 let Xopen = a:cchar . 'open'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 let Xgetexpr = a:cchar . 'getexpr'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 " Create a list with no valid entries
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 " Quickfix/Location window should not open with no valid errors
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 exe Xwindow
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 call assert_true(winnr('$') == 1)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 " Create a list with valid entries
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 exe Xgetexpr . " ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 \ 'Xtestfile3:3:1:Line3']"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 " Open the window
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 exe Xwindow
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 call assert_true(winnr('$') == 2 && winnr() == 2 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 \ getline('.') ==# 'Xtestfile1|1 col 3| Line1')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 " Close the window
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 exe Xclose
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 call assert_true(winnr('$') == 1)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 " Create a list with no valid entries
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 " Open the window
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 exe Xopen . ' 5'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 call assert_true(winnr('$') == 2 && getline('.') ==# '|| non-error 1'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 \ && winheight('.') == 5)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 " Opening the window again, should move the cursor to that window
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 wincmd t
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 exe Xopen . ' 7'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 call assert_true(winnr('$') == 2 && winnr() == 2 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 \ winheight('.') == 7 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 \ getline('.') ==# '|| non-error 1')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 " Calling cwindow should close the quickfix window with no valid errors
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 exe Xwindow
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 call assert_true(winnr('$') == 1)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 function Test_cwindow()
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 call XwindowTests('c')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 call XwindowTests('l')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 " Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 " commands.
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 function XfileTests(cchar)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 let Xfile = a:cchar . 'file'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 let Xgetfile = a:cchar . 'getfile'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 let Xaddfile = a:cchar . 'addfile'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 if a:cchar == 'c'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 let Xgetlist = 'getqflist()'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 else
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 let Xgetlist = 'getloclist(0)'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 endif
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 call writefile(['Xtestfile1:700:10:Line 700',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 \ 'Xtestfile2:800:15:Line 800'], 'Xqftestfile1')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 enew!
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 exe Xfile . ' Xqftestfile1'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 call assert_true(len(l) == 2 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 " Run cfile/lfile from a modified buffer
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 enew!
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 silent! put ='Quickfix'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 exe 'silent! ' . Xfile . ' Xqftestfile1'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 call assert_true(v:errmsg ==# 'E37: No write since last change (add ! to override)')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 exe Xaddfile . ' Xqftestfile1'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 call assert_true(len(l) == 3 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 \ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 call writefile(['Xtestfile1:222:77:Line 222',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 \ 'Xtestfile2:333:88:Line 333'], 'Xqftestfile1')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 enew!
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 exe Xgetfile . ' Xqftestfile1'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 call assert_true(len(l) == 2 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 \ l[0].lnum == 222 && l[0].col == 77 && l[0].text ==# 'Line 222' &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 \ l[1].lnum == 333 && l[1].col == 88 && l[1].text ==# 'Line 333')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 call delete('Xqftestfile1')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 function Test_cfile()
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 call XfileTests('c')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 call XfileTests('l')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 " Tests for the :cbuffer, :lbuffer, :caddbuffer, :laddbuffer, :cgetbuffer and
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 " :lgetbuffer commands.
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 function XbufferTests(cchar)
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 let Xbuffer = a:cchar . 'buffer'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 let Xgetbuffer = a:cchar . 'getbuffer'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 let Xaddbuffer = a:cchar . 'addbuffer'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 if a:cchar == 'c'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 let Xgetlist = 'getqflist()'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 else
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 let Xgetlist = 'getloclist(0)'
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243 endif
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245 enew!
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 silent! call setline(1, ['Xtestfile7:700:10:Line 700',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 \ 'Xtestfile8:800:15:Line 800'])
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 exe Xbuffer . "!"
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 call assert_true(len(l) == 2 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 enew!
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 silent! call setline(1, ['Xtestfile9:900:55:Line 900',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 \ 'Xtestfile10:950:66:Line 950'])
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 exe Xgetbuffer
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 call assert_true(len(l) == 2 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 \ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 enew!
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 silent! call setline(1, ['Xtestfile11:700:20:Line 700',
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 \ 'Xtestfile12:750:25:Line 750'])
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 exe Xaddbuffer
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 exe 'let l = ' . Xgetlist
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 call assert_true(len(l) == 4 &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' &&
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 function Test_cbuffer()
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 call XbufferTests('c')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 call XbufferTests('l')
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 endfunction
3e306ae760d0 commit https://github.com/vim/vim/commit/da59dd5da6440c3410866ed61ce169a2012ba5bd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279
7513
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
280 function Test_nomem()
7545
4c922651fd78 commit https://github.com/vim/vim/commit/28fb79db6b52d1154e8dc63d227673648c2fce15
Christian Brabandt <cb@256bit.org>
parents: 7540
diff changeset
281 call alloc_fail(GetAllocId('qf_dirname_start'), 0, 0)
7593
87e607fb6853 commit https://github.com/vim/vim/commit/a260b87d9da17f605666630f18c1ed909c2b8bae
Christian Brabandt <cb@256bit.org>
parents: 7545
diff changeset
282 call assert_fails('vimgrep vim runtest.vim', 'E342:')
7513
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
283
7545
4c922651fd78 commit https://github.com/vim/vim/commit/28fb79db6b52d1154e8dc63d227673648c2fce15
Christian Brabandt <cb@256bit.org>
parents: 7540
diff changeset
284 call alloc_fail(GetAllocId('qf_dirname_now'), 0, 0)
7593
87e607fb6853 commit https://github.com/vim/vim/commit/a260b87d9da17f605666630f18c1ed909c2b8bae
Christian Brabandt <cb@256bit.org>
parents: 7545
diff changeset
285 call assert_fails('vimgrep vim runtest.vim', 'E342:')
7513
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
286
7545
4c922651fd78 commit https://github.com/vim/vim/commit/28fb79db6b52d1154e8dc63d227673648c2fce15
Christian Brabandt <cb@256bit.org>
parents: 7540
diff changeset
287 call alloc_fail(GetAllocId('qf_namebuf'), 0, 0)
7593
87e607fb6853 commit https://github.com/vim/vim/commit/a260b87d9da17f605666630f18c1ed909c2b8bae
Christian Brabandt <cb@256bit.org>
parents: 7545
diff changeset
288 call assert_fails('cfile runtest.vim', 'E342:')
7513
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
289
7545
4c922651fd78 commit https://github.com/vim/vim/commit/28fb79db6b52d1154e8dc63d227673648c2fce15
Christian Brabandt <cb@256bit.org>
parents: 7540
diff changeset
290 call alloc_fail(GetAllocId('qf_errmsg'), 0, 0)
7593
87e607fb6853 commit https://github.com/vim/vim/commit/a260b87d9da17f605666630f18c1ed909c2b8bae
Christian Brabandt <cb@256bit.org>
parents: 7545
diff changeset
291 call assert_fails('cfile runtest.vim', 'E342:')
7513
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
292
7545
4c922651fd78 commit https://github.com/vim/vim/commit/28fb79db6b52d1154e8dc63d227673648c2fce15
Christian Brabandt <cb@256bit.org>
parents: 7540
diff changeset
293 call alloc_fail(GetAllocId('qf_pattern'), 0, 0)
7593
87e607fb6853 commit https://github.com/vim/vim/commit/a260b87d9da17f605666630f18c1ed909c2b8bae
Christian Brabandt <cb@256bit.org>
parents: 7545
diff changeset
294 call assert_fails('cfile runtest.vim', 'E342:')
7513
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
295
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
296 endfunc
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
297
7677
85a7a945fb87 commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents: 7593
diff changeset
298 function Test_helpgrep()
85a7a945fb87 commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents: 7593
diff changeset
299 helpgrep quickfix
85a7a945fb87 commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents: 7593
diff changeset
300 copen
85a7a945fb87 commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents: 7593
diff changeset
301 " This wipes out the buffer, make sure that doesn't cause trouble.
85a7a945fb87 commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents: 7593
diff changeset
302 cclose
85a7a945fb87 commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents: 7593
diff changeset
303 endfunc
7513
37e061ec063c commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422
Christian Brabandt <cb@256bit.org>
parents: 7502
diff changeset
304