aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-28 06:55:56 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-03-28 06:56:04 +0800
commitb20fc95c1a202332d2f41181cfa6089068a0d70d (patch)
treec8c6af89f68f81be488f8fe80e85006bec41330f
parentd01d4764804bd73ce213aab76a394c62c9f7d193 (diff)
downloadrneovim-b20fc95c1a202332d2f41181cfa6089068a0d70d.tar.gz
rneovim-b20fc95c1a202332d2f41181cfa6089068a0d70d.tar.bz2
rneovim-b20fc95c1a202332d2f41181cfa6089068a0d70d.zip
vim-patch:9.1.1245: need some more tests for curly braces evaluation
Problem: need some more tests for curly braces evaluation Solution: Add a test for the regression introduced by patch v9.1.1242 (Yegappan Lakshmanan) closes: vim/vim#16986 https://github.com/vim/vim/commit/d9b82cfe846e988772f2eec40643d7009d61ffdf Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
-rw-r--r--test/old/testdir/test_let.vim20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim
index 22a3a35f87..ec83de880c 100644
--- a/test/old/testdir/test_let.vim
+++ b/test/old/testdir/test_let.vim
@@ -93,6 +93,26 @@ func Test_let()
let [l[0], l[1]] = [10, 20]
call assert_equal([10, 20, 3], l)
+ " Test for using curly brace name in the LHS of an assignment
+ let listvar = [1, 2]
+ let s = 'listvar'
+ let {s} = [3, 4]
+ call assert_equal([3, 4], listvar)
+
+ " Test for using curly brace name as a list and as list index in the LHS of
+ " an assignment
+ let listvar = [1, 2]
+ let idx = 1
+ let s = 'listvar'
+ let {s}[0] = 10
+ let s = 'idx'
+ let listvar[{s}] = 20
+ call assert_equal([10, 20], listvar)
+ let s1 = 'listvar'
+ let s2 = 'idx'
+ let {s1}[{s2}] = 30
+ call assert_equal([10, 30], listvar)
+
" Test for errors in conditional expression
call assert_fails('let val = [] ? 1 : 2', 'E745:')
call assert_fails('let val = 1 ? 5+ : 6', 'E121:')