aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_functions.vim
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-05-27 12:01:35 +0200
committerGitHub <noreply@github.com>2019-05-27 12:01:35 +0200
commit69b3d5acd375e36a06474c6ebd2622cb0c2fcca5 (patch)
treef34ba1b9e0e138f86666e77280da66f6ca0687e3 /src/nvim/testdir/test_functions.vim
parentfb4d5a184678ab231da20ef559c8e423dfa54d6e (diff)
parent3c3b7844b95879bcfd86677df4cfac3edb0fb132 (diff)
downloadrneovim-69b3d5acd375e36a06474c6ebd2622cb0c2fcca5.tar.gz
rneovim-69b3d5acd375e36a06474c6ebd2622cb0c2fcca5.tar.bz2
rneovim-69b3d5acd375e36a06474c6ebd2622cb0c2fcca5.zip
Merge #10068 from janlazo/vim-8.1.0020
vim-patch:8.1.{20,995,1077}
Diffstat (limited to 'src/nvim/testdir/test_functions.vim')
-rw-r--r--src/nvim/testdir/test_functions.vim64
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