Mercurial > vim
diff src/testdir/test_functions.vim @ 10889:5780bd3a5a7e v8.0.0334
patch 8.0.0334: can't access b:changedtick from a dict reference
commit https://github.com/vim/vim/commit/79518e2ace5fce7b9c49060e462a6e935dba0a84
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 17 16:31:35 2017 +0100
patch 8.0.0334: can't access b:changedtick from a dict reference
Problem: Can't access b:changedtick from a dict reference.
Solution: Make changedtick a member of the b: dict. (inspired by neovim
#6112)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 17 Feb 2017 16:45:05 +0100 |
parents | d66e5446cc48 |
children | c9d057b7a0ab |
line wrap: on
line diff
--- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -424,3 +424,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(9, '')) + call assert_equal(def_num, getbufvar(9, '', def_num)) + unlet def_num + + call assert_equal(0, getbufvar(1, '&autoindent')) + call assert_equal(0, getbufvar(1, '&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