diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-07-29 00:34:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-29 00:34:47 +0200 |
| commit | 4213492231cc9b3ae900657d8ab88039f2f4eb91 (patch) | |
| tree | 05fc2e328a39d522146b09095289d3021d9b0314 /src/nvim/testdir/test_getvar.vim | |
| parent | 00d915d02159037634f0f9628400648cc14da871 (diff) | |
| parent | b457a58e34d43d49a01dd93ec356099d232bd713 (diff) | |
| download | rneovim-4213492231cc9b3ae900657d8ab88039f2f4eb91.tar.gz rneovim-4213492231cc9b3ae900657d8ab88039f2f4eb91.tar.bz2 rneovim-4213492231cc9b3ae900657d8ab88039f2f4eb91.zip | |
Merge #10643 from janlazo/vim-8.1.1765
vim-patch:8.1.{990,992,1765}
Diffstat (limited to 'src/nvim/testdir/test_getvar.vim')
| -rw-r--r-- | src/nvim/testdir/test_getvar.vim | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_getvar.vim b/src/nvim/testdir/test_getvar.vim index d6b6b69aa8..3b61d68ebc 100644 --- a/src/nvim/testdir/test_getvar.vim +++ b/src/nvim/testdir/test_getvar.vim @@ -1,4 +1,5 @@ -" Tests for getwinvar(), gettabvar() and gettabwinvar(). +" Tests for getwinvar(), gettabvar(), gettabwinvar() and get(). + func Test_var() " Use strings to test for memory leaks. First, check that in an empty " window, gettabvar() returns the correct value @@ -102,3 +103,44 @@ func Test_gettabvar_in_tabline() close redrawstatus! endfunc + +" Test get() function using default value. + +" get({dict}, {key} [, {default}]) +func Test_get_dict() + let d = {'foo': 42} + call assert_equal(42, get(d, 'foo', 99)) + call assert_equal(999, get(d, 'bar', 999)) +endfunc + +" get({list}, {idx} [, {default}]) +func Test_get_list() + let l = [1,2,3] + call assert_equal(1, get(l, 0, 999)) + call assert_equal(3, get(l, -1, 999)) + call assert_equal(999, get(l, 3, 999)) +endfunc + +" get({blob}, {idx} [, {default}]) - in test_blob.vim + +" get({lambda}, {what} [, {default}]) +func Test_get_lambda() + let l:L = {-> 42} + call assert_match('^<lambda>', get(l:L, 'name')) + call assert_equal(l:L, get(l:L, 'func')) + call assert_equal({'lambda has': 'no dict'}, get(l:L, 'dict', {'lambda has': 'no dict'})) + call assert_equal(0, get(l:L, 'dict')) + call assert_equal([], get(l:L, 'args')) +endfunc + +" get({func}, {what} [, {default}]) +func Test_get_func() + let l:F = function('tr') + call assert_equal('tr', get(l:F, 'name')) + call assert_equal(l:F, get(l:F, 'func')) + call assert_equal({'func has': 'no dict'}, get(l:F, 'dict', {'func has': 'no dict'})) + call assert_equal(0, get(l:F, 'dict')) + call assert_equal([], get(l:F, 'args')) +endfunc + +" get({partial}, {what} [, {default}]) - in test_partial.vim |