aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_functions.vim
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-01-01 18:36:36 +0100
committerGitHub <noreply@github.com>2018-01-01 18:36:36 +0100
commit95a8af093fdd543f8617f7fee27740eedd7c811a (patch)
treef9bbd1b4948e2abfe3d559e4ccc2040ca3ad9489 /src/nvim/testdir/test_functions.vim
parent1d8c612f788b1a5c8d74814db4654462e0224831 (diff)
parentc5f9762b7e40d23e6a0cfc8f808761a084223859 (diff)
downloadrneovim-95a8af093fdd543f8617f7fee27740eedd7c811a.tar.gz
rneovim-95a8af093fdd543f8617f7fee27740eedd7c811a.tar.bz2
rneovim-95a8af093fdd543f8617f7fee27740eedd7c811a.zip
Merge #7800 'vim patches'
Diffstat (limited to 'src/nvim/testdir/test_functions.vim')
-rw-r--r--src/nvim/testdir/test_functions.vim42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 0ce034b63e..398e9ab331 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -311,3 +311,45 @@ func! Test_mode()
bwipe!
iunmap <F2>
endfunc
+
+func Test_getbufvar()
+ let bnr = bufnr('%')
+ let b:var_num = '1234'
+ let def_num = '5678'
+ call assert_equal('1234', getbufvar(bnr, 'var_num'))
+ call assert_equal('1234', getbufvar(bnr, 'var_num', def_num))
+
+ let bd = getbufvar(bnr, '')
+ call assert_equal('1234', bd['var_num'])
+ call assert_true(exists("bd['changedtick']"))
+ call assert_equal(2, len(bd))
+
+ let bd2 = getbufvar(bnr, '', def_num)
+ call assert_equal(bd, bd2)
+
+ unlet b:var_num
+ call assert_equal(def_num, getbufvar(bnr, 'var_num', def_num))
+ call assert_equal('', getbufvar(bnr, 'var_num'))
+
+ let bd = getbufvar(bnr, '')
+ call assert_equal(1, len(bd))
+ let bd = getbufvar(bnr, '',def_num)
+ call assert_equal(1, len(bd))
+
+ call assert_equal('', getbufvar(9999, ''))
+ call assert_equal(def_num, getbufvar(9999, '', def_num))
+ unlet def_num
+
+ call assert_equal(0, getbufvar(bnr, '&autoindent'))
+ call assert_equal(0, getbufvar(bnr, '&autoindent', 1))
+
+ " Open new window with forced option values
+ set fileformats=unix,dos
+ new ++ff=dos ++bin ++enc=iso-8859-2
+ call assert_equal('dos', getbufvar(bufnr('%'), '&fileformat'))
+ call assert_equal(1, getbufvar(bufnr('%'), '&bin'))
+ call assert_equal('iso-8859-2', getbufvar(bufnr('%'), '&fenc'))
+ close
+
+ set fileformats&
+endfunc