0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.4484: Vim9: some error messages are not tested

Problem:    Vim9: some error messages are not tested.
Solution:   Add a few more test cases.  Delete dead code.
This commit is contained in:
Bram Moolenaar
2022-02-28 20:55:02 +00:00
parent 5de4c4372d
commit 1983f1aa31
5 changed files with 97 additions and 5 deletions

View File

@@ -550,6 +550,13 @@ def Test_assign_index()
bl[-2] = 0x66
assert_equal(0z77226644, bl)
lines =<< trim END
g:val = '22'
var bl = 0z11
bl[1] = g:val
END
v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: "22"')
# should not read the next line when generating "a.b"
var a = {}
a.b = {}
@@ -1233,12 +1240,18 @@ def Test_script_var_default()
var lines =<< trim END
vim9script
var l: list<number>
var li = [1, 2]
var bl: blob
var bli = 0z12
var d: dict<number>
var di = {'a': 1, 'b': 2}
def Echo()
assert_equal([], l)
assert_equal([1, 2], li)
assert_equal(0z, bl)
assert_equal(0z12, bli)
assert_equal({}, d)
assert_equal({'a': 1, 'b': 2}, di)
enddef
Echo()
END
@@ -1502,6 +1515,30 @@ def Test_assign_list()
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var l = [1, 2]
g:idx = 'x'
l[g:idx : 1] = [0]
echo l
END
v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: "x"')
lines =<< trim END
var l = [1, 2]
g:idx = 3
l[g:idx : 1] = [0]
echo l
END
v9.CheckDefExecAndScriptFailure(lines, 'E684: list index out of range: 3')
lines =<< trim END
var l = [1, 2]
g:idx = 'y'
l[1 : g:idx] = [0]
echo l
END
v9.CheckDefExecAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "y"'])
v9.CheckDefFailure(["var l: list<number> = ['', true]"], 'E1012: Type mismatch; expected list<number> but got list<any>', 1)
v9.CheckDefFailure(["var l: list<list<number>> = [['', true]]"], 'E1012: Type mismatch; expected list<list<number>> but got list<list<any>>', 1)
enddef