File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9910,10 +9910,14 @@ assert_fails(typval_T *argvars)
99109910 char_u * cmd = tv_get_string_chk (& argvars [0 ]);
99119911 garray_T ga ;
99129912 int ret = 0 ;
9913+ int save_trylevel = trylevel ;
99139914
9915+ // trylevel must be zero for a ":throw" command to be considered failed
9916+ trylevel = 0 ;
99149917 called_emsg = FALSE;
99159918 suppress_errthrow = TRUE;
99169919 emsg_silent = TRUE;
9920+
99179921 do_cmdline_cmd (cmd );
99189922 if (!called_emsg )
99199923 {
@@ -9939,10 +9943,11 @@ assert_fails(typval_T *argvars)
99399943 assert_append_cmd_or_arg (& ga , argvars , cmd );
99409944 assert_error (& ga );
99419945 ga_clear (& ga );
9942- ret = 1 ;
9946+ ret = 1 ;
99439947 }
99449948 }
99459949
9950+ trylevel = save_trylevel ;
99469951 called_emsg = FALSE;
99479952 suppress_errthrow = FALSE;
99489953 emsg_silent = FALSE;
Original file line number Diff line number Diff line change @@ -166,6 +166,12 @@ func Test_assert_fail_fails()
166166 call remove (v: errors , 0 )
167167endfunc
168168
169+ func Test_assert_fails_in_try_block ()
170+ try
171+ call assert_equal (0 , assert_fails (' throw "error"' ))
172+ endtry
173+ endfunc
174+
169175func Test_assert_beeps ()
170176 new
171177 call assert_equal (0 , assert_beeps (' normal h' ))
Original file line number Diff line number Diff line change @@ -777,6 +777,8 @@ static char *(features[]) =
777777
778778static int included_patches [] =
779779{ /* Add new patch number below this line */
780+ /**/
781+ 1660 ,
780782/**/
781783 1659 ,
782784/**/
You can’t perform that action at this time.
0 commit comments