diff src/testdir/test_vimscript.vim @ 19932:2c4d9ca33769 v8.2.0522

patch 8.2.0522: several errors are not tested for Commit: https://github.com/vim/vim/commit/ee4e0c1e9a81cb5d96e0060203a9033c2f28588e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 6 21:35:05 2020 +0200 patch 8.2.0522: several errors are not tested for Problem: Several errors are not tested for. Solution: Add tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5892)
author Bram Moolenaar <Bram@vim.org>
date Mon, 06 Apr 2020 21:45:31 +0200
parents b3e93a05c3ca
children 9cbe3a4f1492
line wrap: on
line diff
--- a/src/testdir/test_vimscript.vim
+++ b/src/testdir/test_vimscript.vim
@@ -1998,6 +1998,9 @@ func Test_missing_end()
   endtry
   call assert_equal(1, caught_e733)
 
+  " Using endfunc with :if
+  call assert_fails('exe "if 1 | endfunc | endif"', 'E193:')
+
   " Missing 'in' in a :for statement
   call assert_fails('for i range(1) | endfor', 'E690:')
 endfunc
@@ -2044,6 +2047,15 @@ func Test_deep_nest()
       @a
       let @a = ''
     endfunc
+
+    " Deep nesting of function ... endfunction
+    func Test5()
+      let @a = join(repeat(['function X()'], 51), "\n")
+      let @a ..= "\necho v:true\n"
+      let @a ..= join(repeat(['endfunction'], 51), "\n")
+      @a
+      let @a = ''
+    endfunc
   [SCRIPT]
   call writefile(lines, 'Xscript')
 
@@ -2051,20 +2063,31 @@ func Test_deep_nest()
 
   " Deep nesting of if ... endif
   call term_sendkeys(buf, ":call Test1()\n")
+  call term_wait(buf)
   call WaitForAssert({-> assert_match('^E579:', term_getline(buf, 5))})
 
   " Deep nesting of for ... endfor
   call term_sendkeys(buf, ":call Test2()\n")
+  call term_wait(buf)
   call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
 
   " Deep nesting of while ... endwhile
   call term_sendkeys(buf, ":call Test3()\n")
+  call term_wait(buf)
   call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
 
   " Deep nesting of try ... endtry
   call term_sendkeys(buf, ":call Test4()\n")
+  call term_wait(buf)
   call WaitForAssert({-> assert_match('^E601:', term_getline(buf, 5))})
 
+  " Deep nesting of function ... endfunction
+  call term_sendkeys(buf, ":call Test5()\n")
+  call term_wait(buf)
+  call WaitForAssert({-> assert_match('^E1058:', term_getline(buf, 4))})
+  call term_sendkeys(buf, "\<C-C>\n")
+  call term_wait(buf)
+
   "let l = ''
   "for i in range(1, 6)
   "  let l ..= term_getline(buf, i) . "\n"