Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
20058:bc03e6cae236 | 20059:de756b3f4dee |
---|---|
8 call writefile(['def Func()'] + a:lines + ['enddef'], 'Xdef') | 8 call writefile(['def Func()'] + a:lines + ['enddef'], 'Xdef') |
9 call assert_fails('so Xdef', a:error, a:lines) | 9 call assert_fails('so Xdef', a:error, a:lines) |
10 call delete('Xdef') | 10 call delete('Xdef') |
11 endfunc | 11 endfunc |
12 | 12 |
13 func CheckScriptFailure(lines, error) | 13 def CheckScriptFailure(lines: list<string>, error: string) |
14 call writefile(a:lines, 'Xdef') | 14 writefile(lines, 'Xdef') |
15 call assert_fails('so Xdef', a:error, a:lines) | 15 assert_fails('so Xdef', error, lines) |
16 call delete('Xdef') | 16 delete('Xdef') |
17 endfunc | 17 enddef |
18 | |
19 def CheckScriptSuccess(lines: list<string>) | |
20 writefile(lines, 'Xdef') | |
21 so Xdef | |
22 delete('Xdef') | |
23 enddef | |
18 | 24 |
19 def Test_syntax() | 25 def Test_syntax() |
20 let var = 234 | 26 let var = 234 |
21 let other: list<string> = ['asdf'] | 27 let other: list<string> = ['asdf'] |
22 enddef | 28 enddef |
267 call CheckDefFailure(['5tab echo 3'], 'E16:') | 273 call CheckDefFailure(['5tab echo 3'], 'E16:') |
268 enddef | 274 enddef |
269 | 275 |
270 def Test_try_catch() | 276 def Test_try_catch() |
271 let l = [] | 277 let l = [] |
272 try | 278 try # comment |
273 add(l, '1') | 279 add(l, '1') |
274 throw 'wrong' | 280 throw 'wrong' |
275 add(l, '2') | 281 add(l, '2') |
276 catch | 282 catch # comment |
277 add(l, v:exception) | 283 add(l, v:exception) |
278 finally | 284 finally # comment |
279 add(l, '3') | 285 add(l, '3') |
280 endtry | 286 endtry # comment |
281 assert_equal(['1', 'wrong', '3'], l) | 287 assert_equal(['1', 'wrong', '3'], l) |
282 enddef | 288 enddef |
283 | 289 |
284 def ThrowFromDef() | 290 def ThrowFromDef() |
285 throw 'getout' | 291 throw 'getout' |
1001 ['one', 'two', 'three'], | 1007 ['one', 'two', 'three'], |
1002 split('one two three') | 1008 split('one two three') |
1003 ) | 1009 ) |
1004 enddef | 1010 enddef |
1005 | 1011 |
1012 def Test_vim9_comment() | |
1013 CheckScriptSuccess([ | |
1014 'vim9script', | |
1015 '# something', | |
1016 ]) | |
1017 CheckScriptFailure([ | |
1018 'vim9script', | |
1019 ':# something', | |
1020 ], 'E488:') | |
1021 CheckScriptFailure([ | |
1022 '# something', | |
1023 ], 'E488:') | |
1024 CheckScriptFailure([ | |
1025 ':# something', | |
1026 ], 'E488:') | |
1027 | |
1028 CheckScriptSuccess([ | |
1029 'vim9script', | |
1030 'echo "yes" # something', | |
1031 ]) | |
1032 CheckScriptFailure([ | |
1033 'vim9script', | |
1034 'echo "yes"# something', | |
1035 ], 'E121:') | |
1036 CheckScriptFailure([ | |
1037 'vim9script', | |
1038 'echo# something', | |
1039 ], 'E121:') | |
1040 CheckScriptFailure([ | |
1041 'echo "yes" # something', | |
1042 ], 'E121:') | |
1043 | |
1044 CheckDefFailure([ | |
1045 'try# comment', | |
1046 'echo "yes"', | |
1047 'catch', | |
1048 'endtry', | |
1049 ], 'E488:') | |
1050 CheckDefFailure([ | |
1051 'try', | |
1052 'echo "yes"', | |
1053 'catch# comment', | |
1054 'endtry', | |
1055 ], 'E488:') | |
1056 CheckDefFailure([ | |
1057 'try', | |
1058 'echo "yes"', | |
1059 'catch', | |
1060 'endtry# comment', | |
1061 ], 'E488:') | |
1062 enddef | |
1063 | |
1006 " Keep this last, it messes up highlighting. | 1064 " Keep this last, it messes up highlighting. |
1007 def Test_substitute_cmd() | 1065 def Test_substitute_cmd() |
1008 new | 1066 new |
1009 setline(1, 'something') | 1067 setline(1, 'something') |
1010 :substitute(some(other( | 1068 :substitute(some(other( |