Patch 8.2.4678
Problem:    Vim9: not all code is tested.
Solution:   Add a few more tests.
Files:      src/vim9execute.c, src/testdir/test_vim9_script.vim,
            src/testdir/test_vim9_import.vim, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.4677/src/vim9execute.c   2022-04-01 15:26:54.988558723 +0100
--- src/vim9execute.c   2022-04-03 19:46:09.277664634 +0100
***************
*** 2636,2642 ****
--- 2636,2645 ----
                        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;
*** ../vim-8.2.4677/src/testdir/test_vim9_script.vim    2022-04-03 
16:13:03.420370565 +0100
--- src/testdir/test_vim9_script.vim    2022-04-03 21:10:45.923612372 +0100
***************
*** 2130,2135 ****
--- 2130,2146 ----
        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'}
              ]
*** ../vim-8.2.4677/src/testdir/test_vim9_import.vim    2022-03-31 
16:18:19.916278625 +0100
--- src/testdir/test_vim9_import.vim    2022-04-03 20:26:55.879006212 +0100
***************
*** 858,863 ****
--- 858,865 ----
    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,944 ****
    END
    v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 
1)
  
    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)
  
!   # does not fail if the script wasn't loaded yet
    g:loaded = 'no'
    lines =<< trim END
        vim9script
--- 930,947 ----
    END
    v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 
1)
  
+   # Same, script not imported before
    lines =<< trim END
        vim9script
!       import autoload './XimportRel4.vim'
        def Func()
!         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 and only compiling
    g:loaded = 'no'
    lines =<< trim END
        vim9script
***************
*** 951,956 ****
--- 954,969 ----
    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,972 ****
--- 977,1013 ----
    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,1585 ****
    var lines =<< trim END
        vim9script
  
!       if exists('g:loaded')
          finish
        endif
!       g:loaded = 1
        delcommand CallFunc
        command CallFunc Func()
        def Func()
--- 1617,1626 ----
    var lines =<< trim END
        vim9script
  
!       if exists('g:loadedThis')
          finish
        endif
!       g:loadedThis = 1
        delcommand CallFunc
        command CallFunc Func()
        def Func()
***************
*** 1594,1600 ****
  
    delete('XreloadFunc.vim')
    delcommand CallFunc
!   unlet g:loaded
    unlet g:didTheFunc
  enddef
  
--- 1635,1641 ----
  
    delete('XreloadFunc.vim')
    delcommand CallFunc
!   unlet g:loadedThis
    unlet g:didTheFunc
  enddef
  
*** ../vim-8.2.4677/src/testdir/test_vim9_cmd.vim       2022-04-02 
19:43:53.927491819 +0100
--- src/testdir/test_vim9_cmd.vim       2022-04-03 20:43:49.016578428 +0100
***************
*** 1538,1543 ****
--- 1538,1551 ----
    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
*** ../vim-8.2.4677/src/version.c       2022-04-03 18:01:39.659574455 +0100
--- src/version.c       2022-04-03 19:20:49.113476573 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4678,
  /**/

-- 
BRIDGEKEEPER: What is your favorite editor?
GAWAIN:       Emacs ...  No, Viiiiiiiiiiimmmmmmm!
           "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220403201213.43A081C0561%40moolenaar.net.

Raspunde prin e-mail lui