summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-18 14:20:36 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-18 14:20:36 +0200
commit843700875e50c03c94245bef1b2de147b9b3b585 (patch)
treea716990f1c92d96a521c466ee4036dfc8e7f6e47 /src
parent66b3101672f7da32df2fd3962d7f14300e7a65f3 (diff)
downloadvim-git-843700875e50c03c94245bef1b2de147b9b3b585.tar.gz
patch 8.2.0790: Vim9: list index not well testedv8.2.0790
Problem: Vim9: list index not well tested. Solution: Add a few more tests.
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_vim9_script.vim56
-rw-r--r--src/version.c2
2 files changed, 38 insertions, 20 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index f5391847c..22166fcb9 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -23,21 +23,6 @@ def Test_assignment()
let bool2: bool = false
assert_equal(v:false, bool2)
- let list1: list<bool> = [false, true, false]
- let list2: list<number> = [1, 2, 3]
- let list3: list<string> = ['sdf', 'asdf']
- let list4: list<any> = ['yes', true, 1234]
- let list5: list<blob> = [0z01, 0z02]
-
- let listS: list<string> = []
- let listN: list<number> = []
-
- let dict1: dict<bool> = #{one: false, two: true}
- let dict2: dict<number> = #{one: 1, two: 2}
- let dict3: dict<string> = #{key: 'value'}
- let dict4: dict<any> = #{one: 1, two: '2'}
- let dict5: dict<blob> = #{one: 0z01, tw: 0z02}
-
call CheckDefFailure(['let x:string'], 'E1069:')
call CheckDefFailure(['let x:string = "x"'], 'E1069:')
call CheckDefFailure(['let a:string = "x"'], 'E1069:')
@@ -57,11 +42,6 @@ def Test_assignment()
let Funky2: func = function('len')
let Party2: func = funcref('g:Test_syntax')
- # type becomes list<any>
- let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
- # type becomes dict<any>
- let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
-
g:newvar = 'new'
assert_equal('new', g:newvar)
@@ -128,6 +108,42 @@ def Test_assignment()
call CheckDefFailure(['v:errmsg += 123'], 'E1013:')
enddef
+def Test_assignment_list()
+ let list1: list<bool> = [false, true, false]
+ let list2: list<number> = [1, 2, 3]
+ let list3: list<string> = ['sdf', 'asdf']
+ let list4: list<any> = ['yes', true, 1234]
+ let list5: list<blob> = [0z01, 0z02]
+
+ let listS: list<string> = []
+ let listN: list<number> = []
+
+ assert_equal([1, 2, 3], list2)
+ list2[-1] = 99
+ assert_equal([1, 2, 99], list2)
+ list2[-2] = 88
+ assert_equal([1, 88, 99], list2)
+ list2[-3] = 77
+ assert_equal([77, 88, 99], list2)
+ call CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
+
+ # type becomes list<any>
+ let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
+enddef
+
+def Test_assignment_dict()
+ let dict1: dict<bool> = #{one: false, two: true}
+ let dict2: dict<number> = #{one: 1, two: 2}
+ let dict3: dict<string> = #{key: 'value'}
+ let dict4: dict<any> = #{one: 1, two: '2'}
+ let dict5: dict<blob> = #{one: 0z01, tw: 0z02}
+
+ call CheckDefExecFailure(['let dd = {}', 'dd[""] = 6'], 'E713:')
+
+ # type becomes dict<any>
+ let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
+enddef
+
def Test_assignment_local()
" Test in a separated file in order not to the current buffer/window/tab is
" changed.
diff --git a/src/version.c b/src/version.c
index 53d69d54b..aa03f906c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 790,
+/**/
789,
/**/
788,