comparison src/testdir/test_history.vim @ 19517:738a4fe2c8c5 v8.2.0316

patch 8.2.0316: ex_getln.c code has insufficient test coverage Commit: https://github.com/vim/vim/commit/8d588ccee57390aa01c2395fc599bbe6506ee13a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 25 21:47:45 2020 +0100 patch 8.2.0316: ex_getln.c code has insufficient test coverage Problem: ex_getln.c code has insufficient test coverage. Solution: Add more tests. Fix a problem. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5693)
author Bram Moolenaar <Bram@vim.org>
date Tue, 25 Feb 2020 22:00:04 +0100
parents af3d441845cd
children bab20768e1fd
comparison
equal deleted inserted replaced
19516:209388e9e179 19517:738a4fe2c8c5
83 call assert_fails('call histdel([])', 'E730:') 83 call assert_fails('call histdel([])', 'E730:')
84 call assert_equal('', histget(10)) 84 call assert_equal('', histget(10))
85 call assert_fails('call histget([])', 'E730:') 85 call assert_fails('call histget([])', 'E730:')
86 call assert_equal(-1, histnr('abc')) 86 call assert_equal(-1, histnr('abc'))
87 call assert_fails('call histnr([])', 'E730:') 87 call assert_fails('call histnr([])', 'E730:')
88 call assert_fails('history xyz', 'E488:')
89 call assert_fails('history ,abc', 'E488:')
88 endfunction 90 endfunction
89 91
90 function Test_Search_history_window() 92 function Test_Search_history_window()
91 new 93 new
92 call setline(1, ['a', 'b', 'a', 'b']) 94 call setline(1, ['a', 'b', 'a', 'b'])
106 108
107 function Test_history_completion() 109 function Test_history_completion()
108 call feedkeys(":history \<C-A>\<C-B>\"\<CR>", 'tx') 110 call feedkeys(":history \<C-A>\<C-B>\"\<CR>", 'tx')
109 call assert_equal('"history / : = > ? @ all cmd debug expr input search', @:) 111 call assert_equal('"history / : = > ? @ all cmd debug expr input search', @:)
110 endfunc 112 endfunc
113
114 " Test for increasing the 'history' option value
115 func Test_history_size()
116 let save_histsz = &history
117 call histdel(':')
118 set history=5
119 for i in range(1, 5)
120 call histadd(':', 'cmd' .. i)
121 endfor
122 call assert_equal(5, histnr(':'))
123 call assert_equal('cmd5', histget(':', -1))
124
125 set history=10
126 for i in range(6, 10)
127 call histadd(':', 'cmd' .. i)
128 endfor
129 call assert_equal(10, histnr(':'))
130 call assert_equal('cmd1', histget(':', 1))
131 call assert_equal('cmd10', histget(':', -1))
132
133 set history=5
134 call histadd(':', 'abc')
135 call assert_equal('', histget(':', 6))
136 call assert_equal('', histget(':', 12))
137 call assert_equal('cmd7', histget(':', 7))
138 call assert_equal('abc', histget(':', -1))
139
140 let &history=save_histsz
141 endfunc
142
143 " Test for recalling old search patterns in /
144 func Test_history_search()
145 call histdel('/')
146 let g:pat = []
147 func SavePat()
148 call add(g:pat, getcmdline())
149 return ''
150 endfunc
151 cnoremap <F2> <C-\>eSavePat()<CR>
152 call histadd('/', 'pat1')
153 call histadd('/', 'pat2')
154 let @/ = ''
155 call feedkeys("/\<Up>\<F2>\<Up>\<F2>\<Down>\<Down>\<F2>\<Esc>", 'xt')
156 call assert_equal(['pat2', 'pat1', ''], g:pat)
157 cunmap <F2>
158 delfunc SavePat
159 endfunc
160
161 " vim: shiftwidth=2 sts=2 expandtab