Skip to content

Commit 3e9c0b9

Browse files
committed
patch 8.2.3333: Vim9: not enough tests run with Vim9
Problem: Vim9: not enough tests run with Vim9. Solution: Run a few more tests in Vim9 script and :def function.
1 parent 4f0884d commit 3e9c0b9

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

src/testdir/test_listdict.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,19 @@ func Test_dict_func_remove_in_use()
457457
endfunc
458458
let expected = 'a:' . string(get(d, 'func'))
459459
call assert_equal(expected, d.func(string(remove(d, 'func'))))
460+
461+
" similar, in a way it also works in Vim9
462+
let lines =<< trim END
463+
VAR d = {1: 1, 2: 'x'}
464+
func GetArg(a)
465+
return "a:" .. a:a
466+
endfunc
467+
LET d.func = function('GetArg')
468+
VAR expected = 'a:' .. string(get(d, 'func'))
469+
call assert_equal(expected, d.func(string(remove(d, 'func'))))
470+
END
471+
call CheckTransLegacySuccess(lines)
472+
call CheckTransVim9Success(lines)
460473
endfunc
461474

462475
func Test_dict_literal_keys()

src/testdir/vim9.vim

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3)
107107
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
108108
enddef
109109

110-
" As CheckDefAndScriptFailure() but with two different exepected errors.
110+
" As CheckDefAndScriptFailure() but with two different expected errors.
111111
def CheckDefAndScriptFailure2(
112112
lines: list<string>,
113113
errorDef: string,
@@ -166,24 +166,44 @@ func CheckLegacyFailure(lines, error)
166166
endtry
167167
endfunc
168168

169-
" Execute "lines" in a legacy function, :def function and Vim9 script.
170-
" Use 'VAR' for a declaration.
171-
" Use 'LET' for an assignment
172-
" Use ' #"' for a comment
173-
def CheckLegacyAndVim9Success(lines: list<string>)
169+
" Execute "lines" in a legacy function, translated as in
170+
" CheckLegacyAndVim9Success()
171+
def CheckTransLegacySuccess(lines: list<string>)
174172
var legacylines = lines->mapnew((_, v) =>
175173
v->substitute('\<VAR\>', 'let', 'g')
176174
->substitute('\<LET\>', 'let', 'g')
177175
->substitute('#"', ' "', 'g'))
178176
CheckLegacySuccess(legacylines)
177+
enddef
179178

179+
" Execute "lines" in a :def function, translated as in
180+
" CheckLegacyAndVim9Success()
181+
def CheckTransDefSuccess(lines: list<string>)
180182
var vim9lines = lines->mapnew((_, v) =>
181183
v->substitute('\<VAR\>', 'var', 'g')
182184
->substitute('\<LET ', '', 'g'))
183185
CheckDefSuccess(vim9lines)
186+
enddef
187+
188+
" Execute "lines" in a Vim9 script, translated as in
189+
" CheckLegacyAndVim9Success()
190+
def CheckTransVim9Success(lines: list<string>)
191+
var vim9lines = lines->mapnew((_, v) =>
192+
v->substitute('\<VAR\>', 'var', 'g')
193+
->substitute('\<LET ', '', 'g'))
184194
CheckScriptSuccess(['vim9script'] + vim9lines)
185195
enddef
186196

197+
" Execute "lines" in a legacy function, :def function and Vim9 script.
198+
" Use 'VAR' for a declaration.
199+
" Use 'LET' for an assignment
200+
" Use ' #"' for a comment
201+
def CheckLegacyAndVim9Success(lines: list<string>)
202+
CheckTransLegacySuccess(lines)
203+
CheckTransDefSuccess(lines)
204+
CheckTransVim9Success(lines)
205+
enddef
206+
187207
" Execute "lines" in a legacy function, :def function and Vim9 script.
188208
" Use 'VAR' for a declaration.
189209
" Use 'LET' for an assignment

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3333,
758760
/**/
759761
3332,
760762
/**/

0 commit comments

Comments
 (0)