diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-06 18:50:36 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-06 18:50:36 +0100 |
commit | 5402175815a9b9b05772f339efa3ec9f73bdae09 (patch) | |
tree | 35e7d1e656a2c21b659272938de42f9300897068 | |
parent | 8bb0f5472c740458708fd3edabbb8d5193a96241 (diff) |
patch 8.2.2102: Vim9: not all error messages testedv8.2.2102
Problem: Vim9: not all error messages tested.
Solution: Add a few test cases.
-rw-r--r-- | src/testdir/test_vim9_func.vim | 66 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 52 insertions, 16 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index f831c7199c..aabc373333 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -217,22 +217,47 @@ def Test_nested_function() CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:') CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:') - CheckDefFailure([ - 'def Outer()', - ' def Inner()', - ' # comment', - ' enddef', - ' def Inner()', - ' enddef', - 'enddef'], 'E1073:') - CheckDefFailure([ - 'def Outer()', - ' def Inner()', - ' # comment', - ' enddef', - ' def! Inner()', - ' enddef', - 'enddef'], 'E1117:') + var lines =<< trim END + def Outer() + def Inner() + # comment + enddef + def Inner() + enddef + enddef + END + CheckDefFailure(lines, 'E1073:') + + lines =<< trim END + def Outer() + def Inner() + # comment + enddef + def! Inner() + enddef + enddef + END + CheckDefFailure(lines, 'E1117:') + + # nested function inside conditional + # TODO: should it work when "thecount" is inside the "if"? + lines =<< trim END + vim9script + var thecount = 0 + if true + def Test(): number + def TheFunc(): number + thecount += 1 + return thecount + enddef + return TheFunc() + enddef + endif + defcompile + assert_equal(1, Test()) + assert_equal(2, Test()) + END + CheckScriptSuccess(lines) enddef func Test_call_default_args_from_func() @@ -315,6 +340,15 @@ def Test_nested_def_list() assert_true(funcs->index('def DefListAll()') >= 0) assert_true(funcs->index('def DefListOne()') >= 0) assert_true(funcs->index('def DefListMatches()') >= 0) + + var lines =<< trim END + vim9script + def Func() + def +Func+ + enddef + defcompile + END + CheckScriptFailure(lines, 'E476:', 1) enddef def Test_global_local_function() diff --git a/src/version.c b/src/version.c index 56cea2657d..f023d974a7 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2102, +/**/ 2101, /**/ 2100, |