diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-07-12 06:24:29 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-12 06:24:29 +0800 |
| commit | daa49b525e5c55958e9854cd463a763791e6600b (patch) | |
| tree | 7203add5f3ae1ca1dcc32334beb5f985543cb37c /src/nvim/testdir/test_vimscript.vim | |
| parent | 5c3bbb67e7c59b2fa18e37fdd9845a0e7e3381db (diff) | |
| parent | 27fd17a79cd2c51e71077bdd896635188ad711b5 (diff) | |
| download | rneovim-daa49b525e5c55958e9854cd463a763791e6600b.tar.gz rneovim-daa49b525e5c55958e9854cd463a763791e6600b.tar.bz2 rneovim-daa49b525e5c55958e9854cd463a763791e6600b.zip | |
Merge pull request #19320 from zeertzjq/vim-8.2.0212
vim-patch:8.2.{0212,0243,0250}: insufficient tests
Diffstat (limited to 'src/nvim/testdir/test_vimscript.vim')
| -rw-r--r-- | src/nvim/testdir/test_vimscript.vim | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim index f93eb6e274..c933f2443e 100644 --- a/src/nvim/testdir/test_vimscript.vim +++ b/src/nvim/testdir/test_vimscript.vim @@ -1771,6 +1771,92 @@ func Test_function_defined_line() call delete('Xtest.vim') endfunc +" Test for missing :endif, :endfor, :endwhile and :endtry {{{1 +func Test_missing_end() + call writefile(['if 2 > 1', 'echo ">"'], 'Xscript') + call assert_fails('source Xscript', 'E171:') + call writefile(['for i in range(5)', 'echo i'], 'Xscript') + call assert_fails('source Xscript', 'E170:') + call writefile(['while v:true', 'echo "."'], 'Xscript') + call assert_fails('source Xscript', 'E170:') + call writefile(['try', 'echo "."'], 'Xscript') + call assert_fails('source Xscript', 'E600:') + call delete('Xscript') +endfunc + +" Test for deep nesting of if/for/while/try statements {{{1 +func Test_deep_nest() + if !CanRunVimInTerminal() + throw 'Skipped: cannot run vim in terminal' + endif + + let lines =<< trim [SCRIPT] + " Deep nesting of if ... endif + func Test1() + let @a = join(repeat(['if v:true'], 51), "\n") + let @a ..= "\n" + let @a ..= join(repeat(['endif'], 51), "\n") + @a + let @a = '' + endfunc + + " Deep nesting of for ... endfor + func Test2() + let @a = join(repeat(['for i in [1]'], 51), "\n") + let @a ..= "\n" + let @a ..= join(repeat(['endfor'], 51), "\n") + @a + let @a = '' + endfunc + + " Deep nesting of while ... endwhile + func Test3() + let @a = join(repeat(['while v:true'], 51), "\n") + let @a ..= "\n" + let @a ..= join(repeat(['endwhile'], 51), "\n") + @a + let @a = '' + endfunc + + " Deep nesting of try ... endtry + func Test4() + let @a = join(repeat(['try'], 51), "\n") + let @a ..= "\necho v:true\n" + let @a ..= join(repeat(['endtry'], 51), "\n") + @a + let @a = '' + endfunc + [SCRIPT] + call writefile(lines, 'Xscript') + + let buf = RunVimInTerminal('-S Xscript', {'rows': 6}) + + " Deep nesting of if ... endif + call term_sendkeys(buf, ":call Test1()\n") + call WaitForAssert({-> assert_match('^E579:', term_getline(buf, 5))}) + + " Deep nesting of for ... endfor + call term_sendkeys(buf, ":call Test2()\n") + call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))}) + + " Deep nesting of while ... endwhile + call term_sendkeys(buf, ":call Test3()\n") + call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))}) + + " Deep nesting of try ... endtry + call term_sendkeys(buf, ":call Test4()\n") + call WaitForAssert({-> assert_match('^E601:', term_getline(buf, 5))}) + + "let l = '' + "for i in range(1, 6) + " let l ..= term_getline(buf, i) . "\n" + "endfor + "call assert_report(l) + + call StopVimInTerminal(buf) + call delete('Xscript') +endfunc + func Test_for_over_string() let res = '' for c in 'aéc̀d' |