diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-04-03 21:11:34 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-03 21:11:34 +0100 |
commit | 1061195057c4518877cb6da7591eadff9db14598 (patch) | |
tree | 808c1de42fd6a702fa2c01393f6d3f469d56a09d /src | |
parent | 0b962e5685edd41b55d5427b894797e725707639 (diff) |
patch 8.2.4678: Vim9: not all code is testedv8.2.4678
Problem: Vim9: not all code is tested.
Solution: Add a few more tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_vim9_cmd.vim | 8 | ||||
-rw-r--r-- | src/testdir/test_vim9_import.vim | 53 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 11 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9execute.c | 3 |
5 files changed, 71 insertions, 6 deletions
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index 56d3bf231b..8dea71d5f5 100644 --- 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 diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 2c7e731006..5729d73e57 100644 --- 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 diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 56842b3268..02946a315c 100644 --- 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'} ] diff --git a/src/version.c b/src/version.c index b2986d76b8..22191c9976 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4678, +/**/ 4677, /**/ 4676, diff --git a/src/vim9execute.c b/src/vim9execute.c index a6789b5999..483fe1e848 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2636,7 +2636,10 @@ exec_instructions(ectx_T *ectx) SOURCING_LNUM = iptr->isn_lnum; if (do_source(si->sn_name, FALSE, DOSO_NONE, NULL) == FAIL) + { + semsg(_(e_cant_open_file_str_2), si->sn_name); goto on_error; + } } } break; |