comparison src/testdir/test_listdict.vim @ 19724:b3e93a05c3ca v8.2.0418

patch 8.2.0418: code in eval.c not sufficiently covered by tests Commit: https://github.com/vim/vim/commit/8b633135106dda8605463b780573c45b00c22afe Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 20 18:20:51 2020 +0100 patch 8.2.0418: code in eval.c not sufficiently covered by tests Problem: Code in eval.c not sufficiently covered by tests. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5815)
author Bram Moolenaar <Bram@vim.org>
date Fri, 20 Mar 2020 18:30:05 +0100
parents da98d2ed8dc5
children 546bdeef35f1
comparison
equal deleted inserted replaced
19723:16aa117306ec 19724:b3e93a05c3ca
29 call assert_equal([1, 'as''d', [1, 2, function('strlen')], {'a': 1}], l[:]) 29 call assert_equal([1, 'as''d', [1, 2, function('strlen')], {'a': 1}], l[:])
30 call assert_equal(['as''d', [1, 2, function('strlen')], {'a': 1}], l[1:]) 30 call assert_equal(['as''d', [1, 2, function('strlen')], {'a': 1}], l[1:])
31 call assert_equal([1, 'as''d', [1, 2, function('strlen')]], l[:-2]) 31 call assert_equal([1, 'as''d', [1, 2, function('strlen')]], l[:-2])
32 call assert_equal([1, 'as''d', [1, 2, function('strlen')], {'a': 1}], l[0:8]) 32 call assert_equal([1, 'as''d', [1, 2, function('strlen')], {'a': 1}], l[0:8])
33 call assert_equal([], l[8:-1]) 33 call assert_equal([], l[8:-1])
34 call assert_equal([], l[0:-10])
34 endfunc 35 endfunc
35 36
36 " List identity 37 " List identity
37 func Test_list_identity() 38 func Test_list_identity()
38 let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},] 39 let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},]
102 " test for range assign 103 " test for range assign
103 func Test_list_range_assign() 104 func Test_list_range_assign()
104 let l = [0] 105 let l = [0]
105 let l[:] = [1, 2] 106 let l[:] = [1, 2]
106 call assert_equal([1, 2], l) 107 call assert_equal([1, 2], l)
108 let l[-4:-1] = [5, 6]
109 call assert_equal([5, 6], l)
107 endfunc 110 endfunc
108 111
109 " Test removing items in list 112 " Test removing items in list
110 func Test_list_func_remove() 113 func Test_list_func_remove()
111 " Test removing 1 element 114 " Test removing 1 element
646 let l[1] = d 649 let l[1] = d
647 call assert_true(l == l) 650 call assert_true(l == l)
648 call assert_true(d == d) 651 call assert_true(d == d)
649 call assert_false(l != deepcopy(l)) 652 call assert_false(l != deepcopy(l))
650 call assert_false(d != deepcopy(d)) 653 call assert_false(d != deepcopy(d))
654
655 " comparison errors
656 call assert_fails('echo [1, 2] =~ {}', 'E691:')
657 call assert_fails('echo [1, 2] =~ [1, 2]', 'E692:')
658 call assert_fails('echo {} =~ 5', 'E735:')
659 call assert_fails('echo {} =~ {}', 'E736:')
651 endfunc 660 endfunc
652 661
653 " compare complex recursively linked list and dict 662 " compare complex recursively linked list and dict
654 func Test_listdict_compare_complex() 663 func Test_listdict_compare_complex()
655 let l = [] 664 let l = []
840 call assert_fails('let x = execute("echo deep_dict")', 'E724:') 849 call assert_fails('let x = execute("echo deep_dict")', 'E724:')
841 call test_garbagecollect_now() 850 call test_garbagecollect_now()
842 unlet deep_dict 851 unlet deep_dict
843 endfunc 852 endfunc
844 853
854 " List and dict indexing tests
855 func Test_listdict_index()
856 call assert_fails('echo function("min")[0]', 'E695:')
857 call assert_fails('echo v:true[0]', 'E909:')
858 let d = {'k' : 10}
859 call assert_fails('echo d.', 'E15:')
860 call assert_fails('echo d[1:2]', 'E719:')
861 call assert_fails("let v = [4, 6][{-> 1}]", 'E729:')
862 call assert_fails("let v = range(5)[2:[]]", 'E730:')
863 call assert_fails("let v = range(5)[2:{-> 2}(]", 'E116:')
864 call assert_fails("let v = range(5)[2:3", 'E111:')
865 endfunc
866
845 " vim: shiftwidth=2 sts=2 expandtab 867 " vim: shiftwidth=2 sts=2 expandtab