aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2019-07-06 17:02:26 +0900
committerShougo Matsushita <Shougo.Matsu@gmail.com>2019-07-06 17:09:56 +0900
commit3f6346b73265d22b2a2baeedb1e0575938fea727 (patch)
treeb03149631cb804b9dc4bd6dd19dfaaf80a9eb119 /src/nvim/testdir
parent3c860e25e909531954af31c832816fa22ec835e7 (diff)
downloadrneovim-3f6346b73265d22b2a2baeedb1e0575938fea727.tar.gz
rneovim-3f6346b73265d22b2a2baeedb1e0575938fea727.tar.bz2
rneovim-3f6346b73265d22b2a2baeedb1e0575938fea727.zip
vim-patch:8.1.1610: there is no way to add or load a buffer without side effects
Problem: There is no way to add or load a buffer without side effects. Solution: Add the bufadd() and bufload() functions. https://github.com/vim/vim/commit/15e248e37f3925d430f96e945d52d3dc423cdc83
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_functions.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 0c3c356622..64f1c0abd9 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -1188,3 +1188,31 @@ func Test_libcall_libcallnr()
call assert_fails("call libcall('Xdoesnotexist_', 'getenv', 'HOME')", 'E364:')
call assert_fails("call libcallnr('Xdoesnotexist_', 'strlen', 'abcd')", 'E364:')
endfunc
+
+func Test_bufadd_bufload()
+ call assert_equal(0, bufexists('someName'))
+ let buf = bufadd('someName')
+ call assert_notequal(0, buf)
+ call assert_equal(1, bufexists('someName'))
+ call assert_equal(0, getbufvar(buf, '&buflisted'))
+ call assert_equal(0, bufloaded(buf))
+ call bufload(buf)
+ call assert_equal(1, bufloaded(buf))
+ call assert_equal([''], getbufline(buf, 1, '$'))
+
+ let curbuf = bufnr('')
+ call writefile(['some', 'text'], 'otherName')
+ let buf = bufadd('otherName')
+ call assert_notequal(0, buf)
+ call assert_equal(1, bufexists('otherName'))
+ call assert_equal(0, getbufvar(buf, '&buflisted'))
+ call assert_equal(0, bufloaded(buf))
+ call bufload(buf)
+ call assert_equal(1, bufloaded(buf))
+ call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
+ call assert_equal(curbuf, bufnr(''))
+
+ bwipe someName
+ bwipe otherName
+ call assert_equal(0, bufexists('someName'))
+endfunc