changeset 22806:690b84a6a7ce v8.2.1951

patch 8.2.1951: test for list and dict fails Commit: https://github.com/vim/vim/commit/64ffa9b5fb34adb0b20fc22e8127604274bc3010 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 4 12:23:06 2020 +0100 patch 8.2.1951: test for list and dict fails Problem: Test for list and dict fails. Solution: Adjust for using an empty list/dict for a null one.
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Nov 2020 12:30:03 +0100
parents 4ee5efad0df5
children 606ff2127ead
files src/testdir/test_listdict.vim src/testdir/test_python2.vim src/testdir/test_python3.vim src/version.c
diffstat 4 files changed, 33 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -1000,7 +1000,8 @@ endfunc
 " Test for a null list
 func Test_null_list()
   let l = test_null_list()
-  call assert_equal(0, join(l))
+  call assert_equal(0, join(test_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:')
@@ -1008,8 +1009,10 @@ func Test_null_list()
   call assert_equal([], l[:2])
   call assert_true([] == l)
   call assert_equal('[]', string(l))
-  call assert_equal(0, sort(l))
-  call assert_equal(0, uniq(l))
+  call assert_equal(0, sort(test_null_list()))
+  call assert_equal([], sort(l))
+  call assert_equal(0, uniq(test_null_list()))
+  call assert_equal([], uniq(l))
   let k = [] + l
   call assert_equal([], k)
   let k = l + []
@@ -1019,15 +1022,20 @@ func Test_null_list()
   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, insert(test_null_list(), 2, -1))
+  call assert_fails('call insert(l, 2, -1)', 'E684:')
   call assert_equal(0, min(l))
   call assert_equal(0, max(l))
-  call assert_equal(0, remove(l, 0, 2))
+  call assert_equal(0, remove(test_null_list(), 0, 2))
+  call assert_fails('call remove(l, 0, 2)', 'E684:')
   call assert_equal([], repeat(l, 2))
-  call assert_equal(0, reverse(l))
-  call assert_equal(0, sort(l))
+  call assert_equal(0, reverse(test_null_list()))
+  call assert_equal([], reverse(l))
+  call assert_equal(0, sort(test_null_list()))
+  call assert_equal([], sort(l))
   call assert_equal('[]', string(l))
-  call assert_equal(0, extend(l, l, 0))
+  call assert_fails('call extend(test_null_list(), test_null_list())', 'E1134:')
+  call assert_equal([], extend(l, l, 0))
   lockvar l
   call assert_equal(1, islocked('l'))
   unlockvar l
@@ -1040,12 +1048,15 @@ func Test_null_dict()
   call assert_equal({}, d)
   call assert_equal(0, len(d))
   call assert_equal(1, empty(d))
-  call assert_equal(0, items(d))
-  call assert_equal(0, keys(d))
-  call assert_equal(0, values(d))
+  call assert_equal(0, items(test_null_dict()))
+  call assert_equal([], items(d))
+  call assert_equal(0, keys(test_null_dict()))
+  call assert_equal([], keys(d))
+  call assert_equal(0, values(test_null_dict()))
+  call assert_equal([], values(d))
   call assert_false(has_key(d, 'k'))
   call assert_equal('{}', string(d))
-  call assert_fails('let x = d[10]')
+  call assert_fails('let x = d[10]', 'E716:')
   call assert_equal({}, {})
   call assert_equal(0, len(copy(d)))
   call assert_equal(0, count(d, 'k'))
@@ -1053,9 +1064,11 @@ func Test_null_dict()
   call assert_equal(20, get(d, 'k', 20))
   call assert_equal(0, min(d))
   call assert_equal(0, max(d))
-  call assert_equal(0, remove(d, 'k'))
+  call assert_equal(0, remove(test_null_dict(), 'k'))
+  call assert_fails("call remove(d, 'k')", 'E716:')
   call assert_equal('{}', string(d))
-  call assert_equal(0, extend(d, d, 0))
+  call assert_fails('call extend(test_null_dict(), test_null_dict())', 'E1133:')
+  call assert_equal({}, extend(d, d, 'keep'))
   lockvar d
   call assert_equal(1, islocked('d'))
   unlockvar d
--- a/src/testdir/test_python2.vim
+++ b/src/testdir/test_python2.vim
@@ -353,12 +353,12 @@ func Test_python_list()
   call AssertException(["py t = vim.eval('[test_null_list()]')"],
         \ 'Vim(python):SystemError: error return without exception set')
 
-  " Try to bind a null List variable
+  " Try to bind a null List variable (works because an empty list is used)
   let cmds =<< trim END
     let l = test_null_list()
     py ll = vim.bindeval('l')
   END
-  call AssertException(cmds, 'Vim(python):SystemError: error return without exception set')
+  call AssertException(cmds, '')
 
   let l = []
   py l = vim.bindeval('l')
--- a/src/testdir/test_python3.vim
+++ b/src/testdir/test_python3.vim
@@ -545,13 +545,12 @@ func Test_python3_list()
   call AssertException(["py3 t = vim.eval('[test_null_list()]')"],
         \ 'Vim(py3):SystemError: <built-in function eval> returned NULL without setting an error')
 
-  " Try to bind a null List variable
+  " Try to bind a null List variable (works because an empty list is used)
   let cmds =<< trim END
     let l = test_null_list()
     py3 ll = vim.bindeval('l')
   END
-  call AssertException(cmds,
-        \ 'Vim(py3):SystemError: <built-in function bindeval> returned NULL without setting an error')
+  call AssertException(cmds, '')
 
   let l = []
   py3 l = vim.bindeval('l')
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1951,
+/**/
     1950,
 /**/
     1949,