aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c1
-rw-r--r--src/nvim/eval.h1
-rw-r--r--src/nvim/testdir/test_listdict.vim63
-rw-r--r--src/nvim/testdir/test_utf8.vim2
4 files changed, 66 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ed78bfbb24..b310fd49b0 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -229,6 +229,7 @@ static struct vimvar {
// Neovim
VV(VV_STDERR, "stderr", VAR_NUMBER, VV_RO),
VV(VV_MSGPACK_TYPES, "msgpack_types", VAR_DICT, VV_RO),
+ VV(VV__NULL_STRING, "_null_string", VAR_STRING, VV_RO),
VV(VV__NULL_LIST, "_null_list", VAR_LIST, VV_RO),
VV(VV__NULL_DICT, "_null_dict", VAR_DICT, VV_RO),
VV(VV_LUA, "lua", VAR_PARTIAL, VV_RO),
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index c681660771..a62d87fcc4 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -158,6 +158,7 @@ typedef enum {
// Neovim
VV_STDERR,
VV_MSGPACK_TYPES,
+ VV__NULL_STRING, // String with NULL value. For test purposes only.
VV__NULL_LIST, // List with NULL value. For test purposes only.
VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
VV_LUA,
diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim
index 8e2a987e74..affb141a26 100644
--- a/src/nvim/testdir/test_listdict.vim
+++ b/src/nvim/testdir/test_listdict.vim
@@ -506,6 +506,15 @@ func Test_dict_lock_extend()
call assert_equal({'a': 99, 'b': 100}, d)
endfunc
+" Cannot use += with a locked dict
+func Test_dict_lock_operator()
+ unlet! d
+ let d = {}
+ lockvar d
+ call assert_fails("let d += {'k' : 10}", 'E741:')
+ unlockvar d
+endfunc
+
" No remove() of write-protected scope-level variable
func! Tfunc(this_is_a_long_parameter_name)
call assert_fails("call remove(a:, 'this_is_a_long_parameter_name')", 'E742')
@@ -709,6 +718,23 @@ func Test_listdict_extend()
call assert_fails("call extend([1, 2], 1)", 'E712:')
call assert_fails("call extend([1, 2], {})", 'E712:')
+
+ " Extend g: dictionary with an invalid variable name
+ call assert_fails("call extend(g:, {'-!' : 10})", 'E461:')
+
+ " Extend a list with itself.
+ let l = [1, 5, 7]
+ call extend(l, l, 0)
+ call assert_equal([1, 5, 7, 1, 5, 7], l)
+ let l = [1, 5, 7]
+ call extend(l, l, 1)
+ call assert_equal([1, 1, 5, 7, 5, 7], l)
+ let l = [1, 5, 7]
+ call extend(l, l, 2)
+ call assert_equal([1, 5, 1, 5, 7, 7], l)
+ let l = [1, 5, 7]
+ call extend(l, l, 3)
+ call assert_equal([1, 5, 7, 1, 5, 7], l)
endfunc
func s:check_scope_dict(x, fixed)
@@ -782,3 +808,40 @@ func Test_scope_dict()
" Test for v:
call s:check_scope_dict('v', v:true)
endfunc
+
+" Test for a null list
+func Test_null_list()
+ let l = v:_null_list
+ call assert_equal('', join(l))
+ call assert_equal(0, len(l))
+ call assert_equal(1, empty(l))
+ call assert_fails('let s = join([1, 2], [])', 'E730:')
+ call assert_equal([], split(v:_null_string))
+ call assert_equal([], l[:2])
+ call assert_true([] == l)
+ call assert_equal('[]', string(l))
+ " call assert_equal(0, sort(l))
+ " call assert_equal(0, sort(l))
+ " call assert_equal(0, uniq(l))
+ let k = [] + l
+ call assert_equal([], k)
+ let k = l + []
+ call assert_equal([], k)
+ call assert_equal(0, len(copy(l)))
+ call assert_equal(0, count(l, 5))
+ call assert_equal([], deepcopy(l))
+ call assert_equal(5, get(l, 2, 5))
+ call assert_equal(-1, index(l, 2, 5))
+ " call assert_equal(0, insert(l, 2, -1))
+ call assert_equal(0, min(l))
+ call assert_equal(0, max(l))
+ " call assert_equal(0, remove(l, 0, 2))
+ call assert_equal([], repeat(l, 2))
+ " call assert_equal(0, reverse(l))
+ " call assert_equal(0, sort(l))
+ call assert_equal('[]', string(l))
+ " call assert_equal(0, extend(l, l, 0))
+ lockvar l
+ call assert_equal(1, islocked('l'))
+ unlockvar l
+endfunc
diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim
index e8161f8fcb..c51fb3a759 100644
--- a/src/nvim/testdir/test_utf8.vim
+++ b/src/nvim/testdir/test_utf8.vim
@@ -84,7 +84,7 @@ func Test_list2str_str2list_utf8()
" Null list is the same as an empty list
call assert_equal('', list2str([]))
- " call assert_equal('', list2str(test_null_list()))
+ call assert_equal('', list2str(v:_null_list))
endfunc
func Test_list2str_str2list_latin1()