comparison src/testdir/test_vim9_script.vim @ 23358:b3142fc0a414 v8.2.2222

patch 8.2.2222: Vim9: cannot keep script variables when reloading Commit: https://github.com/vim/vim/commit/2b32700dabf392566d8e9fef76e0d587a891ee3e Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 26 15:39:31 2020 +0100 patch 8.2.2222: Vim9: cannot keep script variables when reloading Problem: Vim9: cannot keep script variables when reloading. Solution: Add the "noclear" argument to :vim9script.
author Bram Moolenaar <Bram@vim.org>
date Sat, 26 Dec 2020 15:45:04 +0100
parents 13572a262b15
children eb7d8f39363c
comparison
equal deleted inserted replaced
23357:2cd9078b4d97 23358:b3142fc0a414
1154 rows: 6, wait_for_ruler: 0}) 1154 rows: 6, wait_for_ruler: 0})
1155 WaitForAssert({-> assert_match('^E1094:', term_getline(buf, 5))}) 1155 WaitForAssert({-> assert_match('^E1094:', term_getline(buf, 5))})
1156 1156
1157 delete('XexportCmd.vim') 1157 delete('XexportCmd.vim')
1158 StopVimInTerminal(buf) 1158 StopVimInTerminal(buf)
1159 enddef
1160
1161 def Test_vim9script_reload_noclear()
1162 var lines =<< trim END
1163 vim9script noclear
1164 g:loadCount += 1
1165 var s:reloaded = 'init'
1166
1167 def Again(): string
1168 return 'again'
1169 enddef
1170
1171 if exists('s:loaded') | finish | endif
1172 var s:loaded = true
1173
1174 var s:notReloaded = 'yes'
1175 s:reloaded = 'first'
1176 def g:Values(): list<string>
1177 return [s:reloaded, s:notReloaded, Once()]
1178 enddef
1179 def g:CallAgain(): string
1180 return Again()
1181 enddef
1182
1183 def Once(): string
1184 return 'once'
1185 enddef
1186 END
1187 writefile(lines, 'XReloaded')
1188 g:loadCount = 0
1189 source XReloaded
1190 assert_equal(1, g:loadCount)
1191 assert_equal(['first', 'yes', 'once'], g:Values())
1192 assert_equal('again', g:CallAgain())
1193 source XReloaded
1194 assert_equal(2, g:loadCount)
1195 assert_equal(['init', 'yes', 'once'], g:Values())
1196 assert_fails('call g:CallAgain()', 'E933:')
1197 source XReloaded
1198 assert_equal(3, g:loadCount)
1199 assert_equal(['init', 'yes', 'once'], g:Values())
1200 assert_fails('call g:CallAgain()', 'E933:')
1201
1202 delete('Xreloaded')
1203 delfunc g:Values
1204 delfunc g:CallAgain
1205 unlet g:loadCount
1159 enddef 1206 enddef
1160 1207
1161 def Test_vim9script_reload_import() 1208 def Test_vim9script_reload_import()
1162 var lines =<< trim END 1209 var lines =<< trim END
1163 vim9script 1210 vim9script