Patch 8.2.0493
Problem:    Vim9: some error messages not tested.
Solution:   Add more tests.  Fix uncovered bugs.
Files:      src/vim9compile.c, src/vim9execute.c, src/testing.c, src/eval.c,
            src/proto/testing.pro, src/evalfunc.c, runtime/doc/eval.txt,
            runtime/doc/testing.txt, src/testdir/test_vim9_script.vim


*** ../vim-8.2.0492/src/vim9compile.c   2020-04-01 21:17:17.268409971 +0200
--- src/vim9compile.c   2020-04-01 21:56:05.895613546 +0200
***************
*** 766,772 ****
  
  /*
   * Generate an ISN_PUSHPARTIAL instruction with partial "part".
!  * Consumes "name".
   */
      static int
  generate_PUSHPARTIAL(cctx_T *cctx, partial_T *part)
--- 766,772 ----
  
  /*
   * Generate an ISN_PUSHPARTIAL instruction with partial "part".
!  * Consumes "part".
   */
      static int
  generate_PUSHPARTIAL(cctx_T *cctx, partial_T *part)
***************
*** 3808,3816 ****
            case VAR_BOOL:
                generate_PUSHBOOL(cctx, VVAL_FALSE);
                break;
-           case VAR_SPECIAL:
-               generate_PUSHSPEC(cctx, VVAL_NONE);
-               break;
            case VAR_FLOAT:
  #ifdef FEAT_FLOAT
                generate_PUSHF(cctx, 0.0);
--- 3808,3813 ----
***************
*** 3843,3848 ****
--- 3840,3846 ----
            case VAR_NUMBER:
            case VAR_UNKNOWN:
            case VAR_VOID:
+           case VAR_SPECIAL:  // cannot happen
                generate_PUSHNR(cctx, 0);
                break;
        }
*** ../vim-8.2.0492/src/vim9execute.c   2020-04-01 21:17:17.268409971 +0200
--- src/vim9execute.c   2020-04-01 21:47:21.909589372 +0200
***************
*** 920,926 ****
                        break;
                    default:
                        tv->v_type = VAR_STRING;
!                       tv->vval.v_string = vim_strsave(iptr->isn_arg.string);
                }
                break;
  
--- 920,928 ----
                        break;
                    default:
                        tv->v_type = VAR_STRING;
!                       tv->vval.v_string = vim_strsave(
!                               iptr->isn_arg.string == NULL
!                                       ? (char_u *)"" : iptr->isn_arg.string);
                }
                break;
  
*** ../vim-8.2.0492/src/testing.c       2020-02-22 19:07:24.393786830 +0100
--- src/testing.c       2020-04-01 21:50:55.828781604 +0200
***************
*** 883,888 ****
--- 883,895 ----
  }
  
      void
+ f_test_null_function(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+     rettv->v_type = VAR_FUNC;
+     rettv->vval.v_string = NULL;
+ }
+ 
+     void
  f_test_null_partial(typval_T *argvars UNUSED, typval_T *rettv)
  {
      rettv->v_type = VAR_PARTIAL;
*** ../vim-8.2.0492/src/eval.c  2020-03-23 22:12:15.496961030 +0100
--- src/eval.c  2020-04-01 22:01:22.034424432 +0200
***************
*** 3849,3856 ****
            return tv1->vval.v_channel == tv2->vval.v_channel;
  #endif
  
-       case VAR_FUNC:
        case VAR_PARTIAL:
        case VAR_UNKNOWN:
        case VAR_VOID:
            break;
--- 3849,3860 ----
            return tv1->vval.v_channel == tv2->vval.v_channel;
  #endif
  
        case VAR_PARTIAL:
+           return tv1->vval.v_partial == tv2->vval.v_partial;
+ 
+       case VAR_FUNC:
+           return tv1->vval.v_string == tv2->vval.v_string;
+ 
        case VAR_UNKNOWN:
        case VAR_VOID:
            break;
*** ../vim-8.2.0492/src/proto/testing.pro       2020-02-22 19:07:24.393786830 
+0100
--- src/proto/testing.pro       2020-04-01 21:54:50.947895699 +0200
***************
*** 26,31 ****
--- 26,32 ----
  void f_test_null_dict(typval_T *argvars, typval_T *rettv);
  void f_test_null_job(typval_T *argvars, typval_T *rettv);
  void f_test_null_list(typval_T *argvars, typval_T *rettv);
+ void f_test_null_function(typval_T *argvars, typval_T *rettv);
  void f_test_null_partial(typval_T *argvars, typval_T *rettv);
  void f_test_null_string(typval_T *argvars, typval_T *rettv);
  void f_test_unknown(typval_T *argvars, typval_T *rettv);
*** ../vim-8.2.0492/src/evalfunc.c      2020-03-27 20:52:41.350231375 +0100
--- src/evalfunc.c      2020-04-01 21:57:21.383329567 +0200
***************
*** 290,296 ****
  {
      return &t_string;
  }
!     static type_T * ret_list_any(int argcount UNUSED, type_T **argtypes 
UNUSED)
  {
      return &t_list_any;
  }
--- 290,297 ----
  {
      return &t_string;
  }
!     static type_T *
! ret_list_any(int argcount UNUSED, type_T **argtypes UNUSED)
  {
      return &t_list_any;
  }
***************
*** 330,338 ****
      return &t_blob;
  }
      static type_T *
