changeset 19326:d1810b726592 v8.2.0221

patch 8.2.0221: no test for Vim9 += and ..= Commit: https://github.com/vim/vim/commit/6e587dcbf319ea898ef50f7e367c46586a6f408a Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 6 13:15:52 2020 +0100 patch 8.2.0221: no test for Vim9 += and ..= Problem: No test for Vim9 += and ..=. Solution: Add tests.
author Bram Moolenaar <Bram@vim.org>
date Thu, 06 Feb 2020 13:30:03 +0100
parents bf0e50bb2c82
children 6bbb4ad91d21
files src/testdir/test_vim9_script.vim src/version.c
diffstat 2 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -27,6 +27,9 @@ func Test_def_basic()
   call assert_equal('yes', SomeFunc())
 endfunc
 
+let s:appendToMe = 'xxx'
+let s:addToMe = 111
+
 def Test_assignment()
   let bool1: bool = true
   assert_equal(v:true, bool1)
@@ -44,11 +47,16 @@ def Test_assignment()
   let dict2: dict<number> = #{one: 1, two: 2}
 
   v:char = 'abc'
-  call assert_equal('abc', v:char)
+  assert_equal('abc', v:char)
 
   $ENVVAR = 'foobar'
-  call assert_equal('foobar', $ENVVAR)
+  assert_equal('foobar', $ENVVAR)
   $ENVVAR = ''
+
+  appendToMe ..= 'yyy'
+  assert_equal('xxxyyy', appendToMe)
+  addToMe += 222
+  assert_equal(333, addToMe)
 enddef
 
 func Test_assignment_failure()
@@ -195,6 +203,7 @@ let s:export_script_lines =<< trim END
 
   export const CONST = 1234
   export let exported = 9876
+  export let exp_name = 'John'
   export def Exported(): string
     return 'Exported'
   enddef
@@ -205,7 +214,14 @@ def Test_vim9script()
     vim9script
     import {exported, Exported} from './Xexport.vim'
     g:imported = exported
+    exported += 3
+    g:imported_added = exported
     g:imported_func = Exported()
+
+    import {exp_name} from './Xexport.vim'
+    g:imported_name = exp_name
+    exp_name ..= ' Doe'
+    g:imported_name_appended = exp_name
   END
 
   writefile(import_script_lines, 'Ximport.vim')
@@ -216,13 +232,18 @@ def Test_vim9script()
   assert_equal('bobbie', g:result)
   assert_equal('bob', g:localname)
   assert_equal(9876, g:imported)
+  assert_equal(9879, g:imported_added)
   assert_equal('Exported', g:imported_func)
+  assert_equal('John', g:imported_name)
+  assert_equal('John Doe', g:imported_name_appended)
   assert_false(exists('g:name'))
 
   unlet g:result
   unlet g:localname
   unlet g:imported
+  unlet g:imported_added
   unlet g:imported_func
+  unlet g:imported_name g:imported_name_appended
   delete('Ximport.vim')
   delete('Xexport.vim')
 
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    221,
+/**/
     220,
 /**/
     219,