Skip to content

Commit

Permalink
vim-patch:9.0.1779: Need more state() tests (neovim#24840)
Browse files Browse the repository at this point in the history
Problem:  Need more state() tests
Solution: Add a few more tests for operater pending mode and register
          yank command

closes: vim/vim#12883

vim/vim@8dabccd
  • Loading branch information
zeertzjq authored Aug 22, 2023
1 parent 20f76eb commit 6462ee1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/functional/vimscript/state_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local poke_eventloop = helpers.poke_eventloop
before_each(clear)

describe('state() function', function()
-- oldtest: Test_state()
it('works', function()
meths.ui_attach(80, 24, {}) -- Allow hit-enter-prompt

Expand Down Expand Up @@ -51,6 +52,20 @@ describe('state() function', function()
feed(';')
eq({ 'mS', 'n' }, exec_lua('return _G.res'))

-- An operator is pending
feed([[:call RunTimer()<CR>y]])
poke_eventloop() -- Process pending input
poke_eventloop() -- Process time_event
feed('y')
eq({ 'oSc', 'n' }, exec_lua('return _G.res'))

-- A register was specified
feed([[:call RunTimer()<CR>"r]])
poke_eventloop() -- Process pending input
poke_eventloop() -- Process time_event
feed('yy')
eq({ 'oSc', 'n' }, exec_lua('return _G.res'))

-- Insert mode completion
feed([[:call RunTimer()<CR>Got<C-N>]])
poke_eventloop() -- Process pending input
Expand Down
14 changes: 14 additions & 0 deletions test/old/testdir/test_functions.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2630,6 +2630,20 @@ func Test_state()
call term_sendkeys(buf, getstate)
call WaitForAssert({-> assert_match('state: mSc; mode: n', term_getline(buf, 6))}, 1000)

" A operator is pending
call term_sendkeys(buf, ":call RunTimer()\<CR>y")
call TermWait(buf, 25)
call term_sendkeys(buf, "y")
call term_sendkeys(buf, getstate)
call WaitForAssert({-> assert_match('state: oSc; mode: n', term_getline(buf, 6))}, 1000)

" A register was specified
call term_sendkeys(buf, ":call RunTimer()\<CR>\"r")
call TermWait(buf, 25)
call term_sendkeys(buf, "yy")
call term_sendkeys(buf, getstate)
call WaitForAssert({-> assert_match('state: oSc; mode: n', term_getline(buf, 6))}, 1000)

" Insert mode completion (bit slower on Mac)
call term_sendkeys(buf, ":call RunTimer()\<CR>Got\<C-N>")
call TermWait(buf, 25)
Expand Down

0 comments on commit 6462ee1

Please sign in to comment.