! ret_partial_void(int argcount UNUSED, type_T **argtypes UNUSED)
  {
!     return &t_partial_void;
  }
      static type_T *
  ret_channel(int argcount UNUSED, type_T **argtypes UNUSED)
--- 331,344 ----
      return &t_blob;
  }
      static type_T *
! ret_func_any(int argcount UNUSED, type_T **argtypes UNUSED)
! {
!     return &t_func_any;
! }
!     static type_T *
! ret_partial_any(int argcount UNUSED, type_T **argtypes UNUSED)
  {
!     return &t_partial_any;
  }
      static type_T *
  ret_channel(int argcount UNUSED, type_T **argtypes UNUSED)
***************
*** 558,564 ****
      {"foldtext",      0, 0, 0,          ret_string,   f_foldtext},
      {"foldtextresult",        1, 1, FEARG_1,    ret_string,   
f_foldtextresult},
      {"foreground",    0, 0, 0,          ret_void,     f_foreground},
!     {"funcref",               1, 3, FEARG_1,    ret_partial_void, f_funcref},
      {"function",      1, 3, FEARG_1,    ret_f_function, f_function},
      {"garbagecollect",        0, 1, 0,          ret_void,     
f_garbagecollect},
      {"get",           2, 3, FEARG_1,    ret_any,      f_get},
--- 564,570 ----
      {"foldtext",      0, 0, 0,          ret_string,   f_foldtext},
      {"foldtextresult",        1, 1, FEARG_1,    ret_string,   
f_foldtextresult},
      {"foreground",    0, 0, 0,          ret_void,     f_foreground},
!     {"funcref",               1, 3, FEARG_1,    ret_partial_any, f_funcref},
      {"function",      1, 3, FEARG_1,    ret_f_function, f_function},
      {"garbagecollect",        0, 1, 0,          ret_void,     
f_garbagecollect},
      {"get",           2, 3, FEARG_1,    ret_any,      f_get},
***************
*** 952,960 ****
      {"test_null_blob",        0, 0, 0,          ret_blob,     
f_test_null_blob},
      {"test_null_channel", 0, 0, 0,      ret_channel,  
JOB_FUNC(f_test_null_channel)},
      {"test_null_dict",        0, 0, 0,          ret_dict_any, 
f_test_null_dict},
      {"test_null_job", 0, 0, 0,          ret_job,      
JOB_FUNC(f_test_null_job)},
      {"test_null_list",        0, 0, 0,          ret_list_any, 
f_test_null_list},
!     {"test_null_partial", 0, 0, 0,      ret_partial_void, 
f_test_null_partial},
      {"test_null_string", 0, 0, 0,       ret_string,   f_test_null_string},
      {"test_option_not_set", 1, 1, FEARG_1,ret_void,    f_test_option_not_set},
      {"test_override", 2, 2, FEARG_2,    ret_void,     f_test_override},
