Patch 8.2.0790

11 views
Skip to first unread message

Bram Moolenaar

unread,
May 18, 2020, 8:21:13 AM5/18/20
to vim...@googlegroups.com

Patch 8.2.0790
Problem: Vim9: list index not well tested.
Solution: Add a few more tests.
Files: src/testdir/test_vim9_script.vim


*** ../vim-8.2.0789/src/testdir/test_vim9_script.vim 2020-05-16 22:33:29.000787967 +0200
--- src/testdir/test_vim9_script.vim 2020-05-18 14:19:25.227485188 +0200
***************
*** 23,43 ****
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:')
--- 23,28 ----
***************
*** 57,67 ****
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)

--- 42,47 ----
***************
*** 128,133 ****
--- 108,149 ----
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.
*** ../vim-8.2.0789/src/version.c 2020-05-18 13:37:58.558383291 +0200
--- src/version.c 2020-05-18 14:20:10.159357555 +0200
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 790,
/**/

--
You cannot have a baby in one month by getting nine women pregnant.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christ van Willegen

unread,
May 18, 2020, 8:53:27 AM5/18/20
to vim...@googlegroups.com
Hi, 

Op ma 18 mei 2020 14:21 schreef Bram Moolenaar <Br...@moolenaar.net>:

Patch 8.2.0790
Problem:    Vim9: list index not well tested.
Solution:   Add a few more tests.

+   let dict5: dict<blob> = #{one: 0z01, tw: 0z02}

A sneaky typo here, although you don't use the result anywhere. 

Fix if you see fit to do so. 

Christ van Willegen

Bram Moolenaar

unread,
May 18, 2020, 9:18:39 AM5/18/20
to vim...@googlegroups.com, Christ van Willegen
Hah, it doesn't matter for the test. But perhaps confuses someone
looking at this. I'll add the "o" and let it be part of any next patch.

BTW: The more clever the compiler gets the harder it is to write
tests. At some point a variable declared with const would be
precomputed.

--
Statistics say that you can have a baby per month on average:
Just get nine women pregnant.
Reply all
Reply to author
Forward
0 new messages