Mercurial > vim
view src/testdir/test_history.vim @ 10960:d7b78cbf85e4 v8.0.0369
patch 8.0.0369: a few options are not defined, depending on features
commit https://github.com/vim/vim/commit/c43a8b8de0676caf8a460b6af1310d7aba8221bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 25 21:12:29 2017 +0100
patch 8.0.0369: a few options are not defined, depending on features
Problem: The 'balloondelay', 'ballooneval' and 'balloonexpr' options are
not defined without the +balloon_eval feature. Testing that an
option value fails does not work for unsupported options.
Solution: Make the options defined but not supported. Don't test if
setting unsupported options fails.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 25 Feb 2017 21:15:03 +0100 |
parents | ea0dadb041c9 |
children | 1946487c74ba |
line wrap: on
line source
" Tests for the history functions if !has('cmdline_hist') finish endif set history=7 function History_Tests(hist) " First clear the history call histadd(a:hist, 'dummy') call assert_true(histdel(a:hist)) call assert_equal(-1, histnr(a:hist)) call assert_equal('', histget(a:hist)) call assert_true(histadd(a:hist, 'ls')) call assert_true(histadd(a:hist, 'buffers')) call assert_equal('buffers', histget(a:hist)) call assert_equal('ls', histget(a:hist, -2)) call assert_equal('ls', histget(a:hist, 1)) call assert_equal('', histget(a:hist, 5)) call assert_equal('', histget(a:hist, -5)) call assert_equal(2, histnr(a:hist)) call assert_true(histdel(a:hist, 2)) call assert_false(histdel(a:hist, 7)) call assert_equal(1, histnr(a:hist)) call assert_equal('ls', histget(a:hist, -1)) call assert_true(histadd(a:hist, 'buffers')) call assert_true(histadd(a:hist, 'ls')) call assert_equal('ls', histget(a:hist, -1)) call assert_equal(4, histnr(a:hist)) let a=execute('history ' . a:hist) call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a) let a=execute('history all') call assert_match("^\n # .* history\n 3 buffers\n> 4 ls", a) if len(a:hist) > 0 let a=execute('history ' . a:hist . ' 2') call assert_match("^\n # \\S* history$", a) let a=execute('history ' . a:hist . ' 3') call assert_match("^\n # \\S* history\n 3 buffers$", a) let a=execute('history ' . a:hist . ' 4') call assert_match("^\n # \\S* history\n> 4 ls$", a) let a=execute('history ' . a:hist . ' 3,4') call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a) let a=execute('history ' . a:hist . ' -1') call assert_match("^\n # \\S* history\n> 4 ls$", a) let a=execute('history ' . a:hist . ' -2') call assert_match("^\n # \\S* history\n 3 buffers$", a) let a=execute('history ' . a:hist . ' -2,') call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a) let a=execute('history ' . a:hist . ' -3') call assert_match("^\n # \\S* history$", a) endif " Test for removing entries matching a pattern for i in range(1, 3) call histadd(a:hist, 'text_' . i) endfor call assert_true(histdel(a:hist, 'text_\d\+')) call assert_equal('ls', histget(a:hist, -1)) " Test for freeing the entire history list for i in range(1, 7) call histadd(a:hist, 'text_' . i) endfor call histdel(a:hist) for i in range(1, 7) call assert_equal('', histget(a:hist, i)) call assert_equal('', histget(a:hist, i - 7 - 1)) endfor endfunction function Test_History() for h in ['cmd', ':', '', 'search', '/', '?', 'expr', '=', 'input', '@', 'debug', '>'] call History_Tests(h) endfor " Negative tests call assert_false(histdel('abc')) call assert_equal('', histget('abc')) call assert_fails('call histdel([])', 'E730:') call assert_equal('', histget(10)) call assert_fails('call histget([])', 'E730:') call assert_equal(-1, histnr('abc')) call assert_fails('call histnr([])', 'E730:') endfunction function Test_Search_history_window() new call setline(1, ['a', 'b', 'a', 'b']) 1 call feedkeys("/a\<CR>", 'xt') call assert_equal('a', getline('.')) 1 call feedkeys("/b\<CR>", 'xt') call assert_equal('b', getline('.')) 1 " select the previous /a command call feedkeys("q/kk\<CR>", 'x!') call assert_equal('a', getline('.')) call assert_equal('a', @/) bwipe! endfunc