From ec273a2c6ba055810539f2d58353c9c0fc8db320 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 8 Apr 2021 18:48:43 -0400 Subject: vim-patch:8.2.0623: typo in test comment Problem: Typo in test comment. (Christ van Willegen) Solution: Avoid mixing up a data structure with a body part. https://github.com/vim/vim/commit/f7b398c6a9476a2004a42555b731ebf47b866408 Cherry-pick Test_dict_lock_operator() from patch v8.2.0619. --- src/nvim/testdir/test_listdict.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index 8e2a987e74..9b871b5707 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') -- cgit From 0d0eeff8a34b01db93fb271fbeac3ad2d372a0e0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 8 Apr 2021 22:33:21 -0400 Subject: eval: add v:_null_string Replacement for Vim's test_null_string(). Vim uses it to verify that its codebase handles null strings. Preparation for the Test_null_list() in patch v8.2.1822. Use v:_null_string, not non-existent env var, for null string tests. Mention v:_null_string in id() because id(v:_null_string) returns (nil). --- src/nvim/eval.c | 1 + src/nvim/eval.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src') 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, -- cgit From cfeaea0d3eb3f13a6f3c59f8d270082d9d2ec3b1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 8 Apr 2021 19:20:50 -0400 Subject: vim-patch:8.2.1822: list test doesn't fail Problem: List test doesn't fail. Solution: Adjust the test for NULL list handling. https://github.com/vim/vim/commit/f57497276bc616d3856eeff9824c080941faa51b Comment out test cases that modify null lists because Neovim throws error messages instead of silently failing. Null lists should be read-only and constant. https://github.com/neovim/neovim/issues/4615 --- src/nvim/testdir/test_listdict.vim | 37 +++++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_utf8.vim | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index 9b871b5707..f9410fb620 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -791,3 +791,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() -- cgit From b35daa986f06f00939ddcf225a5efc59c26c418b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 8 Apr 2021 22:40:02 -0400 Subject: vim-patch:8.2.2738: extending a list with itself can give wrong result Problem: Extending a list with itself can give wrong result. Solution: Remember the item before where the insertion happens and skip to after the already inserted items. (closes vim/vim#1112) https://github.com/vim/vim/commit/dcae51facc4d6de1edd62f0242b40972be841103 Originated from Neovim commit 7ceebacb3fad49ba8321397cf839948caa55b3f5. --- src/nvim/testdir/test_listdict.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index f9410fb620..affb141a26 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -718,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) -- cgit