annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8406
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the history functions
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 if !has('cmdline_hist')
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endif
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 set history=7
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 function History_Tests(hist)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 " First clear the history
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call histadd(a:hist, 'dummy')
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_true(histdel(a:hist))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal(-1, histnr(a:hist))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_equal('', histget(a:hist))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_true(histadd(a:hist, 'ls'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_true(histadd(a:hist, 'buffers'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_equal('buffers', histget(a:hist))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal('ls', histget(a:hist, -2))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal('ls', histget(a:hist, 1))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal('', histget(a:hist, 5))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal('', histget(a:hist, -5))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal(2, histnr(a:hist))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call assert_true(histdel(a:hist, 2))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_false(histdel(a:hist, 7))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call assert_equal(1, histnr(a:hist))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal('ls', histget(a:hist, -1))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call assert_true(histadd(a:hist, 'buffers'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_true(histadd(a:hist, 'ls'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal('ls', histget(a:hist, -1))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_equal(4, histnr(a:hist))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 " Test for removing entries matching a pattern
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 for i in range(1, 3)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call histadd(a:hist, 'text_' . i)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 endfor
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_true(histdel(a:hist, 'text_\d\+'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal('ls', histget(a:hist, -1))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 " Test for freeing the entire history list
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 for i in range(1, 7)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call histadd(a:hist, 'text_' . i)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 endfor
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call histdel(a:hist)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 for i in range(1, 7)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal('', histget(a:hist, i))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal('', histget(a:hist, i - 7 - 1))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endfor
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 endfunction
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 function Test_History()
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 for h in ['cmd', ':', '', 'search', '/', '?', 'expr', '=', 'input', '@', 'debug', '>']
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call History_Tests(h)
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 endfor
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " Negative tests
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_false(histdel('abc'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal('', histget('abc'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call assert_fails('call histdel([])', 'E730:')
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call assert_equal('', histget(10))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call assert_fails('call histget([])', 'E730:')
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal(-1, histnr('abc'))
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 call assert_fails('call histnr([])', 'E730:')
5d926807c19c commit https://github.com/vim/vim/commit/119d4693e06e68d4f099aa7287e375ae3d265fd0
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 endfunction