Mercurial > vim
view src/testdir/vim9.vim @ 24246:35603c7991d7 v8.2.2664
patch 8.2.2664: Vim9: not enough function arguments checked for string
Commit: https://github.com/vim/vim/commit/32105ae88f3aa6a6af30336f0bc9f8eb81292cd7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 27 18:59:25 2021 +0100
patch 8.2.2664: Vim9: not enough function arguments checked for string
Problem: Vim9: not enough function arguments checked for string.
Solution: Check in balloon functions. Refactor function arguments.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Mar 2021 19:00:04 +0100 |
parents | e8c379b20765 |
children | 236e9ebdb30e |
line wrap: on
line source
" Utility functions for testing vim9 script " Use a different file name for each run. let s:sequence = 1 " Check that "lines" inside a ":def" function has no error. func CheckDefSuccess(lines) let cwd = getcwd() let fname = 'XdefSuccess' .. s:sequence let s:sequence += 1 call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname) try exe 'so ' .. fname call Func() delfunc! Func finally call chdir(cwd) call delete(fname) endtry endfunc " Check that "lines" inside ":def" results in an "error" message. " If "lnum" is given check that the error is reported for this line. " Add a line before and after to make it less likely that the line number is " accidentally correct. func CheckDefFailure(lines, error, lnum = -3) let cwd = getcwd() let fname = 'XdefFailure' .. s:sequence let s:sequence += 1 call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], fname) try call assert_fails('so ' .. fname, a:error, a:lines, a:lnum + 1) finally call chdir(cwd) call delete(fname) delfunc! Func endtry endfunc " Check that "lines" inside ":def" results in an "error" message when executed. " If "lnum" is given check that the error is reported for this line. " Add a line before and after to make it less likely that the line number is " accidentally correct. func CheckDefExecFailure(lines, error, lnum = -3) let cwd = getcwd() let fname = 'XdefExecFailure' .. s:sequence let s:sequence += 1 call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], fname) try exe 'so ' .. fname call assert_fails('call Func()', a:error, a:lines, a:lnum + 1) finally call chdir(cwd) call delete(fname) delfunc! Func endtry endfunc def CheckScriptFailure(lines: list<string>, error: string, lnum = -3) var cwd = getcwd() var fname = 'XScriptFailure' .. s:sequence s:sequence += 1 writefile(lines, fname) try assert_fails('so ' .. fname, error, lines, lnum) finally chdir(cwd) delete(fname) endtry enddef def CheckScriptFailureList(lines: list<string>, errors: list<string>, lnum = -3) var cwd = getcwd() var fname = 'XScriptFailure' .. s:sequence s:sequence += 1 writefile(lines, fname) try assert_fails('so ' .. fname, errors, lines, lnum) finally chdir(cwd) delete(fname) endtry enddef def CheckScriptSuccess(lines: list<string>) var cwd = getcwd() var fname = 'XScriptSuccess' .. s:sequence s:sequence += 1 writefile(lines, fname) try exe 'so ' .. fname finally chdir(cwd) delete(fname) endtry enddef def CheckDefAndScriptSuccess(lines: list<string>) CheckDefSuccess(lines) CheckScriptSuccess(['vim9script'] + lines) enddef " Check that a command fails with the same error when used in a :def function " and when used in Vim9 script. def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3) CheckDefFailure(lines, error, lnum) CheckScriptFailure(['vim9script'] + lines, error, lnum + 1) enddef " Check that a command fails with the same error when executed in a :def " function and when used in Vim9 script. def CheckDefExecAndScriptFailure(lines: list<string>, error: string, lnum = -3) CheckDefExecFailure(lines, error, lnum) CheckScriptFailure(['vim9script'] + lines, error, lnum + 1) enddef