Mercurial > vim
comparison src/testdir/test_vimscript.vim @ 19370:02111977dd05 v8.2.0243
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Commit: https://github.com/vim/vim/commit/9f6277bdde97b7767ded43a0b5a2023eb601b3b7
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 11 22:04:02 2020 +0100
patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Problem: Insufficient code coverage for ex_docmd.c functions.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5618)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 11 Feb 2020 22:15:04 +0100 |
parents | 2a017e9dc6da |
children | 67fbe280a502 |
comparison
equal
deleted
inserted
replaced
19369:05c259d4233d | 19370:02111977dd05 |
---|---|
1973 call assert_match(' line 23$', m) | 1973 call assert_match(' line 23$', m) |
1974 | 1974 |
1975 call delete('Xtest.vim') | 1975 call delete('Xtest.vim') |
1976 endfunc | 1976 endfunc |
1977 | 1977 |
1978 " Test for missing :endif, :endfor, :endwhile and :endtry {{{1 | |
1979 func Test_missing_end() | |
1980 call writefile(['if 2 > 1', 'echo ">"'], 'Xscript') | |
1981 call assert_fails('source Xscript', 'E171:') | |
1982 call writefile(['for i in range(5)', 'echo i'], 'Xscript') | |
1983 call assert_fails('source Xscript', 'E170:') | |
1984 call writefile(['while v:true', 'echo "."'], 'Xscript') | |
1985 call assert_fails('source Xscript', 'E170:') | |
1986 call writefile(['try', 'echo "."'], 'Xscript') | |
1987 call assert_fails('source Xscript', 'E600:') | |
1988 call delete('Xscript') | |
1989 endfunc | |
1990 | |
1991 " Test for deep nesting of if/for/while/try statements {{{1 | |
1992 func Test_deep_nest() | |
1993 if !CanRunVimInTerminal() | |
1994 throw 'Skipped: cannot run vim in terminal' | |
1995 endif | |
1996 | |
1997 let lines =<< trim [SCRIPT] | |
1998 " Deep nesting of if ... endif | |
1999 func Test1() | |
2000 let @a = join(repeat(['if v:true'], 51), "\n") | |
2001 let @a ..= "\n" | |
2002 let @a ..= join(repeat(['endif'], 51), "\n") | |
2003 @a | |
2004 let @a = '' | |
2005 endfunc | |
2006 | |
2007 " Deep nesting of for ... endfor | |
2008 func Test2() | |
2009 let @a = join(repeat(['for i in [1]'], 51), "\n") | |
2010 let @a ..= "\n" | |
2011 let @a ..= join(repeat(['endfor'], 51), "\n") | |
2012 @a | |
2013 let @a = '' | |
2014 endfunc | |
2015 | |
2016 " Deep nesting of while ... endwhile | |
2017 func Test3() | |
2018 let @a = join(repeat(['while v:true'], 51), "\n") | |
2019 let @a ..= "\n" | |
2020 let @a ..= join(repeat(['endwhile'], 51), "\n") | |
2021 @a | |
2022 let @a = '' | |
2023 endfunc | |
2024 | |
2025 " Deep nesting of try ... endtry | |
2026 func Test4() | |
2027 let @a = join(repeat(['try'], 51), "\n") | |
2028 let @a ..= "\necho v:true\n" | |
2029 let @a ..= join(repeat(['endtry'], 51), "\n") | |
2030 @a | |
2031 let @a = '' | |
2032 endfunc | |
2033 [SCRIPT] | |
2034 call writefile(lines, 'Xscript') | |
2035 | |
2036 let buf = RunVimInTerminal('-S Xscript', {'rows': 6}) | |
2037 | |
2038 " Deep nesting of if ... endif | |
2039 call term_sendkeys(buf, ":call Test1()\n") | |
2040 call WaitForAssert({-> assert_match('^E579:', term_getline(buf, 5))}) | |
2041 | |
2042 " Deep nesting of for ... endfor | |
2043 call term_sendkeys(buf, ":call Test2()\n") | |
2044 call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))}) | |
2045 | |
2046 " Deep nesting of while ... endwhile | |
2047 call term_sendkeys(buf, ":call Test3()\n") | |
2048 call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))}) | |
2049 | |
2050 " Deep nesting of try ... endtry | |
2051 call term_sendkeys(buf, ":call Test4()\n") | |
2052 call WaitForAssert({-> assert_match('^E601:', term_getline(buf, 5))}) | |
2053 | |
2054 "let l = '' | |
2055 "for i in range(1, 6) | |
2056 " let l ..= term_getline(buf, i) . "\n" | |
2057 "endfor | |
2058 "call assert_report(l) | |
2059 | |
2060 call StopVimInTerminal(buf) | |
2061 call delete('Xscript') | |
2062 endfunc | |
2063 | |
1978 "------------------------------------------------------------------------------- | 2064 "------------------------------------------------------------------------------- |
1979 " Modelines {{{1 | 2065 " Modelines {{{1 |
1980 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 2066 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |
1981 "------------------------------------------------------------------------------- | 2067 "------------------------------------------------------------------------------- |