Mercurial > vim
diff src/testdir/test_vim9_script.vim @ 20059:de756b3f4dee v8.2.0585
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Commit: https://github.com/vim/vim/commit/7a09224583b2ad0d9d0648b53cc2d989d45ae96e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 16 22:10:49 2020 +0200
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Problem: Vim9: # comment not recognized after :vim9script.
Solution: Check script type. Make comment after ":echo" work. And in
several other places.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 16 Apr 2020 22:15:04 +0200 |
parents | 686deb5959c2 |
children | 6e6a75800884 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -10,11 +10,17 @@ func CheckDefFailure(lines, error) call delete('Xdef') endfunc -func CheckScriptFailure(lines, error) - call writefile(a:lines, 'Xdef') - call assert_fails('so Xdef', a:error, a:lines) - call delete('Xdef') -endfunc +def CheckScriptFailure(lines: list<string>, error: string) + writefile(lines, 'Xdef') + assert_fails('so Xdef', error, lines) + delete('Xdef') +enddef + +def CheckScriptSuccess(lines: list<string>) + writefile(lines, 'Xdef') + so Xdef + delete('Xdef') +enddef def Test_syntax() let var = 234 @@ -269,15 +275,15 @@ enddef def Test_try_catch() let l = [] - try + try # comment add(l, '1') throw 'wrong' add(l, '2') - catch + catch # comment add(l, v:exception) - finally + finally # comment add(l, '3') - endtry + endtry # comment assert_equal(['1', 'wrong', '3'], l) enddef @@ -1003,6 +1009,58 @@ def Test_automatic_line_continuation() ) enddef +def Test_vim9_comment() + CheckScriptSuccess([ + 'vim9script', + '# something', + ]) + CheckScriptFailure([ + 'vim9script', + ':# something', + ], 'E488:') + CheckScriptFailure([ + '# something', + ], 'E488:') + CheckScriptFailure([ + ':# something', + ], 'E488:') + + CheckScriptSuccess([ + 'vim9script', + 'echo "yes" # something', + ]) + CheckScriptFailure([ + 'vim9script', + 'echo "yes"# something', + ], 'E121:') + CheckScriptFailure([ + 'vim9script', + 'echo# something', + ], 'E121:') + CheckScriptFailure([ + 'echo "yes" # something', + ], 'E121:') + + CheckDefFailure([ + 'try# comment', + 'echo "yes"', + 'catch', + 'endtry', + ], 'E488:') + CheckDefFailure([ + 'try', + 'echo "yes"', + 'catch# comment', + 'endtry', + ], 'E488:') + CheckDefFailure([ + 'try', + 'echo "yes"', + 'catch', + 'endtry# comment', + ], 'E488:') +enddef + " Keep this last, it messes up highlighting. def Test_substitute_cmd() new