]> granicus.if.org Git - vim/commitdiff
patch 8.2.0700: Vim9: converting error message to exception not tested v8.2.0700
authorBram Moolenaar <Bram@vim.org>
Tue, 5 May 2020 20:08:26 +0000 (22:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 May 2020 20:08:26 +0000 (22:08 +0200)
Problem:    Vim9: converting error message to exception not tested.
Solution:   Test exception from error.  Do not continue after :echoerr.

src/testdir/test_vim9_script.vim
src/version.c
src/vim9execute.c

index bc1f87377f1362d17ffd143ef1cd4758dcedeea7..76ce2e5498816a3b2132db46bb56a699e28a1459 100644 (file)
@@ -466,6 +466,20 @@ def Test_try_catch_fails()
   call CheckDefFailure(['throw xxx'], 'E1001:')
 enddef
 
+let someJob = test_null_job()
+
+def FuncWithError()
+  echomsg g:someJob
+enddef
+
+func Test_convert_emsg_to_exception()
+  try
+    call FuncWithError()
+  catch
+    call assert_match('Vim:E908:', v:exception)
+  endtry
+endfunc
+
 let s:export_script_lines =<< trim END
   vim9script
   let name: string = 'bob'
@@ -1058,7 +1072,11 @@ def Test_echomsg_cmd()
 enddef
 
 def Test_echoerr_cmd()
-  # TODO: write this test
+  try
+    echoerr 'something' 'wrong' # comment
+  catch
+    assert_match('something wrong', v:exception)
+  endtry
 enddef
 
 def Test_for_outside_of_function()
index 61681882bd2567c6098b1b324b826c7ff00d0c8b..4c743cbfa18678e149fff90b24a3aeb58d81dfef 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    700,
 /**/
     699,
 /**/
index 27ad04b446a2ad2f85e9025a7bb0b31e454da766..5915ea1dceaeaca94ac7a5ddcecc29bc8c696d4b 100644 (file)
@@ -898,14 +898,8 @@ call_def_function(
                            }
                            else
                            {
-                               int             save_did_emsg = did_emsg;
-
                                SOURCING_LNUM = iptr->isn_lnum;
                                emsg(ga.ga_data);
-                               if (!force_abort)
-                                   // We don't want to abort following
-                                   // commands, restore did_emsg.
-                                   did_emsg = save_did_emsg;
                            }
                        }
                    }