diff src/testdir/test_vim9_script.vim @ 21526:a7afee13873d v8.2.1313

patch 8.2.1313: Vim9 script: cannot assign to environment variable Commit: https://github.com/vim/vim/commit/b5ed266037dea49024e00c4e1f9c89f3a9ebaa60 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 28 22:38:37 2020 +0200 patch 8.2.1313: Vim9 script: cannot assign to environment variable Problem: Vim9 script: cannot assign to environment variable. Solution: Recognize environment variable assignment. (closes https://github.com/vim/vim/issues/6548) Also options and registers.
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 Jul 2020 22:45:03 +0200
parents c7b2ce90c2de
children e0aa9b81f6a9
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -61,6 +61,14 @@ def Test_assignment()
   assert_equal('foobar', $ENVVAR)
   $ENVVAR = ''
 
+  let lines =<< trim END
+    vim9script
+    $ENVVAR = 'barfoo'
+    assert_equal('barfoo', $ENVVAR)
+    $ENVVAR = ''
+  END
+  call CheckScriptSuccess(lines)
+
   s:appendToMe ..= 'yyy'
   assert_equal('xxxyyy', s:appendToMe)
   s:addToMe += 222
@@ -80,6 +88,15 @@ def Test_assignment()
   set ts=10
   &ts %= 4
   assert_equal(2, &ts)
+
+  lines =<< trim END
+    vim9script
+    &ts = 6
+    &ts += 3
+    assert_equal(9, &ts)
+  END
+  call CheckScriptSuccess(lines)
+
   call CheckDefFailure(['&notex += 3'], 'E113:')
   call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
   call CheckDefFailure(['&ts = [7]'], 'E1013:')
@@ -106,6 +123,14 @@ def Test_assignment()
   call CheckDefFailure(['@a += "more"'], 'E1013:')
   call CheckDefFailure(['@a += 123'], 'E1013:')
 
+  lines =<< trim END
+    vim9script
+    @c = 'areg'
+    @c ..= 'add'
+    assert_equal('aregadd', @c)
+  END
+  call CheckScriptSuccess(lines)
+
   v:errmsg = 'none'
   v:errmsg ..= 'again'
   assert_equal('noneagain', v:errmsg)