Mercurial > vim
changeset 28305:c4b2aa8e1ee1 v8.2.4678
patch 8.2.4678: Vim9: not all code is tested
Commit: https://github.com/vim/vim/commit/1061195057c4518877cb6da7591eadff9db14598
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 3 21:11:34 2022 +0100
patch 8.2.4678: Vim9: not all code is tested
Problem: Vim9: not all code is tested.
Solution: Add a few more tests.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 03 Apr 2022 22:15:04 +0200 |
parents | 8462f16d2e7f |
children | 371e6bb623ad |
files | src/testdir/test_vim9_cmd.vim src/testdir/test_vim9_import.vim src/testdir/test_vim9_script.vim src/version.c src/vim9execute.c |
diffstat | 5 files changed, 71 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1538,6 +1538,14 @@ def Test_lockvar() d.a = 7 assert_equal({a: 7, b: 5}, d) + caught = false + try + lockvar d.c + catch /E716/ + caught = true + endtry + assert_true(caught) + var lines =<< trim END vim9script g:bl = 0z1122
--- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -858,6 +858,8 @@ def Test_autoload_import_relative() writefile(lines, 'XimportRel.vim') writefile(lines, 'XimportRel2.vim') writefile(lines, 'XimportRel3.vim') + writefile(lines, 'XimportRel4.vim') + writefile(lines, 'XimportRel5.vim') lines =<< trim END vim9script @@ -928,17 +930,18 @@ def Test_autoload_import_relative() END v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1) + # Same, script not imported before lines =<< trim END vim9script - import autoload './XimportRel.vim' + import autoload './XimportRel4.vim' def Func() - XimportRel.notexp = 'bad' + echo XimportRel4.notexp enddef Func() END v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1) - # does not fail if the script wasn't loaded yet + # does not fail if the script wasn't loaded yet and only compiling g:loaded = 'no' lines =<< trim END vim9script @@ -951,6 +954,16 @@ def Test_autoload_import_relative() v9.CheckScriptSuccess(lines) assert_equal('no', g:loaded) + lines =<< trim END + vim9script + import autoload './XimportRel.vim' + def Func() + XimportRel.notexp = 'bad' + enddef + Func() + END + v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1) + # fails with a not loaded import lines =<< trim END vim9script @@ -964,9 +977,37 @@ def Test_autoload_import_relative() assert_equal('yes', g:loaded) unlet g:loaded + lines =<< trim END + vim9script + import autoload './XimportRel5.vim' + def Func() + XimportRel5.nosuchvar = 'bad' + enddef + Func() + END + v9.CheckScriptFailure(lines, 'E121: Undefined variable: nosuchvar', 1) + unlet g:loaded + + # nasty: delete script after compiling function + writefile(['vim9script'], 'XimportRelDel.vim') + lines =<< trim END + vim9script + + import autoload './XimportRelDel.vim' + def DoIt() + echo XimportRelDel.var + enddef + defcompile + delete('XimportRelDel.vim') + DoIt() + END + v9.CheckScriptFailure(lines, 'E456:') + delete('XimportRel.vim') delete('XimportRel2.vim') delete('XimportRel3.vim') + delete('XimportRel4.vim') + delete('XimportRel5.vim') enddef def Test_autoload_import_relative_autoload_dir() @@ -1576,10 +1617,10 @@ def Test_script_reload_from_function() var lines =<< trim END vim9script - if exists('g:loaded') + if exists('g:loadedThis') finish endif - g:loaded = 1 + g:loadedThis = 1 delcommand CallFunc command CallFunc Func() def Func() @@ -1594,7 +1635,7 @@ def Test_script_reload_from_function() delete('XreloadFunc.vim') delcommand CallFunc - unlet g:loaded + unlet g:loadedThis unlet g:didTheFunc enddef
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -2130,6 +2130,17 @@ def Test_for_loop() endfor assert_equal('', res) + total = 0 + for c in null_list + total += 1 + endfor + assert_equal(0, total) + + for c in null_blob + total += 1 + endfor + assert_equal(0, total) + var foo: list<dict<any>> = [ {a: 'Cat'} ]