Patch 8.2.0495

9 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 1, 2020, 5:05:53 PM4/1/20
to vim...@googlegroups.com

Patch 8.2.0495
Problem: Vim9: some code not tested.
Solution: Add more tests. Support more const expressions.
Files: src/vim9compile.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.0494/src/vim9compile.c 2020-04-01 22:36:46.214119142 +0200
--- src/vim9compile.c 2020-04-01 23:00:51.668600471 +0200
***************
*** 4043,4048 ****
--- 4043,4049 ----
{
typval_T argvars[2];
char_u *start_leader, *end_leader;
+ int has_call = FALSE;

/*
* Skip '!' characters. They are handled later.
***************
*** 4070,4078 ****
return OK;
}

! if (STRNCMP("has(", *arg, 4) != 0)
! return FAIL;
! *arg = skipwhite(*arg + 4);

if (**arg == '"')
{
--- 4071,4081 ----
return OK;
}

! if (STRNCMP("has(", *arg, 4) == 0)
! {
! has_call = TRUE;
! *arg = skipwhite(*arg + 4);
! }

if (**arg == '"')
{
***************
*** 4087,4109 ****
else
return FAIL;

! *arg = skipwhite(*arg);
! if (**arg != ')')
! return FAIL;
! *arg = skipwhite(*arg + 1);

! argvars[0] = *tv;
! argvars[1].v_type = VAR_UNKNOWN;
! tv->v_type = VAR_NUMBER;
! tv->vval.v_number = 0;
! f_has(argvars, tv);
! clear_tv(&argvars[0]);
!
! while (start_leader < end_leader)
! {
! if (*start_leader == '!')
! tv->vval.v_number = !tv->vval.v_number;
! ++start_leader;
}

return OK;
--- 4090,4115 ----
else
return FAIL;

! if (has_call)
! {
! *arg = skipwhite(*arg);
! if (**arg != ')')
! return FAIL;
! *arg = skipwhite(*arg + 1);

! argvars[0] = *tv;
! argvars[1].v_type = VAR_UNKNOWN;
! tv->v_type = VAR_NUMBER;
! tv->vval.v_number = 0;
! f_has(argvars, tv);
! clear_tv(&argvars[0]);
!
! while (start_leader < end_leader)
! {
! if (*start_leader == '!')
! tv->vval.v_number = !tv->vval.v_number;
! ++start_leader;
! }
}

return OK;
***************
*** 4129,4136 ****
*/
if (type != EXPR_UNKNOWN)
{
! // TODO
! return FAIL;
}

return OK;
--- 4135,4167 ----
*/
if (type != EXPR_UNKNOWN)
{
! typval_T tv2;
! char_u *s1, *s2;
! char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
! int n;
!
! // TODO: Only string == string is supported now
! if (tv->v_type != VAR_STRING)
! return FAIL;
! if (type != EXPR_EQUAL)
! return FAIL;
!
! // get the second variable
! tv2.v_type = VAR_UNKNOWN;
! *arg = skipwhite(p + len);
! if (evaluate_const_expr7(arg, cctx, &tv2) == FAIL
! || tv2.v_type != VAR_STRING)
! {
! clear_tv(&tv2);
! return FAIL;
! }
! s1 = tv_get_string_buf(tv, buf1);
! s2 = tv_get_string_buf(&tv2, buf2);
! n = STRCMP(s1, s2);
! clear_tv(tv);
! clear_tv(&tv2);
! tv->v_type = VAR_BOOL;
! tv->vval.v_number = n == 0 ? VVAL_TRUE : VVAL_FALSE;
}

return OK;
*** ../vim-8.2.0494/src/testdir/test_vim9_script.vim 2020-04-01 22:10:56.436201223 +0200
--- src/testdir/test_vim9_script.vim 2020-04-01 23:04:03.523868957 +0200
***************
*** 100,108 ****
--- 100,118 ----
set ts=7
&ts += 1
assert_equal(8, &ts)
+ &ts -= 3
+ assert_equal(5, &ts)
+ &ts *= 2
+ assert_equal(10, &ts)
+ &ts /= 3
+ assert_equal(3, &ts)
+ set ts=10
+ &ts %= 4
+ assert_equal(2, &ts)
call CheckDefFailure(['&notex += 3'], 'E113:')
call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
call CheckDefFailure(['&path += 3'], 'E1013:')
+ &ts = 8

g:inc_counter += 1
assert_equal(2, g:inc_counter)
***************
*** 1013,1019 ****
--- 1023,1033 ----
res = true
endif
assert_equal(false, res)
+ enddef

+ def Test_if_const_expr_fails()
+ call CheckDefFailure(['if "aaa" == "bbb'], 'E114:')
+ call CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:')
enddef

def Test_delfunc()
*** ../vim-8.2.0494/src/version.c 2020-04-01 22:36:46.214119142 +0200
--- src/version.c 2020-04-01 23:04:38.131737041 +0200
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 495,
/**/

--
An indication you must be a manager:
You believe you never have any problems in your life, just
"issues" and "improvement opportunities".

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages