• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision4c488004edbc8b6d5452eb564cb9fe3d093d581f (tree)
Zeit2020-09-22 05:30:03
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.1724: Vim9: assignment tests spread out

Commit: https://github.com/vim/vim/commit/971caf53b81b7d1b6fb0bdf32990632975d54631
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 21 22:21:42 2020 +0200

patch 8.2.1724: Vim9: assignment tests spread out
Problem: Vim9: assignment tests spread out.
Solution: Create new test file for assignment tests.

Ändern Zusammenfassung

Diff

diff -r 416fa143fa2d -r 4c488004edbc src/testdir/Make_all.mak
--- a/src/testdir/Make_all.mak Mon Sep 21 22:15:04 2020 +0200
+++ b/src/testdir/Make_all.mak Mon Sep 21 22:30:03 2020 +0200
@@ -30,6 +30,7 @@
3030
3131 # Tests for Vim9 script.
3232 TEST_VIM9 = \
33+ test_vim9_assign \
3334 test_vim9_cmd \
3435 test_vim9_disassemble \
3536 test_vim9_expr \
@@ -37,6 +38,7 @@
3738 test_vim9_script
3839
3940 TEST_VIM9_RES = \
41+ test_vim9_assign.res \
4042 test_vim9_cmd.res \
4143 test_vim9_disassemble.res \
4244 test_vim9_expr.res \
diff -r 416fa143fa2d -r 4c488004edbc src/testdir/test_vim9_assign.vim
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test_vim9_assign.vim Mon Sep 21 22:30:03 2020 +0200
@@ -0,0 +1,693 @@
1+" Test Vim9 assignments
2+
3+source check.vim
4+source vim9.vim
5+
6+let s:appendToMe = 'xxx'
7+let s:addToMe = 111
8+let g:existing = 'yes'
9+let g:inc_counter = 1
10+let $SOME_ENV_VAR = 'some'
11+let g:alist = [7]
12+let g:astring = 'text'
13+
14+def Test_assignment_bool()
15+ let bool1: bool = true
16+ assert_equal(v:true, bool1)
17+ let bool2: bool = false
18+ assert_equal(v:false, bool2)
19+
20+ let bool3: bool = 0
21+ assert_equal(false, bool3)
22+ let bool4: bool = 1
23+ assert_equal(true, bool4)
24+
25+ let bool5: bool = 'yes' && 'no'
26+ assert_equal(true, bool5)
27+ let bool6: bool = [] && 99
28+ assert_equal(false, bool6)
29+ let bool7: bool = [] || #{a: 1} && 99
30+ assert_equal(true, bool7)
31+
32+ let lines =<< trim END
33+ vim9script
34+ def GetFlag(): bool
35+ let flag: bool = 1
36+ return flag
37+ enddef
38+ let flag: bool = GetFlag()
39+ assert_equal(true, flag)
40+ flag = 0
41+ assert_equal(false, flag)
42+ flag = 1
43+ assert_equal(true, flag)
44+ flag = 99 || 123
45+ assert_equal(true, flag)
46+ flag = 'yes' && []
47+ assert_equal(false, flag)
48+ END
49+ CheckScriptSuccess(lines)
50+ CheckDefAndScriptFailure(['let x: bool = 2'], 'E1012:')
51+ CheckDefAndScriptFailure(['let x: bool = -1'], 'E1012:')
52+ CheckDefAndScriptFailure(['let x: bool = [1]'], 'E1012:')
53+ CheckDefAndScriptFailure(['let x: bool = {}'], 'E1012:')
54+ CheckDefAndScriptFailure(['let x: bool = "x"'], 'E1012:')
55+enddef
56+
57+def Test_syntax()
58+ let var = 234
59+ let other: list<string> = ['asdf']
60+enddef
61+
62+def Test_assignment()
63+ CheckDefFailure(['let x:string'], 'E1069:')
64+ CheckDefFailure(['let x:string = "x"'], 'E1069:')
65+ CheckDefFailure(['let a:string = "x"'], 'E1069:')
66+ CheckDefFailure(['let lambda = {-> "lambda"}'], 'E704:')
67+
68+ let nr: number = 1234
69+ CheckDefFailure(['let nr: number = "asdf"'], 'E1012:')
70+
71+ let a: number = 6 #comment
72+ assert_equal(6, a)
73+
74+ if has('channel')
75+ let chan1: channel
76+ let job1: job
77+ let job2: job = job_start('willfail')
78+ endif
79+ if has('float')
80+ let float1: float = 3.4
81+ endif
82+ let Funky1: func
83+ let Funky2: func = function('len')
84+ let Party2: func = funcref('g:Test_syntax')
85+
86+ g:newvar = 'new' #comment
87+ assert_equal('new', g:newvar)
88+
89+ assert_equal('yes', g:existing)
90+ g:existing = 'no'
91+ assert_equal('no', g:existing)
92+
93+ v:char = 'abc'
94+ assert_equal('abc', v:char)
95+
96+ $ENVVAR = 'foobar'
97+ assert_equal('foobar', $ENVVAR)
98+ $ENVVAR = ''
99+
100+ let lines =<< trim END
101+ vim9script
102+ $ENVVAR = 'barfoo'
103+ assert_equal('barfoo', $ENVVAR)
104+ $ENVVAR = ''
105+ END
106+ CheckScriptSuccess(lines)
107+
108+ s:appendToMe ..= 'yyy'
109+ assert_equal('xxxyyy', s:appendToMe)
110+ s:addToMe += 222
111+ assert_equal(333, s:addToMe)
112+ s:newVar = 'new'
113+ assert_equal('new', s:newVar)
114+
115+ set ts=7
116+ &ts += 1
117+ assert_equal(8, &ts)
118+ &ts -= 3
119+ assert_equal(5, &ts)
120+ &ts *= 2
121+ assert_equal(10, &ts)
122+ &ts /= 3
123+ assert_equal(3, &ts)
124+ set ts=10
125+ &ts %= 4
126+ assert_equal(2, &ts)
127+
128+ if has('float')
129+ let f100: float = 100.0
130+ f100 /= 5
131+ assert_equal(20.0, f100)
132+
133+ let f200: float = 200.0
134+ f200 /= 5.0
135+ assert_equal(40.0, f200)
136+
137+ CheckDefFailure(['let nr: number = 200', 'nr /= 5.0'], 'E1012:')
138+ endif
139+
140+ lines =<< trim END
141+ &ts = 6
142+ &ts += 3
143+ assert_equal(9, &ts)
144+
145+ &l:ts = 6
146+ assert_equal(6, &ts)
147+ &l:ts += 2
148+ assert_equal(8, &ts)
149+
150+ &g:ts = 6
151+ assert_equal(6, &g:ts)
152+ &g:ts += 2
153+ assert_equal(8, &g:ts)
154+ END
155+ CheckDefAndScriptSuccess(lines)
156+
157+ CheckDefFailure(['&notex += 3'], 'E113:')
158+ CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
159+ CheckDefFailure(['&ts = [7]'], 'E1012:')
160+ CheckDefExecFailure(['&ts = g:alist'], 'E1012: Type mismatch; expected number but got list<number>')
161+ CheckDefFailure(['&ts = "xx"'], 'E1012:')
162+ CheckDefExecFailure(['&ts = g:astring'], 'E1012: Type mismatch; expected number but got string')
163+ CheckDefFailure(['&path += 3'], 'E1012:')
164+ CheckDefExecFailure(['&bs = "asdf"'], 'E474:')
165+ # test freeing ISN_STOREOPT
166+ CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:')
167+ &ts = 8
168+
169+ lines =<< trim END
170+ let save_TI = &t_TI
171+ &t_TI = ''
172+ assert_equal('', &t_TI)
173+ &t_TI = 'xxx'
174+ assert_equal('xxx', &t_TI)
175+ &t_TI = save_TI
176+ END
177+ CheckDefAndScriptSuccess(lines)
178+
179+ CheckDefFailure(['&t_TI = 123'], 'E1012:')
180+ CheckScriptFailure(['vim9script', '&t_TI = 123'], 'E928:')
181+
182+ CheckDefFailure(['let s:var = 123'], 'E1101:')
183+ CheckDefFailure(['let s:var: number'], 'E1101:')
184+
185+ lines =<< trim END
186+ vim9script
187+ def SomeFunc()
188+ s:var = 123
189+ enddef
190+ defcompile
191+ END
192+ CheckScriptFailure(lines, 'E1089:')
193+
194+ g:inc_counter += 1
195+ assert_equal(2, g:inc_counter)
196+
197+ $SOME_ENV_VAR ..= 'more'
198+ assert_equal('somemore', $SOME_ENV_VAR)
199+ CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:')
200+ CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:')
201+
202+ lines =<< trim END
203+ @c = 'areg'
204+ @c ..= 'add'
205+ assert_equal('aregadd', @c)
206+ END
207+ CheckDefAndScriptSuccess(lines)
208+
209+ CheckDefFailure(['@a += "more"'], 'E1051:')
210+ CheckDefFailure(['@a += 123'], 'E1012:')
211+
212+ v:errmsg = 'none'
213+ v:errmsg ..= 'again'
214+ assert_equal('noneagain', v:errmsg)
215+ CheckDefFailure(['v:errmsg += "more"'], 'E1051:')
216+ CheckDefFailure(['v:errmsg += 123'], 'E1012:')
217+
218+ # this should not leak
219+ if 0
220+ let text =<< trim END
221+ some text
222+ END
223+ endif
224+enddef
225+
226+def Test_single_letter_vars()
227+ # single letter variables
228+ let a: number = 123
229+ a = 123
230+ assert_equal(123, a)
231+ let b: number
232+ b = 123
233+ assert_equal(123, b)
234+ let g: number
235+ g = 123
236+ assert_equal(123, g)
237+ let s: number
238+ s = 123
239+ assert_equal(123, s)
240+ let t: number
241+ t = 123
242+ assert_equal(123, t)
243+ let v: number
244+ v = 123
245+ assert_equal(123, v)
246+ let w: number
247+ w = 123
248+ assert_equal(123, w)
249+enddef
250+
251+def Test_vim9_single_char_vars()
252+ let lines =<< trim END
253+ vim9script
254+
255+ # single character variable declarations work
256+ let a: string
257+ let b: number
258+ let l: list<any>
259+ let s: string
260+ let t: number
261+ let v: number
262+ let w: number
263+
264+ # script-local variables can be used without s: prefix
265+ a = 'script-a'
266+ b = 111
267+ l = [1, 2, 3]
268+ s = 'script-s'
269+ t = 222
270+ v = 333
271+ w = 444
272+
273+ assert_equal('script-a', a)
274+ assert_equal(111, b)
275+ assert_equal([1, 2, 3], l)
276+ assert_equal('script-s', s)
277+ assert_equal(222, t)
278+ assert_equal(333, v)
279+ assert_equal(444, w)
280+ END
281+ writefile(lines, 'Xsinglechar')
282+ source Xsinglechar
283+ delete('Xsinglechar')
284+enddef
285+
286+def Test_assignment_list()
287+ let list1: list<bool> = [false, true, false]
288+ let list2: list<number> = [1, 2, 3]
289+ let list3: list<string> = ['sdf', 'asdf']
290+ let list4: list<any> = ['yes', true, 1234]
291+ let list5: list<blob> = [0z01, 0z02]
292+
293+ let listS: list<string> = []
294+ let listN: list<number> = []
295+
296+ assert_equal([1, 2, 3], list2)
297+ list2[-1] = 99
298+ assert_equal([1, 2, 99], list2)
299+ list2[-2] = 88
300+ assert_equal([1, 88, 99], list2)
301+ list2[-3] = 77
302+ assert_equal([77, 88, 99], list2)
303+ list2 += [100]
304+ assert_equal([77, 88, 99, 100], list2)
305+
306+ list3 += ['end']
307+ assert_equal(['sdf', 'asdf', 'end'], list3)
308+
309+ CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
310+ CheckDefExecFailure(['let [v1, v2] = [1, 2]'], 'E1092:')
311+
312+ # type becomes list<any>
313+ let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
314+enddef
315+
316+def Test_assignment_list_vim9script()
317+ let lines =<< trim END
318+ vim9script
319+ let v1: number
320+ let v2: number
321+ let v3: number
322+ [v1, v2, v3] = [1, 2, 3]
323+ assert_equal([1, 2, 3], [v1, v2, v3])
324+ END
325+ CheckScriptSuccess(lines)
326+enddef
327+
328+def Test_assignment_dict()
329+ let dict1: dict<bool> = #{one: false, two: true}
330+ let dict2: dict<number> = #{one: 1, two: 2}
331+ let dict3: dict<string> = #{key: 'value'}
332+ let dict4: dict<any> = #{one: 1, two: '2'}
333+ let dict5: dict<blob> = #{one: 0z01, two: 0z02}
334+
335+ # overwrite
336+ dict3['key'] = 'another'
337+
338+ # empty key can be used
339+ let dd = {}
340+ dd[""] = 6
341+ assert_equal({'': 6}, dd)
342+
343+ # type becomes dict<any>
344+ let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
345+
346+ # assignment to script-local dict
347+ let lines =<< trim END
348+ vim9script
349+ let test: dict<any> = {}
350+ def FillDict(): dict<any>
351+ test['a'] = 43
352+ return test
353+ enddef
354+ assert_equal(#{a: 43}, FillDict())
355+ END
356+ CheckScriptSuccess(lines)
357+
358+ lines =<< trim END
359+ vim9script
360+ let test: dict<any>
361+ def FillDict(): dict<any>
362+ test['a'] = 43
363+ return test
364+ enddef
365+ FillDict()
366+ END
367+ CheckScriptFailure(lines, 'E1103:')
368+
369+ # assignment to global dict
370+ lines =<< trim END
371+ vim9script
372+ g:test = {}
373+ def FillDict(): dict<any>
374+ g:test['a'] = 43
375+ return g:test
376+ enddef
377+ assert_equal(#{a: 43}, FillDict())
378+ END
379+ CheckScriptSuccess(lines)
380+
381+ # assignment to buffer dict
382+ lines =<< trim END
383+ vim9script
384+ b:test = {}
385+ def FillDict(): dict<any>
386+ b:test['a'] = 43
387+ return b:test
388+ enddef
389+ assert_equal(#{a: 43}, FillDict())
390+ END
391+ CheckScriptSuccess(lines)
392+enddef
393+
394+def Test_assignment_local()
395+ # Test in a separated file in order not to the current buffer/window/tab is
396+ # changed.
397+ let script_lines: list<string> =<< trim END
398+ let b:existing = 'yes'
399+ let w:existing = 'yes'
400+ let t:existing = 'yes'
401+
402+ def Test_assignment_local_internal()
403+ b:newvar = 'new'
404+ assert_equal('new', b:newvar)
405+ assert_equal('yes', b:existing)
406+ b:existing = 'no'
407+ assert_equal('no', b:existing)
408+ b:existing ..= 'NO'
409+ assert_equal('noNO', b:existing)
410+
411+ w:newvar = 'new'
412+ assert_equal('new', w:newvar)
413+ assert_equal('yes', w:existing)
414+ w:existing = 'no'
415+ assert_equal('no', w:existing)
416+ w:existing ..= 'NO'
417+ assert_equal('noNO', w:existing)
418+
419+ t:newvar = 'new'
420+ assert_equal('new', t:newvar)
421+ assert_equal('yes', t:existing)
422+ t:existing = 'no'
423+ assert_equal('no', t:existing)
424+ t:existing ..= 'NO'
425+ assert_equal('noNO', t:existing)
426+ enddef
427+ call Test_assignment_local_internal()
428+ END
429+ CheckScriptSuccess(script_lines)
430+enddef
431+
432+def Test_assignment_default()
433+
434+ # Test default values.
435+ let thebool: bool
436+ assert_equal(v:false, thebool)
437+
438+ let thenumber: number
439+ assert_equal(0, thenumber)
440+
441+ if has('float')
442+ let thefloat: float
443+ assert_equal(0.0, thefloat)
444+ endif
445+
446+ let thestring: string
447+ assert_equal('', thestring)
448+
449+ let theblob: blob
450+ assert_equal(0z, theblob)
451+
452+ let Thefunc: func
453+ assert_equal(test_null_function(), Thefunc)
454+
455+ let thelist: list<any>
456+ assert_equal([], thelist)
457+
458+ let thedict: dict<any>
459+ assert_equal({}, thedict)
460+
461+ if has('channel')
462+ let thejob: job
463+ assert_equal(test_null_job(), thejob)
464+
465+ let thechannel: channel
466+ assert_equal(test_null_channel(), thechannel)
467+
468+ if has('unix') && executable('cat')
469+ # check with non-null job and channel, types must match
470+ thejob = job_start("cat ", #{})
471+ thechannel = job_getchannel(thejob)
472+ job_stop(thejob, 'kill')
473+ endif
474+ endif
475+
476+ let nr = 1234 | nr = 5678
477+ assert_equal(5678, nr)
478+enddef
479+
480+def Test_assignment_var_list()
481+ let v1: string
482+ let v2: string
483+ let vrem: list<string>
484+ [v1] = ['aaa']
485+ assert_equal('aaa', v1)
486+
487+ [v1, v2] = ['one', 'two']
488+ assert_equal('one', v1)
489+ assert_equal('two', v2)
490+
491+ [v1, v2; vrem] = ['one', 'two']
492+ assert_equal('one', v1)
493+ assert_equal('two', v2)
494+ assert_equal([], vrem)
495+
496+ [v1, v2; vrem] = ['one', 'two', 'three']
497+ assert_equal('one', v1)
498+ assert_equal('two', v2)
499+ assert_equal(['three'], vrem)
500+
501+ [&ts, &sw] = [3, 4]
502+ assert_equal(3, &ts)
503+ assert_equal(4, &sw)
504+ set ts=8 sw=4
505+enddef
506+
507+def Test_assignment_vim9script()
508+ let lines =<< trim END
509+ vim9script
510+ def Func(): list<number>
511+ return [1, 2]
512+ enddef
513+ let var1: number
514+ let var2: number
515+ [var1, var2] =
516+ Func()
517+ assert_equal(1, var1)
518+ assert_equal(2, var2)
519+ let ll =
520+ Func()
521+ assert_equal([1, 2], ll)
522+
523+ @/ = 'text'
524+ assert_equal('text', @/)
525+ @0 = 'zero'
526+ assert_equal('zero', @0)
527+ @1 = 'one'
528+ assert_equal('one', @1)
529+ @9 = 'nine'
530+ assert_equal('nine', @9)
531+ @- = 'minus'
532+ assert_equal('minus', @-)
533+ if has('clipboard_working')
534+ @* = 'star'
535+ assert_equal('star', @*)
536+ @+ = 'plus'
537+ assert_equal('plus', @+)
538+ endif
539+
540+ let a: number = 123
541+ assert_equal(123, a)
542+ let s: string = 'yes'
543+ assert_equal('yes', s)
544+ let b: number = 42
545+ assert_equal(42, b)
546+ let w: number = 43
547+ assert_equal(43, w)
548+ let t: number = 44
549+ assert_equal(44, t)
550+ END
551+ CheckScriptSuccess(lines)
552+enddef
553+
554+def Mess(): string
555+ v:foldstart = 123
556+ return 'xxx'
557+enddef
558+
559+def Test_assignment_failure()
560+ CheckDefFailure(['let var=234'], 'E1004:')
561+ CheckDefFailure(['let var =234'], 'E1004:')
562+ CheckDefFailure(['let var= 234'], 'E1004:')
563+
564+ CheckScriptFailure(['vim9script', 'let var=234'], 'E1004:')
565+ CheckScriptFailure(['vim9script', 'let var=234'], "before and after '='")
566+ CheckScriptFailure(['vim9script', 'let var =234'], 'E1004:')
567+ CheckScriptFailure(['vim9script', 'let var= 234'], 'E1004:')
568+ CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], 'E1004:')
569+ CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], "before and after '+='")
570+ CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], 'E1004:')
571+ CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], "before and after '..='")
572+
573+ CheckDefFailure(['let true = 1'], 'E1034:')
574+ CheckDefFailure(['let false = 1'], 'E1034:')
575+
576+ CheckDefFailure(['[a; b; c] = g:list'], 'E452:')
577+ CheckDefExecFailure(['let a: number',
578+ '[a] = test_null_list()'], 'E1093:')
579+ CheckDefExecFailure(['let a: number',
580+ '[a] = []'], 'E1093:')
581+ CheckDefExecFailure(['let x: number',
582+ 'let y: number',
583+ '[x, y] = [1]'], 'E1093:')
584+ CheckDefExecFailure(['let x: number',
585+ 'let y: number',
586+ 'let z: list<number>',
587+ '[x, y; z] = [1]'], 'E1093:')
588+
589+ CheckDefFailure(['let somevar'], "E1022:")
590+ CheckDefFailure(['let &tabstop = 4'], 'E1052:')
591+ CheckDefFailure(['&g:option = 5'], 'E113:')
592+ CheckScriptFailure(['vim9script', 'let &tabstop = 4'], 'E1052:')
593+
594+ CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:')
595+ CheckScriptFailure(['vim9script', 'let $ENV = "xxx"'], 'E1016:')
596+
597+ if has('dnd')
598+ CheckDefFailure(['let @~ = 5'], 'E1066:')
599+ else
600+ CheckDefFailure(['let @~ = 5'], 'E354:')
601+ CheckDefFailure(['@~ = 5'], 'E354:')
602+ endif
603+ CheckDefFailure(['let @a = 5'], 'E1066:')
604+ CheckDefFailure(['let @/ = "x"'], 'E1066:')
605+ CheckScriptFailure(['vim9script', 'let @a = "abc"'], 'E1066:')
606+
607+ CheckDefFailure(['let g:var = 5'], 'E1016: Cannot declare a global variable:')
608+ CheckDefFailure(['let w:var = 5'], 'E1016: Cannot declare a window variable:')
609+ CheckDefFailure(['let b:var = 5'], 'E1016: Cannot declare a buffer variable:')
610+ CheckDefFailure(['let t:var = 5'], 'E1016: Cannot declare a tab variable:')
611+
612+ CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:')
613+ CheckDefFailure(['let xnr += 4'], 'E1020:', 1)
614+ CheckScriptFailure(['vim9script', 'let xnr += 4'], 'E1020:')
615+ CheckDefFailure(["let xnr = xnr + 1"], 'E1001:', 1)
616+ CheckScriptFailure(['vim9script', 'let xnr = xnr + 4'], 'E121:')
617+
618+ CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:')
619+
620+ CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>')
621+ CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>')
622+
623+ CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>')
624+ CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>')
625+
626+ CheckDefFailure(['let var = feedkeys("0")'], 'E1031:')
627+ CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void')
628+
629+ CheckDefFailure(['let var: dict <number>'], 'E1068:')
630+ CheckDefFailure(['let var: dict<number'], 'E1009:')
631+
632+ assert_fails('s/^/\=Mess()/n', 'E794:')
633+ CheckDefFailure(['let var: dict<number'], 'E1009:')
634+
635+ CheckDefFailure(['w:foo: number = 10'],
636+ 'E488: Trailing characters: : number = 1')
637+ CheckDefFailure(['t:foo: bool = true'],
638+ 'E488: Trailing characters: : bool = true')
639+ CheckDefFailure(['b:foo: string = "x"'],
640+ 'E488: Trailing characters: : string = "x"')
641+ CheckDefFailure(['g:foo: number = 123'],
642+ 'E488: Trailing characters: : number = 123')
643+enddef
644+
645+def Test_assign_list()
646+ let l: list<string> = []
647+ l[0] = 'value'
648+ assert_equal('value', l[0])
649+
650+ l[1] = 'asdf'
651+ assert_equal('value', l[0])
652+ assert_equal('asdf', l[1])
653+ assert_equal('asdf', l[-1])
654+ assert_equal('value', l[-2])
655+
656+ let nrl: list<number> = []
657+ for i in range(5)
658+ nrl[i] = i
659+ endfor
660+ assert_equal([0, 1, 2, 3, 4], nrl)
661+enddef
662+
663+def Test_assign_dict()
664+ let d: dict<string> = {}
665+ d['key'] = 'value'
666+ assert_equal('value', d['key'])
667+
668+ d[123] = 'qwerty'
669+ assert_equal('qwerty', d[123])
670+ assert_equal('qwerty', d['123'])
671+
672+ let nrd: dict<number> = {}
673+ for i in range(3)
674+ nrd[i] = i
675+ endfor
676+ assert_equal({'0': 0, '1': 1, '2': 2}, nrd)
677+enddef
678+
679+def Test_assign_lambda()
680+ # check if assign a lambda to a variable which type is func or any.
681+ let lines =<< trim END
682+ vim9script
683+ let FuncRef = {->123}
684+ assert_equal(123, FuncRef())
685+ let FuncRef_Func: func = {->123}
686+ assert_equal(123, FuncRef_Func())
687+ let FuncRef_Any: any = {->123}
688+ assert_equal(123, FuncRef_Any())
689+ END
690+ CheckScriptSuccess(lines)
691+enddef
692+
693+" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff -r 416fa143fa2d -r 4c488004edbc src/testdir/test_vim9_cmd.vim
--- a/src/testdir/test_vim9_cmd.vim Mon Sep 21 22:15:04 2020 +0200
+++ b/src/testdir/test_vim9_cmd.vim Mon Sep 21 22:30:03 2020 +0200
@@ -45,40 +45,6 @@
4545 delete('Xthemine.vim')
4646 enddef
4747
48-def Test_assign_list()
49- let l: list<string> = []
50- l[0] = 'value'
51- assert_equal('value', l[0])
52-
53- l[1] = 'asdf'
54- assert_equal('value', l[0])
55- assert_equal('asdf', l[1])
56- assert_equal('asdf', l[-1])
57- assert_equal('value', l[-2])
58-
59- let nrl: list<number> = []
60- for i in range(5)
61- nrl[i] = i
62- endfor
63- assert_equal([0, 1, 2, 3, 4], nrl)
64-enddef
65-
66-def Test_assign_dict()
67- let d: dict<string> = {}
68- d['key'] = 'value'
69- assert_equal('value', d['key'])
70-
71- d[123] = 'qwerty'
72- assert_equal('qwerty', d[123])
73- assert_equal('qwerty', d['123'])
74-
75- let nrd: dict<number> = {}
76- for i in range(3)
77- nrd[i] = i
78- endfor
79- assert_equal({'0': 0, '1': 1, '2': 2}, nrd)
80-enddef
81-
8248 def Test_echo_linebreak()
8349 let lines =<< trim END
8450 vim9script
diff -r 416fa143fa2d -r 4c488004edbc src/testdir/test_vim9_expr.vim
--- a/src/testdir/test_vim9_expr.vim Mon Sep 21 22:15:04 2020 +0200
+++ b/src/testdir/test_vim9_expr.vim Mon Sep 21 22:30:03 2020 +0200
@@ -1687,18 +1687,6 @@
16871687 ->map({_, v -> synIDattr(v, 'name')})->len()})
16881688 END
16891689 CheckScriptSuccess(lines)
1690-
1691- # check if assign a lambda to a variable which type is func or any.
1692- lines =<< trim END
1693- vim9script
1694- let FuncRef = {->123}
1695- assert_equal(123, FuncRef())
1696- let FuncRef_Func: func = {->123}
1697- assert_equal(123, FuncRef_Func())
1698- let FuncRef_Any: any = {->123}
1699- assert_equal(123, FuncRef_Any())
1700- END
1701- CheckScriptSuccess(lines)
17021690 enddef
17031691
17041692 def Test_epxr7_funcref()
diff -r 416fa143fa2d -r 4c488004edbc src/testdir/test_vim9_script.vim
--- a/src/testdir/test_vim9_script.vim Mon Sep 21 22:15:04 2020 +0200
+++ b/src/testdir/test_vim9_script.vim Mon Sep 21 22:30:03 2020 +0200
@@ -6,11 +6,6 @@
66 source vim9.vim
77 source shared.vim
88
9-def Test_syntax()
10- let var = 234
11- let other: list<string> = ['asdf']
12-enddef
13-
149 def Test_range_only()
1510 new
1611 setline(1, ['blah', 'Blah'])
@@ -30,639 +25,10 @@
3025 bwipe!
3126 enddef
3227
33-let s:appendToMe = 'xxx'
34-let s:addToMe = 111
35-let g:existing = 'yes'
36-let g:inc_counter = 1
37-let $SOME_ENV_VAR = 'some'
3828 let g:alist = [7]
3929 let g:astring = 'text'
4030 let g:anumber = 123
4131
42-def Test_assignment_bool()
43- let bool1: bool = true
44- assert_equal(v:true, bool1)
45- let bool2: bool = false
46- assert_equal(v:false, bool2)
47-
48- let bool3: bool = 0
49- assert_equal(false, bool3)
50- let bool4: bool = 1
51- assert_equal(true, bool4)
52-
53- let bool5: bool = 'yes' && 'no'
54- assert_equal(true, bool5)
55- let bool6: bool = [] && 99
56- assert_equal(false, bool6)
57- let bool7: bool = [] || #{a: 1} && 99
58- assert_equal(true, bool7)
59-
60- let lines =<< trim END
61- vim9script
62- def GetFlag(): bool
63- let flag: bool = 1
64- return flag
65- enddef
66- let flag: bool = GetFlag()
67- assert_equal(true, flag)
68- flag = 0
69- assert_equal(false, flag)
70- flag = 1
71- assert_equal(true, flag)
72- flag = 99 || 123
73- assert_equal(true, flag)
74- flag = 'yes' && []
75- assert_equal(false, flag)
76- END
77- CheckScriptSuccess(lines)
78- CheckDefAndScriptFailure(['let x: bool = 2'], 'E1012:')
79- CheckDefAndScriptFailure(['let x: bool = -1'], 'E1012:')
80- CheckDefAndScriptFailure(['let x: bool = [1]'], 'E1012:')
81- CheckDefAndScriptFailure(['let x: bool = {}'], 'E1012:')
82- CheckDefAndScriptFailure(['let x: bool = "x"'], 'E1012:')
83-enddef
84-
85-def Test_assignment()
86- CheckDefFailure(['let x:string'], 'E1069:')
87- CheckDefFailure(['let x:string = "x"'], 'E1069:')
88- CheckDefFailure(['let a:string = "x"'], 'E1069:')
89- CheckDefFailure(['let lambda = {-> "lambda"}'], 'E704:')
90-
91- let nr: number = 1234
92- CheckDefFailure(['let nr: number = "asdf"'], 'E1012:')
93-
94- let a: number = 6 #comment
95- assert_equal(6, a)
96-
97- if has('channel')
98- let chan1: channel
99- let job1: job
100- let job2: job = job_start('willfail')
101- endif
102- if has('float')
103- let float1: float = 3.4
104- endif
105- let Funky1: func
106- let Funky2: func = function('len')
107- let Party2: func = funcref('g:Test_syntax')
108-
109- g:newvar = 'new' #comment
110- assert_equal('new', g:newvar)
111-
112- assert_equal('yes', g:existing)
113- g:existing = 'no'
114- assert_equal('no', g:existing)
115-
116- v:char = 'abc'
117- assert_equal('abc', v:char)
118-
119- $ENVVAR = 'foobar'
120- assert_equal('foobar', $ENVVAR)
121- $ENVVAR = ''
122-
123- let lines =<< trim END
124- vim9script
125- $ENVVAR = 'barfoo'
126- assert_equal('barfoo', $ENVVAR)
127- $ENVVAR = ''
128- END
129- CheckScriptSuccess(lines)
130-
131- s:appendToMe ..= 'yyy'
132- assert_equal('xxxyyy', s:appendToMe)
133- s:addToMe += 222
134- assert_equal(333, s:addToMe)
135- s:newVar = 'new'
136- assert_equal('new', s:newVar)
137-
138- set ts=7
139- &ts += 1
140- assert_equal(8, &ts)
141- &ts -= 3
142- assert_equal(5, &ts)
143- &ts *= 2
144- assert_equal(10, &ts)
145- &ts /= 3
146- assert_equal(3, &ts)
147- set ts=10
148- &ts %= 4
149- assert_equal(2, &ts)
150-
151- if has('float')
152- let f100: float = 100.0
153- f100 /= 5
154- assert_equal(20.0, f100)
155-
156- let f200: float = 200.0
157- f200 /= 5.0
158- assert_equal(40.0, f200)
159-
160- CheckDefFailure(['let nr: number = 200', 'nr /= 5.0'], 'E1012:')
161- endif
162-
163- lines =<< trim END
164- &ts = 6
165- &ts += 3
166- assert_equal(9, &ts)
167-
168- &l:ts = 6
169- assert_equal(6, &ts)
170- &l:ts += 2
171- assert_equal(8, &ts)
172-
173- &g:ts = 6
174- assert_equal(6, &g:ts)
175- &g:ts += 2
176- assert_equal(8, &g:ts)
177- END
178- CheckDefAndScriptSuccess(lines)
179-
180- CheckDefFailure(['&notex += 3'], 'E113:')
181- CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
182- CheckDefFailure(['&ts = [7]'], 'E1012:')
183- CheckDefExecFailure(['&ts = g:alist'], 'E1012: Type mismatch; expected number but got list<number>')
184- CheckDefFailure(['&ts = "xx"'], 'E1012:')
185- CheckDefExecFailure(['&ts = g:astring'], 'E1012: Type mismatch; expected number but got string')
186- CheckDefFailure(['&path += 3'], 'E1012:')
187- CheckDefExecFailure(['&bs = "asdf"'], 'E474:')
188- # test freeing ISN_STOREOPT
189- CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:')
190- &ts = 8
191-
192- lines =<< trim END
193- let save_TI = &t_TI
194- &t_TI = ''
195- assert_equal('', &t_TI)
196- &t_TI = 'xxx'
197- assert_equal('xxx', &t_TI)
198- &t_TI = save_TI
199- END
200- CheckDefAndScriptSuccess(lines)
201-
202- CheckDefFailure(['&t_TI = 123'], 'E1012:')
203- CheckScriptFailure(['vim9script', '&t_TI = 123'], 'E928:')
204-
205- CheckDefFailure(['let s:var = 123'], 'E1101:')
206- CheckDefFailure(['let s:var: number'], 'E1101:')
207-
208- lines =<< trim END
209- vim9script
210- def SomeFunc()
211- s:var = 123
212- enddef
213- defcompile
214- END
215- CheckScriptFailure(lines, 'E1089:')
216-
217- g:inc_counter += 1
218- assert_equal(2, g:inc_counter)
219-
220- $SOME_ENV_VAR ..= 'more'
221- assert_equal('somemore', $SOME_ENV_VAR)
222- CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:')
223- CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:')
224-
225- lines =<< trim END
226- @c = 'areg'
227- @c ..= 'add'
228- assert_equal('aregadd', @c)
229- END
230- CheckDefAndScriptSuccess(lines)
231-
232- CheckDefFailure(['@a += "more"'], 'E1051:')
233- CheckDefFailure(['@a += 123'], 'E1012:')
234-
235- v:errmsg = 'none'
236- v:errmsg ..= 'again'
237- assert_equal('noneagain', v:errmsg)
238- CheckDefFailure(['v:errmsg += "more"'], 'E1051:')
239- CheckDefFailure(['v:errmsg += 123'], 'E1012:')
240-
241- # single letter variables
242- a = 123
243- assert_equal(123, a)
244- let b: number
245- b = 123
246- assert_equal(123, b)
247- let g: number
248- g = 123
249- assert_equal(123, g)
250- let s: number
251- s = 123
252- assert_equal(123, s)
253- let t: number
254- t = 123
255- assert_equal(123, t)
256- let v: number
257- v = 123
258- assert_equal(123, v)
259- let w: number
260- w = 123
261- assert_equal(123, w)
262-
263-
264- # this should not leak
265- if 0
266- let text =<< trim END
267- some text
268- END
269- endif
270-enddef
271-
272-def Test_vim9_single_char_vars()
273- let lines =<< trim END
274- vim9script
275-
276- # single character variable declarations work
277- let a: string
278- let b: number
279- let l: list<any>
280- let s: string
281- let t: number
282- let v: number
283- let w: number
284-
285- # script-local variables can be used without s: prefix
286- a = 'script-a'
287- b = 111
288- l = [1, 2, 3]
289- s = 'script-s'
290- t = 222
291- v = 333
292- w = 444
293-
294- assert_equal('script-a', a)
295- assert_equal(111, b)
296- assert_equal([1, 2, 3], l)
297- assert_equal('script-s', s)
298- assert_equal(222, t)
299- assert_equal(333, v)
300- assert_equal(444, w)
301- END
302- writefile(lines, 'Xsinglechar')
303- source Xsinglechar
304- delete('Xsinglechar')
305-enddef
306-
307-def Test_assignment_list()
308- let list1: list<bool> = [false, true, false]
309- let list2: list<number> = [1, 2, 3]
310- let list3: list<string> = ['sdf', 'asdf']
311- let list4: list<any> = ['yes', true, 1234]
312- let list5: list<blob> = [0z01, 0z02]
313-
314- let listS: list<string> = []
315- let listN: list<number> = []
316-
317- assert_equal([1, 2, 3], list2)
318- list2[-1] = 99
319- assert_equal([1, 2, 99], list2)
320- list2[-2] = 88
321- assert_equal([1, 88, 99], list2)
322- list2[-3] = 77
323- assert_equal([77, 88, 99], list2)
324- list2 += [100]
325- assert_equal([77, 88, 99, 100], list2)
326-
327- list3 += ['end']
328- assert_equal(['sdf', 'asdf', 'end'], list3)
329-
330- CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
331- CheckDefExecFailure(['let [v1, v2] = [1, 2]'], 'E1092:')
332-
333- # type becomes list<any>
334- let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
335-enddef
336-
337-def Test_assignment_list_vim9script()
338- let lines =<< trim END
339- vim9script
340- let v1: number
341- let v2: number
342- let v3: number
343- [v1, v2, v3] = [1, 2, 3]
344- assert_equal([1, 2, 3], [v1, v2, v3])
345- END
346- CheckScriptSuccess(lines)
347-enddef
348-
349-def Test_assignment_dict()
350- let dict1: dict<bool> = #{one: false, two: true}
351- let dict2: dict<number> = #{one: 1, two: 2}
352- let dict3: dict<string> = #{key: 'value'}
353- let dict4: dict<any> = #{one: 1, two: '2'}
354- let dict5: dict<blob> = #{one: 0z01, two: 0z02}
355-
356- # overwrite
357- dict3['key'] = 'another'
358-
359- # empty key can be used
360- let dd = {}
361- dd[""] = 6
362- assert_equal({'': 6}, dd)
363-
364- # type becomes dict<any>
365- let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
366-
367- # assignment to script-local dict
368- let lines =<< trim END
369- vim9script
370- let test: dict<any> = {}
371- def FillDict(): dict<any>
372- test['a'] = 43
373- return test
374- enddef
375- assert_equal(#{a: 43}, FillDict())
376- END
377- CheckScriptSuccess(lines)
378-
379- lines =<< trim END
380- vim9script
381- let test: dict<any>
382- def FillDict(): dict<any>
383- test['a'] = 43
384- return test
385- enddef
386- FillDict()
387- END
388- CheckScriptFailure(lines, 'E1103:')
389-
390- # assignment to global dict
391- lines =<< trim END
392- vim9script
393- g:test = {}
394- def FillDict(): dict<any>
395- g:test['a'] = 43
396- return g:test
397- enddef
398- assert_equal(#{a: 43}, FillDict())
399- END
400- CheckScriptSuccess(lines)
401-
402- # assignment to buffer dict
403- lines =<< trim END
404- vim9script
405- b:test = {}
406- def FillDict(): dict<any>
407- b:test['a'] = 43
408- return b:test
409- enddef
410- assert_equal(#{a: 43}, FillDict())
411- END
412- CheckScriptSuccess(lines)
413-enddef
414-
415-def Test_assignment_local()
416- # Test in a separated file in order not to the current buffer/window/tab is
417- # changed.
418- let script_lines: list<string> =<< trim END
419- let b:existing = 'yes'
420- let w:existing = 'yes'
421- let t:existing = 'yes'
422-
423- def Test_assignment_local_internal()
424- b:newvar = 'new'
425- assert_equal('new', b:newvar)
426- assert_equal('yes', b:existing)
427- b:existing = 'no'
428- assert_equal('no', b:existing)
429- b:existing ..= 'NO'
430- assert_equal('noNO', b:existing)
431-
432- w:newvar = 'new'
433- assert_equal('new', w:newvar)
434- assert_equal('yes', w:existing)
435- w:existing = 'no'
436- assert_equal('no', w:existing)
437- w:existing ..= 'NO'
438- assert_equal('noNO', w:existing)
439-
440- t:newvar = 'new'
441- assert_equal('new', t:newvar)
442- assert_equal('yes', t:existing)
443- t:existing = 'no'
444- assert_equal('no', t:existing)
445- t:existing ..= 'NO'
446- assert_equal('noNO', t:existing)
447- enddef
448- call Test_assignment_local_internal()
449- END
450- CheckScriptSuccess(script_lines)
451-enddef
452-
453-def Test_assignment_default()
454-
455- # Test default values.
456- let thebool: bool
457- assert_equal(v:false, thebool)
458-
459- let thenumber: number
460- assert_equal(0, thenumber)
461-
462- if has('float')
463- let thefloat: float
464- assert_equal(0.0, thefloat)
465- endif
466-
467- let thestring: string
468- assert_equal('', thestring)
469-
470- let theblob: blob
471- assert_equal(0z, theblob)
472-
473- let Thefunc: func
474- assert_equal(test_null_function(), Thefunc)
475-
476- let thelist: list<any>
477- assert_equal([], thelist)
478-
479- let thedict: dict<any>
480- assert_equal({}, thedict)
481-
482- if has('channel')
483- let thejob: job
484- assert_equal(test_null_job(), thejob)
485-
486- let thechannel: channel
487- assert_equal(test_null_channel(), thechannel)
488-
489- if has('unix') && executable('cat')
490- # check with non-null job and channel, types must match
491- thejob = job_start("cat ", #{})
492- thechannel = job_getchannel(thejob)
493- job_stop(thejob, 'kill')
494- endif
495- endif
496-
497- let nr = 1234 | nr = 5678
498- assert_equal(5678, nr)
499-enddef
500-
501-def Test_assignment_var_list()
502- let v1: string
503- let v2: string
504- let vrem: list<string>
505- [v1] = ['aaa']
506- assert_equal('aaa', v1)
507-
508- [v1, v2] = ['one', 'two']
509- assert_equal('one', v1)
510- assert_equal('two', v2)
511-
512- [v1, v2; vrem] = ['one', 'two']
513- assert_equal('one', v1)
514- assert_equal('two', v2)
515- assert_equal([], vrem)
516-
517- [v1, v2; vrem] = ['one', 'two', 'three']
518- assert_equal('one', v1)
519- assert_equal('two', v2)
520- assert_equal(['three'], vrem)
521-
522- [&ts, &sw] = [3, 4]
523- assert_equal(3, &ts)
524- assert_equal(4, &sw)
525- set ts=8 sw=4
526-enddef
527-
528-def Test_assignment_vim9script()
529- let lines =<< trim END
530- vim9script
531- def Func(): list<number>
532- return [1, 2]
533- enddef
534- let var1: number
535- let var2: number
536- [var1, var2] =
537- Func()
538- assert_equal(1, var1)
539- assert_equal(2, var2)
540- let ll =
541- Func()
542- assert_equal([1, 2], ll)
543-
544- @/ = 'text'
545- assert_equal('text', @/)
546- @0 = 'zero'
547- assert_equal('zero', @0)
548- @1 = 'one'
549- assert_equal('one', @1)
550- @9 = 'nine'
551- assert_equal('nine', @9)
552- @- = 'minus'
553- assert_equal('minus', @-)
554- if has('clipboard_working')
555- @* = 'star'
556- assert_equal('star', @*)
557- @+ = 'plus'
558- assert_equal('plus', @+)
559- endif
560-
561- let a: number = 123
562- assert_equal(123, a)
563- let s: string = 'yes'
564- assert_equal('yes', s)
565- let b: number = 42
566- assert_equal(42, b)
567- let w: number = 43
568- assert_equal(43, w)
569- let t: number = 44
570- assert_equal(44, t)
571- END
572- CheckScriptSuccess(lines)
573-enddef
574-
575-def Mess(): string
576- v:foldstart = 123
577- return 'xxx'
578-enddef
579-
580-def Test_assignment_failure()
581- CheckDefFailure(['let var=234'], 'E1004:')
582- CheckDefFailure(['let var =234'], 'E1004:')
583- CheckDefFailure(['let var= 234'], 'E1004:')
584-
585- CheckScriptFailure(['vim9script', 'let var=234'], 'E1004:')
586- CheckScriptFailure(['vim9script', 'let var=234'], "before and after '='")
587- CheckScriptFailure(['vim9script', 'let var =234'], 'E1004:')
588- CheckScriptFailure(['vim9script', 'let var= 234'], 'E1004:')
589- CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], 'E1004:')
590- CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], "before and after '+='")
591- CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], 'E1004:')
592- CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], "before and after '..='")
593-
594- CheckDefFailure(['let true = 1'], 'E1034:')
595- CheckDefFailure(['let false = 1'], 'E1034:')
596-
597- CheckDefFailure(['[a; b; c] = g:list'], 'E452:')
598- CheckDefExecFailure(['let a: number',
599- '[a] = test_null_list()'], 'E1093:')
600- CheckDefExecFailure(['let a: number',
601- '[a] = []'], 'E1093:')
602- CheckDefExecFailure(['let x: number',
603- 'let y: number',
604- '[x, y] = [1]'], 'E1093:')
605- CheckDefExecFailure(['let x: number',
606- 'let y: number',
607- 'let z: list<number>',
608- '[x, y; z] = [1]'], 'E1093:')
609-
610- CheckDefFailure(['let somevar'], "E1022:")
611- CheckDefFailure(['let &tabstop = 4'], 'E1052:')
612- CheckDefFailure(['&g:option = 5'], 'E113:')
613- CheckScriptFailure(['vim9script', 'let &tabstop = 4'], 'E1052:')
614-
615- CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:')
616- CheckScriptFailure(['vim9script', 'let $ENV = "xxx"'], 'E1016:')
617-
618- if has('dnd')
619- CheckDefFailure(['let @~ = 5'], 'E1066:')
620- else
621- CheckDefFailure(['let @~ = 5'], 'E354:')
622- CheckDefFailure(['@~ = 5'], 'E354:')
623- endif
624- CheckDefFailure(['let @a = 5'], 'E1066:')
625- CheckDefFailure(['let @/ = "x"'], 'E1066:')
626- CheckScriptFailure(['vim9script', 'let @a = "abc"'], 'E1066:')
627-
628- CheckDefFailure(['let g:var = 5'], 'E1016: Cannot declare a global variable:')
629- CheckDefFailure(['let w:var = 5'], 'E1016: Cannot declare a window variable:')
630- CheckDefFailure(['let b:var = 5'], 'E1016: Cannot declare a buffer variable:')
631- CheckDefFailure(['let t:var = 5'], 'E1016: Cannot declare a tab variable:')
632-
633- CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:')
634- CheckDefFailure(['let xnr += 4'], 'E1020:', 1)
635- CheckScriptFailure(['vim9script', 'let xnr += 4'], 'E1020:')
636- CheckDefFailure(["let xnr = xnr + 1"], 'E1001:', 1)
637- CheckScriptFailure(['vim9script', 'let xnr = xnr + 4'], 'E121:')
638-
639- CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:')
640-
641- CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>')
642- CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>')
643-
644- CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>')
645- CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>')
646-
647- CheckDefFailure(['let var = feedkeys("0")'], 'E1031:')
648- CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void')
649-
650- CheckDefFailure(['let var: dict <number>'], 'E1068:')
651- CheckDefFailure(['let var: dict<number'], 'E1009:')
652-
653- assert_fails('s/^/\=Mess()/n', 'E794:')
654- CheckDefFailure(['let var: dict<number'], 'E1009:')
655-
656- CheckDefFailure(['w:foo: number = 10'],
657- 'E488: Trailing characters: : number = 1')
658- CheckDefFailure(['t:foo: bool = true'],
659- 'E488: Trailing characters: : bool = true')
660- CheckDefFailure(['b:foo: string = "x"'],
661- 'E488: Trailing characters: : string = "x"')
662- CheckDefFailure(['g:foo: number = 123'],
663- 'E488: Trailing characters: : number = 123')
664-enddef
665-
66632 def Test_unlet()
66733 g:somevar = 'yes'
66834 assert_true(exists('g:somevar'))
diff -r 416fa143fa2d -r 4c488004edbc src/version.c
--- a/src/version.c Mon Sep 21 22:15:04 2020 +0200
+++ b/src/version.c Mon Sep 21 22:30:03 2020 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1724,
755+/**/
754756 1723,
755757 /**/
756758 1722,
Show on old repository browser