Patch 8.2.0288
Problem: Vim9: some float and blob operators not tested.
Solution: Add float and blob tests. Fix addition.
Files: src/testdir/test_vim9_expr.vim, src/vim9compile.c
*** ../vim-8.2.0287/src/testdir/test_vim9_expr.vim 2020-02-19
20:23:07.948950048 +0100
--- src/testdir/test_vim9_expr.vim 2020-02-20 22:11:38.985865603 +0100
***************
*** 286,317 ****
" test > comperator
def Test_expr4_greater()
! assert_equal(true, 2 > 0)
! assert_equal(true, 2 > 1)
! assert_equal(false, 2 > 2)
! assert_equal(false, 2 > 3)
enddef
" test >= comperator
def Test_expr4_greaterequal()
! assert_equal(true, 2 >= 0)
! assert_equal(true, 2 >= 2)
! assert_equal(false, 2 >= 3)
enddef
" test < comperator
def Test_expr4_smaller()
! assert_equal(false, 2 < 0)
! assert_equal(false, 2 < 2)
! assert_equal(true, 2 < 3)
enddef
" test <= comperator
def Test_expr4_smallerequal()
! assert_equal(false, 2 <= 0)
! assert_equal(false, 2 <= 1)
! assert_equal(true, 2 <= 2)
! assert_equal(true, 2 <= 3)
enddef
" test =~ comperator
--- 286,339 ----
" test > comperator
def Test_expr4_greater()
! assert_true(2 > 0)
! assert_true(2 > 1)
! assert_false(2 > 2)
! assert_false(2 > 3)
! if has('float')
! assert_true(2.0 > 0.0)
! assert_true(2.0 > 1.0)
! assert_false(2.0 > 2.0)
! assert_false(2.0 > 3.0)
! endif
enddef
" test >= comperator
def Test_expr4_greaterequal()
! assert_true(2 >= 0)
! assert_true(2 >= 2)
! assert_false(2 >= 3)
! if has('float')
! assert_true(2.0 >= 0.0)
! assert_true(2.0 >= 2.0)
! assert_false(2.0 >= 3.0)
! endif
enddef
" test < comperator
def Test_expr4_smaller()
! assert_false(2 < 0)
! assert_false(2 < 2)
! assert_true(2 < 3)
! if has('float')
! assert_false(2.0 < 0.0)
! assert_false(2.0 < 2.0)
! assert_true(2.0 < 3.0)
! endif
enddef
" test <= comperator
def Test_expr4_smallerequal()
! assert_false(2 <= 0)
! assert_false(2 <= 1)
! assert_true(2 <= 2)
! assert_true(2 <= 3)
! if has('float')
! assert_false(2.0 <= 0.0)
! assert_false(2.0 <= 1.0)
! assert_true(2.0 <= 2.0)
! assert_true(2.0 <= 3.0)
! endif
enddef
" test =~ comperator
***************
*** 329,346 ****
" test is comperator
def Test_expr4_is()
let mylist = [2]
! assert_equal(false, mylist is [2])
let other = mylist
! assert_equal(true, mylist is other)
enddef
" test isnot comperator
def Test_expr4_isnot()
let mylist = [2]
! assert_equal(true, '2' isnot '0')
! assert_equal(true, mylist isnot [2])
let other = mylist
! assert_equal(false, mylist isnot other)
enddef
def RetVoid()
--- 351,378 ----
" test is comperator
def Test_expr4_is()
let mylist = [2]
! assert_false(mylist is [2])
let other = mylist
! assert_true(mylist is other)
!
! let myblob = 0z1234
! assert_false(myblob is 0z1234)
! let otherblob = myblob
! assert_true(myblob is otherblob)
enddef
" test isnot comperator
def Test_expr4_isnot()
let mylist = [2]
! assert_true('2' isnot '0')
! assert_true(mylist isnot [2])
let other = mylist
! assert_false(mylist isnot other)
!
! let myblob = 0z1234
! assert_true(myblob isnot 0z1234)
! let otherblob = myblob
! assert_false(myblob isnot otherblob)
enddef
def RetVoid()
***************
*** 427,432 ****
--- 459,470 ----
assert_equal('hello 123', 'hello ' .. 123)
assert_equal('123 hello', 123 .. ' hello')
assert_equal('123456', 123 .. 456)
+
+ assert_equal([1, 2, 3, 4], [1, 2] + [3, 4])
+ assert_equal(0z11223344, 0z1122 + 0z3344)
+ assert_equal(0z112201ab, 0z1122 + g:ablob)
+ assert_equal(0z01ab3344, g:ablob + 0z3344)
+ assert_equal(0z01ab01ab, g:ablob + g:ablob)
enddef
def Test_expr5_float()
***************
*** 466,471 ****
--- 504,516 ----
call CheckDefFailure("let x = '1'..'2'", msg)
call CheckDefFailure("let x = '1' ..'2'", msg)
call CheckDefFailure("let x = '1'.. '2'", msg)
+
+ call CheckDefFailure("let x = 0z1122 + 33", 'E1035')
+ call CheckDefFailure("let x = 0z1122 + [3]", 'E1035')
+ call CheckDefFailure("let x = 0z1122 + 'asd'", 'E1035')
+ call CheckDefFailure("let x = 33 + 0z1122", 'E1035')
+ call CheckDefFailure("let x = [3] + 0z1122", 'E1035')
+ call CheckDefFailure("let x = 'asdf' + 0z1122", 'E1035')
endfunc
" test multiply, divide, modulo
***************
*** 650,655 ****
--- 695,704 ----
assert_equal(g:list_empty, [])
assert_equal(g:list_empty, [ ])
assert_equal(g:list_mixed, [1, 'b', false])
+
+ call CheckDefExecFailure("let x = g:anint[3]", 'E714:')
+ call CheckDefExecFailure("let x = g:list_mixed['xx']", 'E39:')
+ call CheckDefExecFailure("let x = g:list_empty[3]", 'E684:')
enddef
def Test_expr7_lambda()
***************
*** 667,672 ****
--- 716,724 ----
let key = 'one'
let val = 1
assert_equal(g:dict_one, {key: val})
+
+ call CheckDefExecFailure("let x = g:anint.member", 'E715:')
+ call CheckDefExecFailure("let x = g:dict_empty.member", 'E716:')
enddef
def Test_expr7_option()
*** ../vim-8.2.0287/src/vim9compile.c 2020-02-19 22:31:44.886288858 +0100
--- src/vim9compile.c 2020-02-20 22:09:35.194385883 +0100
***************
*** 374,379 ****
--- 374,381 ----
switch (*op)
{
case '+': if (vartype != VAR_LIST && vartype != VAR_BLOB
+ && type1->tt_type != VAR_UNKNOWN
+ && type2->tt_type != VAR_UNKNOWN
&& check_number_or_float(
type1->tt_type, type2->tt_type, op) == FAIL)
return FAIL;
***************
*** 1074,1082 ****
return FAIL;
isn->isn_arg.string = vim_strnsave(name, (int)len);
! // change dict type to dict member type
type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
! ((type_T **)stack->ga_data)[stack->ga_len - 1] = type->tt_member;
return OK;
}
--- 1076,1091 ----
return FAIL;
isn->isn_arg.string = vim_strnsave(name, (int)len);
! // check for dict type
type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
! if (type->tt_type != VAR_DICT && type != &t_any)
! {
! emsg(_(e_dictreq));
! return FAIL;
! }
! // change dict type to dict member type
! if (type->tt_type == VAR_DICT)
! ((type_T **)stack->ga_data)[stack->ga_len - 1] = type->tt_member;
return OK;
}
***************
*** 2370,2376 ****
emsg(_(e_listreq));
return FAIL;
}
! *typep = (*typep)->tt_member;
}
else if (**arg == '.' && (*arg)[1] != '.')
{
--- 2379,2386 ----
emsg(_(e_listreq));
return FAIL;
}
! if ((*typep)->tt_type == VAR_LIST)
! *typep = (*typep)->tt_member;
}
else if (**arg == '.' && (*arg)[1] != '.')
{
***************
*** 2387,2393 ****
semsg(_(e_syntax_at), *arg);
return FAIL;
}
- // TODO: check type is dict
if (generate_MEMBER(cctx, *arg, p - *arg) == FAIL)
return FAIL;
*arg = p;
--- 2397,2402 ----
***************
*** 4964,4969 ****
--- 4973,4982 ----
default:
// Not recognized, execute with do_cmdline_cmd().
+ // TODO:
+ // CMD_echomsg
+ // CMD_execute
+ // etc.
generate_EXEC(&cctx, line);
line = (char_u *)"";
break;
*** ../vim-8.2.0287/src/version.c 2020-02-20 20:41:02.987044162 +0100
--- src/version.c 2020-02-20 21:25:11.159028083 +0100
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 288,
/**/
--
I AM THANKFUL...
...for the mess to clean after a party because it means I have
been surrounded by friends.
/// 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/202002202115.01KLF0T2029720%40masaka.moolenaar.net.