Mercurial > vim
diff src/testdir/test_vim9_cmd.vim @ 28152:b96409b84eaf v8.2.4600
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Commit: https://github.com/vim/vim/commit/6b8c7ba062ca4b50e8f983e0485be7afa4eef691
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 20 17:46:06 2022 +0000
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Problem: Vim9: not enough test coverage for executing :def function.
Solution: Add a few more tests. Fix inconsistencies.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 20 Mar 2022 19:00:03 +0100 |
parents | 5bf3ed75e26c |
children | ae975c8d5438 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1573,6 +1573,36 @@ def Test_lockvar() END v9.CheckScriptFailure(lines, 'E741', 2) + # can unlet a locked list item but not change it + lines =<< trim END + var ll = [1, 2, 3] + lockvar ll[1] + unlet ll[1] + assert_equal([1, 3], ll) + END + v9.CheckDefAndScriptSuccess(lines) + lines =<< trim END + var ll = [1, 2, 3] + lockvar ll[1] + ll[1] = 9 + END + v9.CheckDefExecAndScriptFailure(lines, ['E1119:', 'E741'], 3) + + # can unlet a locked dict item but not change it + lines =<< trim END + var dd = {a: 1, b: 2} + lockvar dd.a + unlet dd.a + assert_equal({b: 2}, dd) + END + v9.CheckDefAndScriptSuccess(lines) + lines =<< trim END + var dd = {a: 1, b: 2} + lockvar dd.a + dd.a = 3 + END + v9.CheckDefExecAndScriptFailure(lines, ['E1121:', 'E741'], 3) + lines =<< trim END var theList = [1, 2, 3] lockvar theList