summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_vim9_expr.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-12 22:03:01 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-12 22:03:01 +0100
commit7f8a3b11bfc02f24dfd877d0a81392d679008180 (patch)
treebaefbbb6151f6cc271f3cc4dccd15f3409f35a17 /src/testdir/test_vim9_expr.vim
parent9f1983de4e8293bae32fdab72a459b1b64bf767f (diff)
patch 8.2.4946: Vim9: some code not covered by testsv8.2.4946
Problem: Vim9: some code not covered by tests. Solution: Add a few more test cases. Remove dead code.
Diffstat (limited to 'src/testdir/test_vim9_expr.vim')
-rw-r--r--src/testdir/test_vim9_expr.vim18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 9807b6c364..93c6bcd1ff 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2151,6 +2151,9 @@ def Test_expr8_string()
vv = $'other {val}'
assert_equal('other val', vv)
+ v9.CheckDefAndScriptFailure(['var x = $"foo'], 'E114:', 1)
+ v9.CheckDefAndScriptFailure(['var x = $"foo{xxx}"'], ['E1001: Variable not found: xxx', 'E121: Undefined variable: xxx'], 1)
+
var x = 'x'
var vl = 'foo xxx bar xxx baz'
->split($'x{x}x')
@@ -2818,6 +2821,7 @@ def Test_expr8_dict()
g:key = 'x'
v9.CheckDefExecAndScriptFailure(["var x = {[g:key]: 'text', [g:key]: 'text'}"], 'E721:', 1)
unlet g:key
+ v9.CheckDefExecAndScriptFailure(["var x = {[notexists]: 'text'}"], ['E1001:', 'E121: Undefined variable: notexists'], 1)
v9.CheckDefExecAndScriptFailure(["var x = g:anint.member"], ['E715:', 'E488:'], 1)
v9.CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1)
@@ -3370,6 +3374,9 @@ def Test_expr8_parens()
assert_equal('onetwo', s)
END
v9.CheckDefAndScriptSuccess(lines)
+
+ v9.CheckDefAndScriptFailure(['echo ('], ['E1097: Line incomplete', 'E15: Invalid expression: "("'])
+ v9.CheckDefAndScriptFailure(['echo (123]'], "E110: Missing ')'", 1)
enddef
def Test_expr8_negate_add()
@@ -3480,6 +3487,7 @@ def Test_expr8_call()
"var x = substitute ('x', 'x', 'x', 'x')"
], ['E1001:', 'E121:'], 1)
v9.CheckDefAndScriptFailure(["var Ref = function('len' [1, 2])"], ['E1123:', 'E116:'], 1)
+ v9.CheckDefAndScriptFailure(["echo match(['foo'] , 'foo')"], 'E1068:', 1)
enddef
def g:ExistingGlobal(): string
@@ -4000,6 +4008,16 @@ def Test_expr8_blob_subscript()
v9.CheckDefAndScriptSuccess(lines)
enddef
+def Test_expr8_funcref_subscript()
+ var lines =<< trim END
+ var l = function('len')("abc")
+ assert_equal(3, l)
+ END
+ v9.CheckDefAndScriptSuccess(lines)
+
+ v9.CheckDefAndScriptFailure(["var l = function('len')(xxx)"], ['E1001: Variable not found: xxx', 'E121: Undefined variable: xxx'], 1)
+enddef
+
def Test_expr8_subscript_linebreak()
var lines =<< trim END
var range = range(