Skip to content

Commit 5402175

Browse files
committed
patch 8.2.2102: Vim9: not all error messages tested
Problem: Vim9: not all error messages tested. Solution: Add a few test cases.
1 parent 8bb0f54 commit 5402175

2 files changed

Lines changed: 52 additions & 16 deletions

File tree

src/testdir/test_vim9_func.vim

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,47 @@ def Test_nested_function()
217217
CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:')
218218
CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:')
219219

220-
CheckDefFailure([
221-
'def Outer()',
222-
' def Inner()',
223-
' # comment',
224-
' enddef',
225-
' def Inner()',
226-
' enddef',
227-
'enddef'], 'E1073:')
228-
CheckDefFailure([
229-
'def Outer()',
230-
' def Inner()',
231-
' # comment',
232-
' enddef',
233-
' def! Inner()',
234-
' enddef',
235-
'enddef'], 'E1117:')
220+
var lines =<< trim END
221+
def Outer()
222+
def Inner()
223+
# comment
224+
enddef
225+
def Inner()
226+
enddef
227+
enddef
228+
END
229+
CheckDefFailure(lines, 'E1073:')
230+
231+
lines =<< trim END
232+
def Outer()
233+
def Inner()
234+
# comment
235+
enddef
236+
def! Inner()
237+
enddef
238+
enddef
239+
END
240+
CheckDefFailure(lines, 'E1117:')
241+
242+
# nested function inside conditional
243+
# TODO: should it work when "thecount" is inside the "if"?
244+
lines =<< trim END
245+
vim9script
246+
var thecount = 0
247+
if true
248+
def Test(): number
249+
def TheFunc(): number
250+
thecount += 1
251+
return thecount
252+
enddef
253+
return TheFunc()
254+
enddef
255+
endif
256+
defcompile
257+
assert_equal(1, Test())
258+
assert_equal(2, Test())
259+
END
260+
CheckScriptSuccess(lines)
236261
enddef
237262

238263
func Test_call_default_args_from_func()
@@ -315,6 +340,15 @@ def Test_nested_def_list()
315340
assert_true(funcs->index('def DefListAll()') >= 0)
316341
assert_true(funcs->index('def DefListOne()') >= 0)
317342
assert_true(funcs->index('def DefListMatches()') >= 0)
343+
344+
var lines =<< trim END
345+
vim9script
346+
def Func()
347+
def +Func+
348+
enddef
349+
defcompile
350+
END
351+
CheckScriptFailure(lines, 'E476:', 1)
318352
enddef
319353

320354
def Test_global_local_function()

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2102,
753755
/**/
754756
2101,
755757
/**/

0 commit comments

Comments
 (0)