diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-03-25 22:15:28 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-03-25 22:15:28 +0100 |
commit | fa984418e7becd8e7d6543cd3ea25f605e9ac97f (patch) | |
tree | 1e8b4185c415271d0d51f74cd56dab2ad05b7ff5 /src/testdir | |
parent | a91a71322dc2e6a1640e73b6da1f1a2f94f39a54 (diff) |
patch 8.2.2652: Vim9: can use command modifier without an effectv8.2.2652
Problem: Vim9: can use command modifier without an effect.
Solution: Give an error for a misplaced command modifier. Fix error message
number.
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 6 | ||||
-rw-r--r-- | src/testdir/test_vim9_cmd.vim | 49 | ||||
-rw-r--r-- | src/testdir/test_vim9_disassemble.vim | 12 |
3 files changed, 58 insertions, 9 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index b6f387666f..25db01288f 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -247,7 +247,7 @@ enddef def Test_exepath() CheckDefExecFailure(['echo exepath(true)'], 'E1174:') CheckDefExecFailure(['echo exepath(v:null)'], 'E1174:') - CheckDefExecFailure(['echo exepath("")'], 'E1142:') + CheckDefExecFailure(['echo exepath("")'], 'E1175:') enddef def Test_expand() @@ -406,13 +406,13 @@ enddef def Test_finddir() CheckDefExecFailure(['echo finddir(true)'], 'E1174:') CheckDefExecFailure(['echo finddir(v:null)'], 'E1174:') - CheckDefExecFailure(['echo finddir("")'], 'E1142:') + CheckDefExecFailure(['echo finddir("")'], 'E1175:') enddef def Test_findfile() CheckDefExecFailure(['echo findfile(true)'], 'E1174:') CheckDefExecFailure(['echo findfile(v:null)'], 'E1174:') - CheckDefExecFailure(['echo findfile("")'], 'E1142:') + CheckDefExecFailure(['echo findfile("")'], 'E1175:') enddef def Test_flattennew() diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index c276a7e6f5..bc4cfa6e16 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -797,6 +797,55 @@ def Test_silent_pattern() bwipe! enddef +def Test_useless_command_modifier() + g:maybe = true + var lines =<< trim END + if g:maybe + silent endif + END + CheckDefAndScriptFailure(lines, 'E1176:', 2) + + lines =<< trim END + for i in [0] + silent endfor + END + CheckDefAndScriptFailure(lines, 'E1176:', 2) + + lines =<< trim END + while g:maybe + silent endwhile + END + CheckDefAndScriptFailure(lines, 'E1176:', 2) + + lines =<< trim END + silent try + finally + endtry + END + CheckDefAndScriptFailure(lines, 'E1176:', 1) + + lines =<< trim END + try + silent catch + endtry + END + CheckDefAndScriptFailure(lines, 'E1176:', 2) + + lines =<< trim END + try + silent finally + endtry + END + CheckDefAndScriptFailure(lines, 'E1176:', 2) + + lines =<< trim END + try + finally + silent endtry + END + CheckDefAndScriptFailure(lines, 'E1176:', 3) +enddef + def Test_eval_command() var from = 3 var to = 5 diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim index 5d3e4faa69..bb74fada07 100644 --- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -1903,7 +1903,7 @@ enddef def s:SilentIf() silent if 4 == g:five silent elseif 4 == g:five - silent endif + endif enddef def Test_silent_if() @@ -1924,14 +1924,14 @@ def Test_silent_if() '\d\+ COMPAREANY ==\_s*' .. '\d\+ CMDMOD_REV\_s*' .. '\d\+ JUMP_IF_FALSE -> \d\+\_s*' .. - 'silent endif\_s*' .. + 'endif\_s*' .. '\d\+ RETURN 0', res) enddef def s:SilentFor() silent for i in [0] - silent endfor + endfor enddef def Test_silent_for() @@ -1945,7 +1945,7 @@ def Test_silent_for() '\d CMDMOD_REV\_s*' .. '5 FOR $0 -> 8\_s*' .. '\d STORE $1\_s*' .. - 'silent endfor\_s*' .. + 'endfor\_s*' .. '\d JUMP -> 5\_s*' .. '8 DROP\_s*' .. '\d RETURN 0\_s*', @@ -1954,7 +1954,7 @@ enddef def s:SilentWhile() silent while g:not - silent endwhile + endwhile enddef def Test_silent_while() @@ -1967,7 +1967,7 @@ def Test_silent_while() '\d CMDMOD_REV\_s*' .. '\d JUMP_IF_FALSE -> 6\_s*' .. - 'silent endwhile\_s*' .. + 'endwhile\_s*' .. '\d JUMP -> 0\_s*' .. '6 RETURN 0\_s*', res) |