mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
patch 8.2.3202: Vim9: tests are only executed for legacy script
Problem: Vim9: tests are only executed for legacy script. Solution: Run more tests also for Vim9 script. Fix uncovered problems.
This commit is contained in:
@@ -3451,7 +3451,8 @@ find_ex_command(
|
|||||||
// "varname[]" is an expression.
|
// "varname[]" is an expression.
|
||||||
*p == '['
|
*p == '['
|
||||||
// "varname.key" is an expression.
|
// "varname.key" is an expression.
|
||||||
|| (*p == '.' && ASCII_ISALPHA(p[1]))))
|
|| (*p == '.' && (ASCII_ISALPHA(p[1])
|
||||||
|
|| p[1] == '_'))))
|
||||||
{
|
{
|
||||||
char_u *after = eap->cmd;
|
char_u *after = eap->cmd;
|
||||||
|
|
||||||
|
@@ -109,10 +109,17 @@ func Test_list_unlet()
|
|||||||
unlet l[2:3]
|
unlet l[2:3]
|
||||||
call assert_equal([0, 1], l)
|
call assert_equal([0, 1], l)
|
||||||
|
|
||||||
let l = [0, 1, 2, 3]
|
let lines =<< trim END
|
||||||
call assert_fails('unlet l[2:1]', 'E684:')
|
VAR l = [0, 1, 2, 3]
|
||||||
let l = [0, 1, 2, 3]
|
unlet l[2 : 1]
|
||||||
call assert_fails('unlet l[-1:2]', 'E684:')
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, 'E684:')
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
VAR l = [0, 1, 2, 3]
|
||||||
|
unlet l[-1 : 2]
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, 'E684:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" assignment to a list
|
" assignment to a list
|
||||||
@@ -126,9 +133,33 @@ func Test_list_assign()
|
|||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
let l = [0, 1, 2, 3]
|
let l = [0, 1, 2, 3]
|
||||||
call assert_fails('let [va, vb] = l', 'E687:')
|
let [va, vb] = l
|
||||||
call assert_fails('let [va, vb] = l[1:1]', 'E688:')
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E687:')
|
||||||
|
let lines =<< trim END
|
||||||
|
var l = [0, 1, 2, 3]
|
||||||
|
var va = 0
|
||||||
|
var vb = 0
|
||||||
|
[va, vb] = l
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(['vim9script'] + lines, 'E687:')
|
||||||
|
call CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 4')
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
let l = [0, 1, 2, 3]
|
||||||
|
let [va, vb] = l[1:1]
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E688:')
|
||||||
|
let lines =<< trim END
|
||||||
|
var l = [0, 1, 2, 3]
|
||||||
|
var va = 0
|
||||||
|
var vb = 0
|
||||||
|
[va, vb] = l[1 : 1]
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(['vim9script'] + lines, 'E688:')
|
||||||
|
call CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 1')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" test for range assign
|
" test for range assign
|
||||||
@@ -248,23 +279,29 @@ let s:dict_with_spaces_lit = #{one : 1 , two : 2 , three : 3}
|
|||||||
|
|
||||||
" Dictionary identity
|
" Dictionary identity
|
||||||
func Test_dict_identity()
|
func Test_dict_identity()
|
||||||
let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},}
|
let lines =<< trim END
|
||||||
let dd = d
|
VAR d = {'1': 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1}, }
|
||||||
let dx = copy(d)
|
VAR dd = d
|
||||||
|
VAR dx = copy(d)
|
||||||
call assert_true(d == dd)
|
call assert_true(d == dd)
|
||||||
call assert_false(d isnot dd)
|
call assert_false(d isnot dd)
|
||||||
call assert_true(d is dd)
|
call assert_true(d is dd)
|
||||||
call assert_true(d == dx)
|
call assert_true(d == dx)
|
||||||
call assert_false(d is dx)
|
call assert_false(d is dx)
|
||||||
call assert_true(d isnot dx)
|
call assert_true(d isnot dx)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" removing items with :unlet
|
" removing items with :unlet
|
||||||
func Test_dict_unlet()
|
func Test_dict_unlet()
|
||||||
let d = {'b':'bbb', '1': 99, '3': 33, '-1': {'a': 1}}
|
let lines =<< trim END
|
||||||
|
VAR d = {'b': 'bbb', '1': 99, '3': 33, '-1': {'a': 1}}
|
||||||
unlet d.b
|
unlet d.b
|
||||||
unlet d[-1]
|
unlet d[-1]
|
||||||
call assert_equal({'1': 99, '3': 33}, d)
|
call assert_equal({'1': 99, '3': 33}, d)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" manipulating a big Dictionary (hashtable.c has a border of 1000 entries)
|
" manipulating a big Dictionary (hashtable.c has a border of 1000 entries)
|
||||||
@@ -332,8 +369,30 @@ func Test_dict_assign()
|
|||||||
let d._ = 2
|
let d._ = 2
|
||||||
call assert_equal({'1': 1, '_': 2}, d)
|
call assert_equal({'1': 1, '_': 2}, d)
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
VAR d = {}
|
||||||
|
LET d.a = 1
|
||||||
|
LET d._ = 2
|
||||||
|
call assert_equal({'a': 1, '_': 2}, d)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
let n = 0
|
let n = 0
|
||||||
call assert_fails('let n.key = 3', 'E1203: Dot can only be used on a dictionary: n.key = 3')
|
let n.key = 3
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3')
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var n = 0
|
||||||
|
n.key = 3
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3')
|
||||||
|
let lines =<< trim END
|
||||||
|
var n = 0
|
||||||
|
n.key = 3
|
||||||
|
END
|
||||||
|
call CheckDefFailure(lines, 'E1141:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Function in script-local List or Dict
|
" Function in script-local List or Dict
|
||||||
@@ -350,13 +409,41 @@ endfunc
|
|||||||
|
|
||||||
" Test removing items in a dictionary
|
" Test removing items in a dictionary
|
||||||
func Test_dict_func_remove()
|
func Test_dict_func_remove()
|
||||||
let d = {1:'a', 2:'b', 3:'c'}
|
let lines =<< trim END
|
||||||
|
VAR d = {1: 'a', 2: 'b', 3: 'c'}
|
||||||
call assert_equal('b', remove(d, 2))
|
call assert_equal('b', remove(d, 2))
|
||||||
call assert_equal({1: 'a', 3: 'c'}, d)
|
call assert_equal({1: 'a', 3: 'c'}, d)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call assert_fails("call remove(d, 1, 2)", 'E118:')
|
let lines =<< trim END
|
||||||
call assert_fails("call remove(d, 'a')", 'E716:')
|
VAR d = {1: 'a', 3: 'c'}
|
||||||
call assert_fails("call remove(d, [])", 'E730:')
|
call remove(d, 1, 2)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, 'E118:')
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
VAR d = {1: 'a', 3: 'c'}
|
||||||
|
call remove(d, 'a')
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, 'E716:')
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
let d = {1: 'a', 3: 'c'}
|
||||||
|
call remove(d, [])
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E730:')
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var d = {1: 'a', 3: 'c'}
|
||||||
|
call remove(d, [])
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E1174: String required for argument 2')
|
||||||
|
let lines =<< trim END
|
||||||
|
var d = {1: 'a', 3: 'c'}
|
||||||
|
call remove(d, [])
|
||||||
|
END
|
||||||
|
call CheckDefExecFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got list<unknown>')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Nasty: remove func from Dict that's being called (works)
|
" Nasty: remove func from Dict that's being called (works)
|
||||||
@@ -372,7 +459,7 @@ endfunc
|
|||||||
func Test_dict_literal_keys()
|
func Test_dict_literal_keys()
|
||||||
call assert_equal({'one': 1, 'two2': 2, '3three': 3, '44': 4}, #{one: 1, two2: 2, 3three: 3, 44: 4},)
|
call assert_equal({'one': 1, 'two2': 2, '3three': 3, '44': 4}, #{one: 1, two2: 2, 3three: 3, 44: 4},)
|
||||||
|
|
||||||
" why *{} cannot be used
|
" why *{} cannot be used for a literal dictionary
|
||||||
let blue = 'blue'
|
let blue = 'blue'
|
||||||
call assert_equal('6', trim(execute('echo 2 *{blue: 3}.blue')))
|
call assert_equal('6', trim(execute('echo 2 *{blue: 3}.blue')))
|
||||||
endfunc
|
endfunc
|
||||||
@@ -564,7 +651,6 @@ endfunc
|
|||||||
|
|
||||||
" No :unlet after lock on dict:
|
" No :unlet after lock on dict:
|
||||||
func Test_dict_lock_unlet()
|
func Test_dict_lock_unlet()
|
||||||
unlet! d
|
|
||||||
let d = {'a': 99, 'b': 100}
|
let d = {'a': 99, 'b': 100}
|
||||||
lockvar 1 d
|
lockvar 1 d
|
||||||
call assert_fails('unlet d.a', 'E741:')
|
call assert_fails('unlet d.a', 'E741:')
|
||||||
@@ -572,7 +658,6 @@ endfunc
|
|||||||
|
|
||||||
" unlet after lock on dict item
|
" unlet after lock on dict item
|
||||||
func Test_dict_item_lock_unlet()
|
func Test_dict_item_lock_unlet()
|
||||||
unlet! d
|
|
||||||
let d = {'a': 99, 'b': 100}
|
let d = {'a': 99, 'b': 100}
|
||||||
lockvar d.a
|
lockvar d.a
|
||||||
unlet d.a
|
unlet d.a
|
||||||
@@ -581,7 +666,6 @@ endfunc
|
|||||||
|
|
||||||
" filter() after lock on dict item
|
" filter() after lock on dict item
|
||||||
func Test_dict_lock_filter()
|
func Test_dict_lock_filter()
|
||||||
unlet! d
|
|
||||||
let d = {'a': 99, 'b': 100}
|
let d = {'a': 99, 'b': 100}
|
||||||
lockvar d.a
|
lockvar d.a
|
||||||
call filter(d, 'v:key != "a"')
|
call filter(d, 'v:key != "a"')
|
||||||
@@ -590,7 +674,6 @@ endfunc
|
|||||||
|
|
||||||
" map() after lock on dict
|
" map() after lock on dict
|
||||||
func Test_dict_lock_map()
|
func Test_dict_lock_map()
|
||||||
unlet! d
|
|
||||||
let d = {'a': 99, 'b': 100}
|
let d = {'a': 99, 'b': 100}
|
||||||
lockvar 1 d
|
lockvar 1 d
|
||||||
call map(d, 'v:val + 200')
|
call map(d, 'v:val + 200')
|
||||||
@@ -599,7 +682,6 @@ endfunc
|
|||||||
|
|
||||||
" No extend() after lock on dict item
|
" No extend() after lock on dict item
|
||||||
func Test_dict_lock_extend()
|
func Test_dict_lock_extend()
|
||||||
unlet! d
|
|
||||||
let d = {'a': 99, 'b': 100}
|
let d = {'a': 99, 'b': 100}
|
||||||
lockvar d.a
|
lockvar d.a
|
||||||
call assert_fails("call extend(d, {'a' : 123})", 'E741:')
|
call assert_fails("call extend(d, {'a' : 123})", 'E741:')
|
||||||
@@ -608,7 +690,6 @@ endfunc
|
|||||||
|
|
||||||
" Cannot use += with a locked dict
|
" Cannot use += with a locked dict
|
||||||
func Test_dict_lock_operator()
|
func Test_dict_lock_operator()
|
||||||
unlet! d
|
|
||||||
let d = {}
|
let d = {}
|
||||||
lockvar d
|
lockvar d
|
||||||
call assert_fails("let d += {'k' : 10}", 'E741:')
|
call assert_fails("let d += {'k' : 10}", 'E741:')
|
||||||
@@ -711,9 +792,6 @@ func Test_func_arg_list()
|
|||||||
call s:arg_list_test(1, 2, [3, 4], {5: 6})
|
call s:arg_list_test(1, 2, [3, 4], {5: 6})
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_dict_item_locked()
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
" Tests for reverse(), sort(), uniq()
|
" Tests for reverse(), sort(), uniq()
|
||||||
func Test_reverse_sort_uniq()
|
func Test_reverse_sort_uniq()
|
||||||
let l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
|
let l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
|
||||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3202,
|
||||||
/**/
|
/**/
|
||||||
3201,
|
3201,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2711,6 +2711,13 @@ exec_instructions(ectx_T *ectx)
|
|||||||
else
|
else
|
||||||
n2 = list_idx_of_item(l, li2);
|
n2 = list_idx_of_item(l, li2);
|
||||||
}
|
}
|
||||||
|
if (status != FAIL
|
||||||
|
&& tv_idx2->v_type != VAR_SPECIAL
|
||||||
|
&& n2 < n1)
|
||||||
|
{
|
||||||
|
semsg(_(e_listidx), n2);
|
||||||
|
status = FAIL;
|
||||||
|
}
|
||||||
if (status != FAIL
|
if (status != FAIL
|
||||||
&& list_unlet_range(l, li, NULL, n1,
|
&& list_unlet_range(l, li, NULL, n1,
|
||||||
tv_idx2->v_type != VAR_SPECIAL, n2)
|
tv_idx2->v_type != VAR_SPECIAL, n2)
|
||||||
|
Reference in New Issue
Block a user