comparison src/testdir/test_history.vim @ 8406:5d926807c19c v7.4.1494

commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 5 21:21:24 2016 +0100 patch 7.4.1494 Problem: clr_history() does not work properly. Solution: Increment hisptr. Add a test. (Yegappan Lakshmanan)
author Christian Brabandt <cb@256bit.org>
date Sat, 05 Mar 2016 21:30:05 +0100
parents
children f3bb76ec4155
comparison
equal deleted inserted replaced
8405:c440e8a53d6c 8406:5d926807c19c
1 " Tests for the history functions
2
3 if !has('cmdline_hist')
4 finish
5 endif
6
7 set history=7
8
9 function History_Tests(hist)
10 " First clear the history
11 call histadd(a:hist, 'dummy')
12 call assert_true(histdel(a:hist))
13 call assert_equal(-1, histnr(a:hist))
14 call assert_equal('', histget(a:hist))
15
16 call assert_true(histadd(a:hist, 'ls'))
17 call assert_true(histadd(a:hist, 'buffers'))
18 call assert_equal('buffers', histget(a:hist))
19 call assert_equal('ls', histget(a:hist, -2))
20 call assert_equal('ls', histget(a:hist, 1))
21 call assert_equal('', histget(a:hist, 5))
22 call assert_equal('', histget(a:hist, -5))
23 call assert_equal(2, histnr(a:hist))
24 call assert_true(histdel(a:hist, 2))
25 call assert_false(histdel(a:hist, 7))
26 call assert_equal(1, histnr(a:hist))
27 call assert_equal('ls', histget(a:hist, -1))
28
29 call assert_true(histadd(a:hist, 'buffers'))
30 call assert_true(histadd(a:hist, 'ls'))
31 call assert_equal('ls', histget(a:hist, -1))
32 call assert_equal(4, histnr(a:hist))
33
34 " Test for removing entries matching a pattern
35 for i in range(1, 3)
36 call histadd(a:hist, 'text_' . i)
37 endfor
38 call assert_true(histdel(a:hist, 'text_\d\+'))
39 call assert_equal('ls', histget(a:hist, -1))
40
41 " Test for freeing the entire history list
42 for i in range(1, 7)
43 call histadd(a:hist, 'text_' . i)
44 endfor
45 call histdel(a:hist)
46 for i in range(1, 7)
47 call assert_equal('', histget(a:hist, i))
48 call assert_equal('', histget(a:hist, i - 7 - 1))
49 endfor
50 endfunction
51
52 function Test_History()
53 for h in ['cmd', ':', '', 'search', '/', '?', 'expr', '=', 'input', '@', 'debug', '>']
54 call History_Tests(h)
55 endfor
56
57 " Negative tests
58 call assert_false(histdel('abc'))
59 call assert_equal('', histget('abc'))
60 call assert_fails('call histdel([])', 'E730:')
61 call assert_equal('', histget(10))
62 call assert_fails('call histget([])', 'E730:')
63 call assert_equal(-1, histnr('abc'))
64 call assert_fails('call histnr([])', 'E730:')
65 endfunction