]> granicus.if.org Git - vim/commitdiff
patch 8.1.1554: docs and tests for :const can be improved v8.1.1554
authorBram Moolenaar <Bram@vim.org>
Sun, 16 Jun 2019 13:41:58 +0000 (15:41 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 16 Jun 2019 13:41:58 +0000 (15:41 +0200)
Problem:    Docs and tests for :const can be improved.
Solution:   Improve documentation, add a few more tests. (Ryuichi Hayashida,
            closes #4551)

runtime/doc/eval.txt
src/testdir/test_const.vim
src/version.c

index 83a89957f27a37063f2eb3c683281d5ccbb6cfb2..549d27ba9af85c80bac255ff657dc54706a7f646 100644 (file)
@@ -11619,10 +11619,9 @@ text...
                        If the system does not support deleting an environment
                        variable, it is made empty.
 
-                                               *:cons* *:const* *E996*
+                                               *:cons* *:const*
 :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...
@@ -11641,7 +11640,11 @@ text...
                        |: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).
index bb47e5e5fdca505e6806c902ddc71377cfa26abd..d4dccb1b831bd7bcbccafbf10a9fa0e93ea1a7c1 100644 (file)
@@ -21,6 +21,21 @@ func Test_define_var_with_lock()
     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,6 +233,17 @@ func Test_const_with_special_variables()
     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}
index aa11b7ebc4e22a5b0aa017a8057064ce6070656f..fcdf562d47a9fb142a5897fbff1f8db12cd31850 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1554,
 /**/
     1553,
 /**/