comparison src/testdir/vim9.vim @ 26654:e01607ab0fab v8.2.3856

patch 8.2.3856: Vim9: not enough tests Commit: https://github.com/vim/vim/commit/fea43e44c008a7ca73b506ddab0f47b63b5d2126 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 19 21:34:05 2021 +0000 patch 8.2.3856: Vim9: not enough tests Problem: Vim9: not enough tests. Solution: Run more expression tests also with Vim9. Fix an uncovered problem.
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Dec 2021 22:45:03 +0100
parents a07323eb647f
children c04b28fad0cc
comparison
equal deleted inserted replaced
26653:9838e43e6bb7 26654:e01607ab0fab
183 v->substitute('\<VAR\>', 'let', 'g') 183 v->substitute('\<VAR\>', 'let', 'g')
184 ->substitute('\<LET\>', 'let', 'g') 184 ->substitute('\<LET\>', 'let', 'g')
185 ->substitute('\<LSTART\>', '{', 'g') 185 ->substitute('\<LSTART\>', '{', 'g')
186 ->substitute('\<LMIDDLE\>', '->', 'g') 186 ->substitute('\<LMIDDLE\>', '->', 'g')
187 ->substitute('\<LEND\>', '}', 'g') 187 ->substitute('\<LEND\>', '}', 'g')
188 ->substitute('\<TRUE\>', '1', 'g')
189 ->substitute('\<FALSE\>', '0', 'g')
188 ->substitute('#"', ' "', 'g')) 190 ->substitute('#"', ' "', 'g'))
189 CheckLegacySuccess(legacylines) 191 CheckLegacySuccess(legacylines)
192 enddef
193
194 def Vim9Trans(lines: list<string>): list<string>
195 return lines->mapnew((_, v) =>
196 v->substitute('\<VAR\>', 'var', 'g')
197 ->substitute('\<LET ', '', 'g')
198 ->substitute('\<LSTART\>', '(', 'g')
199 ->substitute('\<LMIDDLE\>', ') =>', 'g')
200 ->substitute(' *\<LEND\> *', '', 'g')
201 ->substitute('\<TRUE\>', 'true', 'g')
202 ->substitute('\<FALSE\>', 'false', 'g'))
190 enddef 203 enddef
191 204
192 " Execute "lines" in a :def function, translated as in 205 " Execute "lines" in a :def function, translated as in
193 " CheckLegacyAndVim9Success() 206 " CheckLegacyAndVim9Success()
194 def CheckTransDefSuccess(lines: list<string>) 207 def CheckTransDefSuccess(lines: list<string>)
195 var vim9lines = lines->mapnew((_, v) => 208 CheckDefSuccess(Vim9Trans(lines))
196 v->substitute('\<VAR\>', 'var', 'g')
197 ->substitute('\<LET ', '', 'g')
198 ->substitute('\<LSTART\>', '(', 'g')
199 ->substitute('\<LMIDDLE\>', ') =>', 'g')
200 ->substitute(' *\<LEND\> *', '', 'g'))
201 CheckDefSuccess(vim9lines)
202 enddef 209 enddef
203 210
204 " Execute "lines" in a Vim9 script, translated as in 211 " Execute "lines" in a Vim9 script, translated as in
205 " CheckLegacyAndVim9Success() 212 " CheckLegacyAndVim9Success()
206 def CheckTransVim9Success(lines: list<string>) 213 def CheckTransVim9Success(lines: list<string>)
207 var vim9lines = lines->mapnew((_, v) => 214 CheckScriptSuccess(['vim9script'] + Vim9Trans(lines))
208 v->substitute('\<VAR\>', 'var', 'g')
209 ->substitute('\<LET ', '', 'g')
210 ->substitute('\<LSTART\>', '(', 'g')
211 ->substitute('\<LMIDDLE\>', ') =>', 'g')
212 ->substitute(' *\<LEND\> *', '', 'g'))
213 CheckScriptSuccess(['vim9script'] + vim9lines)
214 enddef 215 enddef
215 216
216 " Execute "lines" in a legacy function, :def function and Vim9 script. 217 " Execute "lines" in a legacy function, :def function and Vim9 script.
217 " Use 'VAR' for a declaration. 218 " Use 'VAR' for a declaration.
218 " Use 'LET' for an assignment 219 " Use 'LET' for an assignment
219 " Use ' #"' for a comment 220 " Use ' #"' for a comment
220 " Use LSTART arg LMIDDLE expr LEND for lambda 221 " Use LSTART arg LMIDDLE expr LEND for lambda
222 " Use 'TRUE' for 1 in legacy, true in Vim9
223 " Use 'FALSE' for 0 in legacy, false in Vim9
221 def CheckLegacyAndVim9Success(lines: list<string>) 224 def CheckLegacyAndVim9Success(lines: list<string>)
222 CheckTransLegacySuccess(lines) 225 CheckTransLegacySuccess(lines)
223 CheckTransDefSuccess(lines) 226 CheckTransDefSuccess(lines)
224 CheckTransVim9Success(lines) 227 CheckTransVim9Success(lines)
225 enddef 228 enddef