--- 958,967 ----
      {"test_null_blob",        0, 0, 0,          ret_blob,     
f_test_null_blob},
      {"test_null_channel", 0, 0, 0,      ret_channel,  
JOB_FUNC(f_test_null_channel)},
      {"test_null_dict",        0, 0, 0,          ret_dict_any, 
f_test_null_dict},
+     {"test_null_function", 0, 0, 0,     ret_func_any, f_test_null_function},
      {"test_null_job", 0, 0, 0,          ret_job,      
JOB_FUNC(f_test_null_job)},
      {"test_null_list",        0, 0, 0,          ret_list_any, 
f_test_null_list},
!     {"test_null_partial", 0, 0, 0,      ret_partial_any, f_test_null_partial},
      {"test_null_string", 0, 0, 0,       ret_string,   f_test_null_string},
      {"test_option_not_set", 1, 1, FEARG_1,ret_void,    f_test_option_not_set},
      {"test_override", 2, 2, FEARG_2,    ret_void,     f_test_override},
*** ../vim-8.2.0492/runtime/doc/eval.txt        2020-04-01 19:22:06.522507242 
+0200
--- runtime/doc/eval.txt        2020-04-01 22:02:14.490227201 +0200
***************
*** 2859,2864 ****
--- 2861,2867 ----
  test_null_blob()              Blob    null value for testing
  test_null_channel()           Channel null value for testing
  test_null_dict()              Dict    null value for testing
+ test_null_function()          Funcref null value for testing
  test_null_job()                       Job     null value for testing
  test_null_list()              List    null value for testing
  test_null_partial()           Funcref null value for testing
*** ../vim-8.2.0492/runtime/doc/testing.txt     2020-02-22 19:07:24.397786814 
+0100
--- runtime/doc/testing.txt     2020-04-01 22:03:10.558016422 +0200
***************
*** 106,111 ****
--- 106,115 ----
                Return a |Dict| that is null. Only useful for testing.
  
  
+ test_null_function()                                  *test_null_function()*
+               Return a |FuncRef| that is null. Only useful for testing.
+ 
+ 
  test_null_job()                                               
*test_null_job()*
                Return a |Job| that is null. Only useful for testing.
                {only available when compiled with the +job feature}
*** ../vim-8.2.0492/src/testdir/test_vim9_script.vim    2020-04-01 
21:17:17.272409958 +0200
--- src/testdir/test_vim9_script.vim    2020-04-01 22:05:38.229461438 +0200
***************
*** 117,122 ****
--- 117,164 ----
    assert_equal('aregadd', @a)
    call CheckDefFailure(['@a += "more"'], 'E1013:')
    call CheckDefFailure(['@a += 123'], 'E1013:')
+ 
+   v:errmsg = 'none'
+   v:errmsg ..= 'again'
+   assert_equal('noneagain', v:errmsg)
+   call CheckDefFailure(['v:errmsg += "more"'], 'E1013:')
+   call CheckDefFailure(['v:errmsg += 123'], 'E1013:')
+ 
+   " Test default values.
+   let thebool: bool
+   assert_equal(v:false, thebool)
+ 
+   let thenumber: number
+   assert_equal(0, thenumber)
+ 
+   if has('float')
+     let thefloat: float
+     assert_equal(0.0, thefloat)
+   endif
+ 
+   let thestring: string
+   assert_equal('', thestring)
+ 
+   let theblob: blob
+   assert_equal(0z, theblob)
+ 
+   let thefunc: func
+   assert_equal(test_null_function(), thefunc)
+ 
+   let thepartial: partial
+   assert_equal(test_null_partial(), thepartial)
+ 
+   let thelist: list<any>
+   assert_equal([], thelist)
+ 
+   let thedict: dict<any>
+   assert_equal({}, thedict)
+ 
+   let thejob: job
+   assert_equal(test_null_job(), thejob)
+ 
+   let thechannel: channel
+   assert_equal(test_null_channel(), thechannel)
  enddef
  
  func Test_assignment_failure()
***************
*** 129,134 ****
--- 171,177 ----
  
    call CheckDefFailure(['let [a; b; c] = g:list'], 'E452:')
  
+   call CheckDefFailure(['let somevar'], "E1022:")
    call CheckDefFailure(['let &option'], 'E1052:')
    call CheckDefFailure(['&g:option = 5'], 'E113:')
  
*** ../vim-8.2.0492/src/version.c       2020-04-01 21:17:17.272409958 +0200
--- src/version.c       2020-04-01 22:05:57.541388868 +0200
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     493,
  /**/

-- 
An indication you must be a manager:
You can explain to somebody the difference between "re-engineering",
"down-sizing", "right-sizing", and "firing people's asses".

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202004012011.031KBVhY005557%40masaka.moolenaar.net.

Raspunde prin e-mail lui