Patch 8.1.1554 (after 8.1.1539)
Problem: Docs and tests for :const can be improved.
Solution: Improve documentation, add a few more tests. (Ryuichi Hayashida,
closes #4551)
Files: runtime/doc/eval.txt, src/testdir/test_const.vim
*** ../vim-8.1.1553/runtime/doc/eval.txt 2019-06-15 17:12:01.565915021 +0200
--- runtime/doc/eval.txt 2019-06-16 15:37:13.827802795 +0200
***************
*** 11617,11626 ****
If the system does not support deleting an environment
variable, it is made empty.
! *:cons* *:const* *E996*
:cons[t] {var-name} = {expr1}
:cons[t] [{name1}, {name2}, ...] = {expr1}
- :cons[t] [{name1}, {name2}, ...] .= {expr1}
:cons[t] [{name}, ..., ; {lastname}] = {expr1}
:cons[t] {var-name} =<< [trim] {marker}
text...
--- 11617,11625 ----
If the system does not support deleting an environment
variable, it is made empty.
! *:cons* *:const*
:cons[t] {var-name} = {expr1}
:cons[t] [{name1}, {name2}, ...] = {expr1}
:cons[t] [{name}, ..., ; {lastname}] = {expr1}
:cons[t] {var-name} =<< [trim] {marker}
text...
***************
*** 11639,11645 ****
|:const| does not allow to for changing a variable. >
:let x = 1
:const x = 2 " Error!
! <
:lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv*
Lock the internal variable {name}. Locking means that
it can no longer be changed (until it is unlocked).
--- 11638,11648 ----
|:const| does not allow to for changing a variable. >
:let x = 1
:const x = 2 " Error!
! < *E996*
! Note that environment variables, option values and
! register values cannot be used here, since they cannot
! be locked.
!
:lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv*
Lock the internal variable {name}. Locking means that
it can no longer be changed (until it is unlocked).
*** ../vim-8.1.1553/src/testdir/test_const.vim 2019-06-15 17:50:53.139516045 +0200
--- src/testdir/test_const.vim 2019-06-16 15:40:14.931083207 +0200
***************
*** 21,26 ****
--- 21,41 ----
hello
EOS
+ call assert_true(exists('i'))
+ call assert_true(exists('f'))
+ call assert_true(exists('s'))
+ call assert_true(exists('F'))
+ call assert_true(exists('l'))
+ call assert_true(exists('d'))
+ if has('channel')
+ call assert_true(exists('j'))
+ call assert_true(exists('c'))
+ endif
+ call assert_true(exists('b'))
+ call assert_true(exists('n'))
+ call assert_true(exists('bl'))
+ call assert_true(exists('here'))
+
call assert_fails('let i = 1', 'E741:')
call assert_fails('let f = 1.1', 'E741:')
call assert_fails('let s = "vim"', 'E741:')
***************
*** 218,223 ****
--- 233,249 ----
call assert_fails('const &g:encoding = "utf-8"', 'E996:')
endfunc
+ func Test_const_with_eval_name()
+ let s = 'foo'
+
+ " eval name with :const should work
+ const abc_{s} = 1
+ const {s}{s} = 1
+
+ let s2 = 'abc_foo'
+ call assert_fails('const {s2} = "bar"', 'E995:')
+ endfunc
+
func Test_lock_depth_is_1()
const l = [1, 2, 3]
const d = {'foo': 10}
*** ../vim-8.1.1553/src/version.c 2019-06-16 15:31:38.737109971 +0200
--- src/version.c 2019-06-16 15:41:14.750844203 +0200
***************
*** 779,780 ****
--- 779,782 ----
{ /* Add new patch number below this line */
+ /**/
+ 1554,
/**/
--
$ echo pizza > /dev/oven
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///