From 6462ee1c10f9f1aa66ffc4d4fe1b7b3d9f0f91af Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 23 Aug 2023 06:42:10 +0800 Subject: [PATCH] vim-patch:9.0.1779: Need more state() tests (#24840) Problem: Need more state() tests Solution: Add a few more tests for operater pending mode and register yank command closes: vim/vim#12883 https://github.com/vim/vim/commit/8dabccd295271104ad5af0abc48e283d644cff59 --- test/functional/vimscript/state_spec.lua | 15 +++++++++++++++ test/old/testdir/test_functions.vim | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua index 1acfb1337d..0508b8b1da 100644 --- a/test/functional/vimscript/state_spec.lua +++ b/test/functional/vimscript/state_spec.lua @@ -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 @@ -51,6 +52,20 @@ describe('state() function', function() feed(';') eq({ 'mS', 'n' }, exec_lua('return _G.res')) + -- An operator is pending + feed([[:call RunTimer()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()"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()Got]]) poke_eventloop() -- Process pending input diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index ca0066efca..37541c4af3 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -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()\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()\\"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()\Got\") call TermWait(buf, 25)