diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-14 20:35:23 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-14 20:35:23 +0200 |
commit | 0e3ff1919603ee4c4a347fdf761dbdbdeb068015 (patch) | |
tree | db3dc3df238da3a1c44116827796157cdd3346f0 /src/testdir/vim9.vim | |
parent | b47bed2f7ada4dfae78f76f27473b83507e40315 (diff) | |
download | vim-git-0e3ff1919603ee4c4a347fdf761dbdbdeb068015.tar.gz |
patch 8.2.2765: Vim9: not all blob operations workv8.2.2765
Problem: Vim9: not all blob operations work.
Solution: Run more tests also with Vim9 script and :def functions. Fix what
doesn't work.
Diffstat (limited to 'src/testdir/vim9.vim')
-rw-r--r-- | src/testdir/vim9.vim | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/testdir/vim9.vim b/src/testdir/vim9.vim index e05f8590b..9efa65552 100644 --- a/src/testdir/vim9.vim +++ b/src/testdir/vim9.vim @@ -144,8 +144,23 @@ func CheckLegacySuccess(lines) try exe 'so ' .. fname call Func() + finally delfunc! Func + call chdir(cwd) + call delete(fname) + endtry +endfunc + +" Check that "lines" inside a legacy function results in the expected error +func CheckLegacyFailure(lines, error) + let cwd = getcwd() + let fname = 'XlegacyFails' .. s:sequence + let s:sequence += 1 + call writefile(['func Func()'] + a:lines + ['endfunc', 'call Func()'], fname) + try + call assert_fails('so ' .. fname, a:error) finally + delfunc! Func call chdir(cwd) call delete(fname) endtry @@ -168,3 +183,35 @@ def CheckLegacyAndVim9Success(lines: list<string>) CheckDefSuccess(vim9lines) CheckScriptSuccess(['vim9script'] + vim9lines) enddef + +" Execute "lines" in a legacy function, :def function and Vim9 script. +" Use 'VAR' for a declaration. +" Use 'LET' for an assignment +" Use ' #"' for a comment +def CheckLegacyAndVim9Failure(lines: list<string>, error: any) + var legacyError: string + var defError: string + var scriptError: string + + if type(error) == type('string') + legacyError = error + defError = error + scriptError = error + else + legacyError = error[0] + defError = error[1] + scriptError = error[2] + endif + + var legacylines = lines->mapnew((_, v) => + v->substitute('\<VAR\>', 'let', 'g') + ->substitute('\<LET\>', 'let', 'g') + ->substitute('#"', ' "', 'g')) + CheckLegacyFailure(legacylines, legacyError) + + var vim9lines = lines->mapnew((_, v) => + v->substitute('\<VAR\>', 'var', 'g') + ->substitute('\<LET ', '', 'g')) + CheckDefExecFailure(vim9lines, defError) + CheckScriptFailure(['vim9script'] + vim9lines, scriptError) +enddef |