blob: fb64711863050844aaeadd0c2c725f14c3d28595 [file] [log] [blame]
Bram Moolenaar74c5bbf2016-03-10 22:19:53 +01001" Test feedkeys() function.
2
3func Test_feedkeys_x_with_empty_string()
4 new
5 call feedkeys("ifoo\<Esc>")
6 call assert_equal('', getline('.'))
7 call feedkeys('', 'x')
8 call assert_equal('foo', getline('.'))
Bram Moolenaar9bd547a2016-04-01 21:00:48 +02009
10 " check it goes back to normal mode immediately.
11 call feedkeys('i', 'x')
12 call assert_equal('foo', getline('.'))
Bram Moolenaar74c5bbf2016-03-10 22:19:53 +010013 quit!
14endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020015
Bram Moolenaarb37a65e2022-01-01 12:42:56 +000016func Test_feedkeys_with_abbreviation()
17 new
18 inoreabbrev trigger value
19 call feedkeys("atrigger ", 'x')
20 call feedkeys("atrigger ", 'x')
21 call assert_equal('value value ', getline(1))
22 bwipe!
23 iunabbrev trigger
24endfunc
25
zeertzjqdb088872022-05-02 22:53:45 +010026func Test_feedkeys_escape_special()
27 nnoremap <Cmd>let g:got_ellipsis += 1<CR>
28 call feedkeys('…', 't')
29 call assert_equal('…', getcharstr())
30 let g:got_ellipsis = 0
31 call feedkeys('…', 'xt')
32 call assert_equal(1, g:got_ellipsis)
33 unlet g:got_ellipsis
34 nunmap
35endfunc
36
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020037" vim: shiftwidth=2 sts=2 expandtab