Skip to content

Commit 64ffa9b

Browse files
committed
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.
1 parent 9c13f76 commit 64ffa9b

4 files changed

Lines changed: 33 additions & 19 deletions

File tree

src/testdir/test_listdict.vim

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,16 +1000,19 @@ endfunc
10001000
" Test for a null list
10011001
func Test_null_list()
10021002
let l = test_null_list()
1003-
call assert_equal(0, join(l))
1003+
call assert_equal(0, join(test_null_list()))
1004+
call assert_equal('', join(l))
10041005
call assert_equal(0, len(l))
10051006
call assert_equal(1, empty(l))
10061007
call assert_fails('let s = join([1, 2], [])', 'E730:')
10071008
call assert_equal([], split(test_null_string()))
10081009
call assert_equal([], l[:2])
10091010
call assert_true([] == l)
10101011
call assert_equal('[]', string(l))
1011-
call assert_equal(0, sort(l))
1012-
call assert_equal(0, uniq(l))
1012+
call assert_equal(0, sort(test_null_list()))
1013+
call assert_equal([], sort(l))
1014+
call assert_equal(0, uniq(test_null_list()))
1015+
call assert_equal([], uniq(l))
10131016
let k = [] + l
10141017
call assert_equal([], k)
10151018
let k = l + []
@@ -1019,15 +1022,20 @@ func Test_null_list()
10191022
call assert_equal([], deepcopy(l))
10201023
call assert_equal(5, get(l, 2, 5))
10211024
call assert_equal(-1, index(l, 2, 5))
1022-
call assert_equal(0, insert(l, 2, -1))
1025+
call assert_equal(0, insert(test_null_list(), 2, -1))
1026+
call assert_fails('call insert(l, 2, -1)', 'E684:')
10231027
call assert_equal(0, min(l))
10241028
call assert_equal(0, max(l))
1025-
call assert_equal(0, remove(l, 0, 2))
1029+
call assert_equal(0, remove(test_null_list(), 0, 2))
1030+
call assert_fails('call remove(l, 0, 2)', 'E684:')
10261031
call assert_equal([], repeat(l, 2))
1027-
call assert_equal(0, reverse(l))
1028-
call assert_equal(0, sort(l))
1032+
call assert_equal(0, reverse(test_null_list()))
1033+
call assert_equal([], reverse(l))
1034+
call assert_equal(0, sort(test_null_list()))
1035+
call assert_equal([], sort(l))
10291036
call assert_equal('[]', string(l))
1030-
call assert_equal(0, extend(l, l, 0))
1037+
call assert_fails('call extend(test_null_list(), test_null_list())', 'E1134:')
1038+
call assert_equal([], extend(l, l, 0))
10311039
lockvar l
10321040
call assert_equal(1, islocked('l'))
10331041
unlockvar l
@@ -1040,22 +1048,27 @@ func Test_null_dict()
10401048
call assert_equal({}, d)
10411049
call assert_equal(0, len(d))
10421050
call assert_equal(1, empty(d))
1043-
call assert_equal(0, items(d))
1044-
call assert_equal(0, keys(d))
1045-
call assert_equal(0, values(d))
1051+
call assert_equal(0, items(test_null_dict()))
1052+
call assert_equal([], items(d))
1053+
call assert_equal(0, keys(test_null_dict()))
1054+
call assert_equal([], keys(d))
1055+
call assert_equal(0, values(test_null_dict()))
1056+
call assert_equal([], values(d))
10461057
call assert_false(has_key(d, 'k'))
10471058
call assert_equal('{}', string(d))
1048-
call assert_fails('let x = d[10]')
1059+
call assert_fails('let x = d[10]', 'E716:')
10491060
call assert_equal({}, {})
10501061
call assert_equal(0, len(copy(d)))
10511062
call assert_equal(0, count(d, 'k'))
10521063
call assert_equal({}, deepcopy(d))
10531064
call assert_equal(20, get(d, 'k', 20))
10541065
call assert_equal(0, min(d))
10551066
call assert_equal(0, max(d))
1056-
call assert_equal(0, remove(d, 'k'))
1067+
call assert_equal(0, remove(test_null_dict(), 'k'))
1068+
call assert_fails("call remove(d, 'k')", 'E716:')
10571069
call assert_equal('{}', string(d))
1058-
call assert_equal(0, extend(d, d, 0))
1070+
call assert_fails('call extend(test_null_dict(), test_null_dict())', 'E1133:')
1071+
call assert_equal({}, extend(d, d, 'keep'))
10591072
lockvar d
10601073
call assert_equal(1, islocked('d'))
10611074
unlockvar d

src/testdir/test_python2.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,12 @@ func Test_python_list()
353353
call AssertException(["py t = vim.eval('[test_null_list()]')"],
354354
\ 'Vim(python):SystemError: error return without exception set')
355355

356-
" Try to bind a null List variable
356+
" Try to bind a null List variable (works because an empty list is used)
357357
let cmds =<< trim END
358358
let l = test_null_list()
359359
py ll = vim.bindeval('l')
360360
END
361-
call AssertException(cmds, 'Vim(python):SystemError: error return without exception set')
361+
call AssertException(cmds, '')
362362

363363
let l = []
364364
py l = vim.bindeval('l')

src/testdir/test_python3.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,12 @@ func Test_python3_list()
545545
call AssertException(["py3 t = vim.eval('[test_null_list()]')"],
546546
\ 'Vim(py3):SystemError: <built-in function eval> returned NULL without setting an error')
547547

548-
" Try to bind a null List variable
548+
" Try to bind a null List variable (works because an empty list is used)
549549
let cmds =<< trim END
550550
let l = test_null_list()
551551
py3 ll = vim.bindeval('l')
552552
END
553-
call AssertException(cmds,
554-
\ 'Vim(py3):SystemError: <built-in function bindeval> returned NULL without setting an error')
553+
call AssertException(cmds, '')
555554

556555
let l = []
557556
py3 l = vim.bindeval('l')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1951,
753755
/**/
754756
1950,
755757
/**/

0 commit comments

Comments
 (0)