comparison src/testdir/test_listdict.vim @ 19689:da98d2ed8dc5 v8.2.0401

patch 8.2.0401: not enough test coverage for evalvars.c Commit: https://github.com/vim/vim/commit/8dfcce3a78ccb520cc9d09081f998091494c50bf Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 18 19:32:26 2020 +0100 patch 8.2.0401: not enough test coverage for evalvars.c Problem: Not enough test coverage for evalvars.c. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5804)
author Bram Moolenaar <Bram@vim.org>
date Wed, 18 Mar 2020 19:45:04 +0100
parents 2a017e9dc6da
children b3e93a05c3ca
comparison
equal deleted inserted replaced
19688:8d01c76e0bc7 19689:da98d2ed8dc5
557 call assert_fails('let l[1:2] = [0, 1]', 'E741:') 557 call assert_fails('let l[1:2] = [0, 1]', 'E741:')
558 call assert_equal([1, 2, 3, 4], l) 558 call assert_equal([1, 2, 3, 4], l)
559 unlet l 559 unlet l
560 endfunc 560 endfunc
561 561
562 " Locking part of the list
563 func Test_let_lock_list_items()
564 let l = [1, 2, 3, 4]
565 lockvar l[2:]
566 call assert_equal(0, islocked('l[0]'))
567 call assert_equal(1, islocked('l[2]'))
568 call assert_equal(1, islocked('l[3]'))
569 call assert_fails('let l[2] = 10', 'E741:')
570 call assert_fails('let l[3] = 20', 'E741:')
571 unlet l
572 endfunc
573
562 " lockvar/islocked() triggering script autoloading 574 " lockvar/islocked() triggering script autoloading
563 func Test_lockvar_script_autoload() 575 func Test_lockvar_script_autoload()
564 let old_rtp = &rtp 576 let old_rtp = &rtp
565 set rtp+=./sautest 577 set rtp+=./sautest
566 lockvar g:footest#x 578 lockvar g:footest#x
789 call s:check_scope_dict('t', v:false) 801 call s:check_scope_dict('t', v:false)
790 802
791 " Test for v: 803 " Test for v:
792 call s:check_scope_dict('v', v:true) 804 call s:check_scope_dict('v', v:true)
793 endfunc 805 endfunc
806
807 " Test for deep nesting of lists (> 100)
808 func Test_deep_nested_list()
809 let deep_list = []
810 let l = deep_list
811 for i in range(102)
812 let newlist = []
813 call add(l, newlist)
814 let l = newlist
815 endfor
816 call add(l, 102)
817
818 call assert_fails('let m = deepcopy(deep_list)', 'E698:')
819 call assert_fails('lockvar 110 deep_list', 'E743:')
820 call assert_fails('unlockvar 110 deep_list', 'E743:')
821 call assert_fails('let x = execute("echo deep_list")', 'E724:')
822 call test_garbagecollect_now()
823 unlet deep_list
824 endfunc
825
826 " Test for deep nesting of dicts (> 100)
827 func Test_deep_nested_dict()
828 let deep_dict = {}
829 let d = deep_dict
830 for i in range(102)
831 let newdict = {}
832 let d.k = newdict
833 let d = newdict
834 endfor
835 let d.k = 'v'
836
837 call assert_fails('let m = deepcopy(deep_dict)', 'E698:')
838 call assert_fails('lockvar 110 deep_dict', 'E743:')
839 call assert_fails('unlockvar 110 deep_dict', 'E743:')
840 call assert_fails('let x = execute("echo deep_dict")', 'E724:')
841 call test_garbagecollect_now()
842 unlet deep_dict
843 endfunc
844
845 " vim: shiftwidth=2 sts=2 expandtab