" Tests for mappings and abbreviations
source shared.vim
source check.vim
source screendump.vim
source term_util.vim
func Test_abbreviation()
" abbreviation with 0x80 should work
inoreab чкпр vim
call feedkeys("Goчкпр \<Esc>", "xt")
call assert_equal('vim ', getline('$'))
iunab чкпр
set nomodified
endfunc
func Test_abclear()
abbrev foo foobar
iabbrev fooi foobari
cabbrev fooc foobarc
call assert_equal("\n\n"
\ .. "c fooc foobarc\n"
\ .. "i fooi foobari\n"
\ .. "! foo foobar", execute('abbrev'))
iabclear
call assert_equal("\n\n"
\ .. "c fooc foobarc\n"
\ .. "c foo foobar", execute('abbrev'))
abbrev foo foobar
iabbrev fooi foobari
cabclear
call assert_equal("\n\n"
\ .. "i fooi foobari\n"
\ .. "i foo foobar", execute('abbrev'))
abbrev foo foobar
cabbrev fooc foobarc
abclear
call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
call assert_fails('%abclear', 'E481:')
endfunc
func Test_abclear_buffer()
abbrev foo foobar
new X1
abbrev <buffer> foo1 foobar1
new X2
abbrev <buffer> foo2 foobar2
call assert_equal("\n\n"
\ .. "! foo2 @foobar2\n"
\ .. "! foo foobar", execute('abbrev'))
abclear <buffer>
call assert_equal("\n\n"
\ .. "! foo foobar", execute('abbrev'))
b X1
call assert_equal("\n\n"
\ .. "! foo1 @foobar1\n"
\ .. "! foo foobar", execute('abbrev'))
abclear <buffer>
call assert_equal("\n\n"
\ .. "! foo foobar", execute('abbrev'))
abclear
call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
%bwipe
endfunc
func Test_map_ctrl_c_insert()
" mapping of ctrl-c in Insert mode
set cpo-=< cpo-=k
inoremap <c-c> <ctrl-c>
cnoremap <c-c> dummy
cunmap <c-c>
call feedkeys("GoTEST2: CTRL-C |\<*C-C>A|\<Esc>", "xt")
call assert_equal('TEST2: CTRL-C |<ctrl-c>A|', getline('$'))
unmap! <c-c>
set nomodified
e