]> granicus.if.org Git - vim/commitdiff
patch 8.2.1951: test for list and dict fails v8.2.1951
authorBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 11:23:06 +0000 (12:23 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 4 Nov 2020 11:23:06 +0000 (12:23 +0100)
Problem:    Test for list and dict fails.
Solution:   Adjust for using an empty list/dict for a null one.

src/testdir/test_listdict.vim
src/testdir/test_python2.vim
src/testdir/test_python3.vim
src/version.c

index 6a7fc4c6820ad1d8a778e257ec8c449c1937459a..762a5170806e2ed3ac16584f877c6f994a56b1d3 100644 (file)
@@ -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
index fd8fe70e495c0ca999cde5de39b0ab44378bac26..ba73c1232e7cf24e47f35e5326b9d4f7b354d593 100644 (file)
@@ -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')
index f05fc0702448a95d73b109d88c1921b9a23c6f9a..660ac461dfc6b4bf63e2fc3b620947f6cde57c16 100644 (file)
@@ -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')
index 150bfd23bc75c878d1e32a4502a7e9cc6236148f..d677744eed639dcb566043fa91a4b384914867e2 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1951,
 /**/
     1950,
 /**/