diff options
Diffstat (limited to 'src/nvim/testdir/test_functions.vim')
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 46c2d0f4cd..ed9c70403e 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1076,3 +1076,67 @@ func Test_func_sandbox() call assert_fails('call Fsandbox()', 'E48:') delfunc Fsandbox endfunc + +" Test for reg_recording() and reg_executing() +func Test_reg_executing_and_recording() + let s:reg_stat = '' + func s:save_reg_stat() + let s:reg_stat = reg_recording() . ':' . reg_executing() + return '' + endfunc + + new + call s:save_reg_stat() + call assert_equal(':', s:reg_stat) + call feedkeys("qa\"=s:save_reg_stat()\<CR>pq", 'xt') + call assert_equal('a:', s:reg_stat) + call feedkeys("@a", 'xt') + call assert_equal(':a', s:reg_stat) + call feedkeys("qb@aq", 'xt') + call assert_equal('b:a', s:reg_stat) + call feedkeys("q\"\"=s:save_reg_stat()\<CR>pq", 'xt') + call assert_equal('":', s:reg_stat) + + " :normal command saves and restores reg_executing + let s:reg_stat = '' + + " getchar() command saves and restores reg_executing + map W :call TestFunc()<CR> + let @q = "W" + let g:typed = '' + let g:regs = [] + func TestFunc() abort + let g:regs += [reg_executing()] + let g:typed = getchar(0) + let g:regs += [reg_executing()] + endfunc + call feedkeys("@qy", 'xt') + call assert_equal(char2nr("y"), g:typed) + call assert_equal(['q', 'q'], g:regs) + delfunc TestFunc + unmap W + unlet g:typed + unlet g:regs + + " input() command saves and restores reg_executing + map W :call TestFunc()<CR> + let @q = "W" + let g:typed = '' + let g:regs = [] + func TestFunc() abort + let g:regs += [reg_executing()] + let g:typed = input('?') + let g:regs += [reg_executing()] + endfunc + call feedkeys("@qy\<CR>", 'xt') + call assert_equal("y", g:typed) + call assert_equal(['q', 'q'], g:regs) + delfunc TestFunc + unmap W + unlet g:typed + unlet g:regs + + bwipe! + delfunc s:save_reg_stat + unlet s:reg_stat +endfunc |