comparison src/testdir/test_listdict.vim @ 19783:546bdeef35f1 v8.2.0448

patch 8.2.0448: various functions not properly tested Commit: https://github.com/vim/vim/commit/0e05de46226eb4e5ea580beefa71831f92d613d3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 25 22:23:46 2020 +0100 patch 8.2.0448: various functions not properly tested Problem: Various functions not properly tested. Solution: Add more tests, especially for failures. (Yegappan Lakshmanan, closes #5843)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Mar 2020 22:30:04 +0100
parents b3e93a05c3ca
children 2c4d9ca33769
comparison
equal deleted inserted replaced
19782:e5f4316b01dd 19783:546bdeef35f1
300 call assert_fails('call deepcopy(d, 1)', 'E698') 300 call assert_fails('call deepcopy(d, 1)', 'E698')
301 let l2 = [0, l, l, 3] 301 let l2 = [0, l, l, 3]
302 let l[1] = l2 302 let l[1] = l2
303 let l3 = deepcopy(l2) 303 let l3 = deepcopy(l2)
304 call assert_true(l3[1] is l3[2]) 304 call assert_true(l3[1] is l3[2])
305 call assert_fails("call deepcopy([1, 2], 2)", 'E474:')
305 endfunc 306 endfunc
306 307
307 " Locked variables 308 " Locked variables
308 func Test_list_locked_var() 309 func Test_list_locked_var()
309 let expected = [ 310 let expected = [
379 let ps .= 'F' 380 let ps .= 'F'
380 endtry 381 endtry
381 call assert_equal(expected[depth][u][1], ps) 382 call assert_equal(expected[depth][u][1], ps)
382 endfor 383 endfor
383 endfor 384 endfor
385 call assert_fails("let x=islocked('a b')", 'E488:')
386 let mylist = [1, 2, 3]
387 call assert_fails("let x = islocked('mylist[1:2]')", 'E786:')
388 let mydict = {'k' : 'v'}
389 call assert_fails("let x = islocked('mydict.a')", 'E716:')
384 endfunc 390 endfunc
385 391
386 " Unletting locked variables 392 " Unletting locked variables
387 func Test_list_locked_var_unlet() 393 func Test_list_locked_var_unlet()
388 let expected = [ 394 let expected = [
627 endif 633 endif
628 634
629 call assert_fails('call reverse("")', 'E899:') 635 call assert_fails('call reverse("")', 'E899:')
630 endfunc 636 endfunc
631 637
632 " splitting a string to a List 638 " splitting a string to a List using split()
633 func Test_str_split() 639 func Test_str_split()
634 call assert_equal(['aa', 'bb'], split(' aa bb ')) 640 call assert_equal(['aa', 'bb'], split(' aa bb '))
635 call assert_equal(['aa', 'bb'], split(' aa bb ', '\W\+', 0)) 641 call assert_equal(['aa', 'bb'], split(' aa bb ', '\W\+', 0))
636 call assert_equal(['', 'aa', 'bb', ''], split(' aa bb ', '\W\+', 1)) 642 call assert_equal(['', 'aa', 'bb', ''], split(' aa bb ', '\W\+', 1))
637 call assert_equal(['', '', 'aa', '', 'bb', '', ''], split(' aa bb ', '\W', 1)) 643 call assert_equal(['', '', 'aa', '', 'bb', '', ''], split(' aa bb ', '\W', 1))
638 call assert_equal(['aa', '', 'bb'], split(':aa::bb:', ':', 0)) 644 call assert_equal(['aa', '', 'bb'], split(':aa::bb:', ':', 0))
639 call assert_equal(['', 'aa', '', 'bb', ''], split(':aa::bb:', ':', 1)) 645 call assert_equal(['', 'aa', '', 'bb', ''], split(':aa::bb:', ':', 1))
640 call assert_equal(['aa', '', 'bb', 'cc', ''], split('aa,,bb, cc,', ',\s*', 1)) 646 call assert_equal(['aa', '', 'bb', 'cc', ''], split('aa,,bb, cc,', ',\s*', 1))
641 call assert_equal(['a', 'b', 'c'], split('abc', '\zs')) 647 call assert_equal(['a', 'b', 'c'], split('abc', '\zs'))
642 call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1)) 648 call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1))
649 call assert_fails("call split('abc', [])", 'E730:')
650 call assert_fails("call split('abc', 'b', [])", 'E745:')
643 endfunc 651 endfunc
644 652
645 " compare recursively linked list and dict 653 " compare recursively linked list and dict
646 func Test_listdict_compare() 654 func Test_listdict_compare()
647 let l = [1, 2, 3, 4] 655 let l = [1, 2, 3, 4]