summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-29 21:38:15 +0200
committerBram Moolenaar <Bram@vim.org>2020-03-29 21:38:15 +0200
commit0b37a2f379f36d097e7fa90a3e86da6a29ed2aaa (patch)
treeaa08a41d322d8f44d39794bf5200a3d5b4fb90be /src
parent2027973b5be693577bea0731b50ea4904d19ea8b (diff)
patch 8.2.0480: Vim9: some code is not testedv8.2.0480
Problem: Vim9: some code is not tested. Solution: Add more tests.
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_vim9_expr.vim33
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c7
3 files changed, 40 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 6a03027d05..f61ff536ad 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -706,9 +706,12 @@ def Test_expr7_list()
assert_equal(g:list_empty, [])
assert_equal(g:list_empty, [ ])
assert_equal(g:list_mixed, [1, 'b', false])
+ assert_equal('b', g:list_mixed[1])
call CheckDefExecFailure("let x = g:anint[3]", 'E714:')
+ call CheckDefFailure("let x = g:list_mixed[xxx]", 'E1001:')
call CheckDefExecFailure("let x = g:list_mixed['xx']", 'E39:')
+ call CheckDefFailure("let x = g:list_mixed[0", 'E111:')
call CheckDefExecFailure("let x = g:list_empty[3]", 'E684:')
enddef
@@ -739,6 +742,12 @@ def Test_expr7_dict()
call CheckDefExecFailure("let x = g:dict_empty.member", 'E716:')
enddef
+def Test_expr_member()
+ assert_equal(1, g:dict_one.one)
+
+ call CheckDefFailure("let x = g:dict_one.#$!", 'E1002:')
+enddef
+
def Test_expr7_option()
" option
set ts=11
@@ -778,6 +787,30 @@ def Test_expr7_parens()
assert_equal(-6, ---6)
enddef
+def Test_expr7_negate()
+ assert_equal(-99, -99)
+ assert_equal(99, --99)
+ let nr = 88
+ assert_equal(-88, -nr)
+ assert_equal(88, --nr)
+enddef
+
+def Echo(arg): string
+ return arg
+enddef
+
+def s:EchoArg(arg): string
+ return arg
+enddef
+
+def Test_expr7_call()
+ assert_equal('yes', 'yes'->Echo())
+ assert_equal('yes', 'yes'->s:EchoArg())
+
+ call CheckDefFailure("let x = 'yes'->Echo", 'E107:')
+enddef
+
+
def Test_expr7_not()
assert_equal(true, !'')
assert_equal(true, ![])
diff --git a/src/version.c b/src/version.c
index f1d74d87fb..e09cf4f707 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 480,
+/**/
479,
/**/
478,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 584618c0e1..9d66e5ed15 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2622,11 +2622,14 @@ compile_subscript(
else
{
// method call: list->method()
- for (p = *arg; eval_isnamec1(*p); ++p)
+ p = *arg;
+ if (ASCII_ISALPHA(*p) && p[1] == ':')
+ p += 2;
+ for ( ; eval_isnamec1(*p); ++p)
;
if (*p != '(')
{
- semsg(_(e_missing_paren), arg);
+ semsg(_(e_missing_paren), *arg);
return FAIL;
}
// TODO: base value may not be the first argument