Mercurial > vim
diff src/testdir/test_vim9_cmd.vim @ 24262:d0e86f1b34e7 v8.2.2672
patch 8.2.2672: Vim9: cannot use :lockvar and :unlockvar in compiled script
Commit: https://github.com/vim/vim/commit/b2cb6c8bbd215177ed05c1d952e7ef2ad8f7ef4b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 28 20:38:34 2021 +0200
patch 8.2.2672: Vim9: cannot use :lockvar and :unlockvar in compiled script
Problem: Vim9: cannot use :lockvar and :unlockvar in compiled script.
Solution: Implement locking support.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Mar 2021 20:45:06 +0200 |
parents | a2e6029d354e |
children | f293bb501b30 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1135,4 +1135,42 @@ def Test_windo_missing_endif() CheckDefExecFailure(lines, 'E171:', 1) enddef +let s:theList = [1, 2, 3] + +def Test_lockvar() + s:theList[1] = 22 + assert_equal([1, 22, 3], s:theList) + lockvar s:theList + assert_fails('theList[1] = 77', 'E741:') + unlockvar s:theList + s:theList[1] = 44 + assert_equal([1, 44, 3], s:theList) + + var lines =<< trim END + vim9script + var theList = [1, 2, 3] + def SetList() + theList[1] = 22 + assert_equal([1, 22, 3], theList) + lockvar theList + theList[1] = 77 + enddef + SetList() + END + CheckScriptFailure(lines, 'E1119', 4) + + lines =<< trim END + var theList = [1, 2, 3] + lockvar theList + END + CheckDefFailure(lines, 'E1178', 2) + + lines =<< trim END + var theList = [1, 2, 3] + unlockvar theList + END + CheckDefFailure(lines, 'E1178', 2) +enddef + + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker