1" Test various aspects of the Vim9 script language.
2
3source check.vim
4source view_util.vim
5
6" Check that "lines" inside ":def" results in an "error" message.
7func CheckDefFailure(lines, error)
8  call writefile(['def Func()'] + a:lines + ['enddef'], 'Xdef')
9  call assert_fails('so Xdef', a:error, a:lines)
10  call delete('Xdef')
11endfunc
12
13def CheckScriptFailure(lines: list<string>, error: string)
14  writefile(lines, 'Xdef')
15  assert_fails('so Xdef', error, lines)
16  delete('Xdef')
17enddef
18
19def CheckScriptSuccess(lines: list<string>)
20  writefile(lines, 'Xdef')
21  so Xdef
22  delete('Xdef')
23enddef
24
25def Test_syntax()
26  let var = 234
27  let other: list<string> = ['asdf']
28enddef
29
30let s:appendToMe = 'xxx'
31let s:addToMe = 111
32let g:existing = 'yes'
33let g:inc_counter = 1
34let $SOME_ENV_VAR = 'some'
35
36def Test_assignment()
37  let bool1: bool = true
38  assert_equal(v:true, bool1)
39  let bool2: bool = false
40  assert_equal(v:false, bool2)
41
42  let list1: list<bool> = [false, true, false]
43  let list2: list<number> = [1, 2, 3]
44  let list3: list<string> = ['sdf', 'asdf']
45  let list4: list<any> = ['yes', true, 1234]
46  let list5: list<blob> = [0z01, 0z02]
47
48  let listS: list<string> = []
49  let listN: list<number> = []
50
51  let dict1: dict<bool> = #{one: false, two: true}
52  let dict2: dict<number> = #{one: 1, two: 2}
53  let dict3: dict<string> = #{key: 'value'}
54  let dict4: dict<any> = #{one: 1, two: '2'}
55  let dict5: dict<blob> = #{one: 0z01, tw: 0z02}
56
57  call CheckDefFailure(['let x:string'], 'E1069:')
58  call CheckDefFailure(['let x:string = "x"'], 'E1069:')
59  call CheckDefFailure(['let a:string = "x"'], 'E1082:')
60
61  let a: number = 6
62  assert_equal(6, a)
63
64  if has('channel')
65    let chan1: channel
66    let job1: job
67    let job2: job = job_start('willfail')
68  endif
69  if has('float')
70    let float1: float = 3.4
71  endif
72  let Funky1: func
73  let Funky2: func = function('len')
74  let Party2: func = funcref('Test_syntax')
75
76  # type becomes list<any>
77  let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
78  # type becomes dict<any>
79  let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
80
81  g:newvar = 'new'
82  assert_equal('new', g:newvar)
83
84  assert_equal('yes', g:existing)
85  g:existing = 'no'
86  assert_equal('no', g:existing)
87
88  v:char = 'abc'
89  assert_equal('abc', v:char)
90
91  $ENVVAR = 'foobar'
92  assert_equal('foobar', $ENVVAR)
93  $ENVVAR = ''
94
95  s:appendToMe ..= 'yyy'
96  assert_equal('xxxyyy', s:appendToMe)
97  s:addToMe += 222
98  assert_equal(333, s:addToMe)
99  s:newVar = 'new'
100  assert_equal('new', s:newVar)
101
102  set ts=7
103  &ts += 1
104  assert_equal(8, &ts)
105  &ts -= 3
106  assert_equal(5, &ts)
107  &ts *= 2
108  assert_equal(10, &ts)
109  &ts /= 3
110  assert_equal(3, &ts)
111  set ts=10
112  &ts %= 4
113  assert_equal(2, &ts)
114  call CheckDefFailure(['&notex += 3'], 'E113:')
115  call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
116  call CheckDefFailure(['&path += 3'], 'E1013:')
117  # test freeing ISN_STOREOPT
118  call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:')
119  &ts = 8
120
121  g:inc_counter += 1
122  assert_equal(2, g:inc_counter)
123
124  $SOME_ENV_VAR ..= 'more'
125  assert_equal('somemore', $SOME_ENV_VAR)
126  call CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1013:')
127  call CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1013:')
128
129  @a = 'areg'
130  @a ..= 'add'
131  assert_equal('aregadd', @a)
132  call CheckDefFailure(['@a += "more"'], 'E1013:')
133  call CheckDefFailure(['@a += 123'], 'E1013:')
134
135  v:errmsg = 'none'
136  v:errmsg ..= 'again'
137  assert_equal('noneagain', v:errmsg)
138  call CheckDefFailure(['v:errmsg += "more"'], 'E1013:')
139  call CheckDefFailure(['v:errmsg += 123'], 'E1013:')
140enddef
141
142def Test_assignment_local()
143  " Test in a separated file in order not to the current buffer/window/tab is
144  " changed.
145  let script_lines: list<string> =<< trim END
146    let b:existing = 'yes'
147    let w:existing = 'yes'
148    let t:existing = 'yes'
149
150    def Test_assignment_local_internal()
151      b:newvar = 'new'
152      assert_equal('new', b:newvar)
153      assert_equal('yes', b:existing)
154      b:existing = 'no'
155      assert_equal('no', b:existing)
156
157      w:newvar = 'new'
158      assert_equal('new', w:newvar)
159      assert_equal('yes', w:existing)
160      w:existing = 'no'
161      assert_equal('no', w:existing)
162
163      t:newvar = 'new'
164      assert_equal('new', t:newvar)
165      assert_equal('yes', t:existing)
166      t:existing = 'no'
167      assert_equal('no', t:existing)
168    enddef
169    call Test_assignment_local_internal()
170  END
171  call CheckScriptSuccess(script_lines)
172enddef
173
174def Test_assignment_default()
175
176  # Test default values.
177  let thebool: bool
178  assert_equal(v:false, thebool)
179
180  let thenumber: number
181  assert_equal(0, thenumber)
182
183  if has('float')
184    let thefloat: float
185    assert_equal(0.0, thefloat)
186  endif
187
188  let thestring: string
189  assert_equal('', thestring)
190
191  let theblob: blob
192  assert_equal(0z, theblob)
193
194  let Thefunc: func
195  assert_equal(test_null_function(), Thefunc)
196
197  let thelist: list<any>
198  assert_equal([], thelist)
199
200  let thedict: dict<any>
201  assert_equal({}, thedict)
202
203  if has('channel')
204    let thejob: job
205    assert_equal(test_null_job(), thejob)
206
207    let thechannel: channel
208    assert_equal(test_null_channel(), thechannel)
209  endif
210
211  let nr = 1234 | nr = 5678
212  assert_equal(5678, nr)
213enddef
214
215def Mess(): string
216  v:foldstart = 123
217  return 'xxx'
218enddef
219
220def Test_assignment_failure()
221  call CheckDefFailure(['let var=234'], 'E1004:')
222  call CheckDefFailure(['let var =234'], 'E1004:')
223  call CheckDefFailure(['let var= 234'], 'E1004:')
224
225  call CheckDefFailure(['let true = 1'], 'E1034:')
226  call CheckDefFailure(['let false = 1'], 'E1034:')
227
228  call CheckDefFailure(['let [a; b; c] = g:list'], 'E452:')
229
230  call CheckDefFailure(['let somevar'], "E1022:")
231  call CheckDefFailure(['let &option'], 'E1052:')
232  call CheckDefFailure(['&g:option = 5'], 'E113:')
233
234  call CheckDefFailure(['let $VAR = 5'], 'E1065:')
235
236  call CheckDefFailure(['let @~ = 5'], 'E354:')
237  call CheckDefFailure(['let @a = 5'], 'E1066:')
238
239  call CheckDefFailure(['let g:var = 5'], 'E1016:')
240  call CheckDefFailure(['let w:var = 5'], 'E1079:')
241  call CheckDefFailure(['let b:var = 5'], 'E1078:')
242  call CheckDefFailure(['let t:var = 5'], 'E1080:')
243
244  call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:')
245  call CheckDefFailure(['let xnr += 4'], 'E1020:')
246
247  call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef'], 'E1050:')
248
249  call CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>')
250  call CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>')
251
252  call CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>')
253  call CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>')
254
255  call CheckDefFailure(['let var = feedkeys("0")'], 'E1031:')
256  call CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void')
257
258  call CheckDefFailure(['let var: dict <number>'], 'E1068:')
259  call CheckDefFailure(['let var: dict<number'], 'E1009:')
260
261  call assert_fails('s/^/\=Mess()/n', 'E794:')
262  call CheckDefFailure(['let var: dict<number'], 'E1009:')
263enddef
264
265def Test_unlet()
266  g:somevar = 'yes'
267  assert_true(exists('g:somevar'))
268  unlet g:somevar
269  assert_false(exists('g:somevar'))
270  unlet! g:somevar
271
272  call CheckScriptFailure([
273        'vim9script',
274        'let svar = 123',
275        'unlet svar',
276        ], 'E1081:')
277  call CheckScriptFailure([
278        'vim9script',
279        'let svar = 123',
280        'unlet s:svar',
281        ], 'E1081:')
282  call CheckScriptFailure([
283        'vim9script',
284        'let svar = 123',
285        'def Func()',
286        '  unlet svar',
287        'enddef',
288        ], 'E1081:')
289  call CheckScriptFailure([
290        'vim9script',
291        'let svar = 123',
292        'def Func()',
293        '  unlet s:svar',
294        'enddef',
295        ], 'E1081:')
296
297  $ENVVAR = 'foobar'
298  assert_equal('foobar', $ENVVAR)
299  unlet $ENVVAR
300  assert_equal('', $ENVVAR)
301enddef
302
303func Test_wrong_type()
304  call CheckDefFailure(['let var: list<nothing>'], 'E1010:')
305  call CheckDefFailure(['let var: list<list<nothing>>'], 'E1010:')
306  call CheckDefFailure(['let var: dict<nothing>'], 'E1010:')
307  call CheckDefFailure(['let var: dict<dict<nothing>>'], 'E1010:')
308
309  call CheckDefFailure(['let var: dict<number'], 'E1009:')
310  call CheckDefFailure(['let var: dict<list<number>'], 'E1009:')
311
312  call CheckDefFailure(['let var: ally'], 'E1010:')
313  call CheckDefFailure(['let var: bram'], 'E1010:')
314  call CheckDefFailure(['let var: cathy'], 'E1010:')
315  call CheckDefFailure(['let var: dom'], 'E1010:')
316  call CheckDefFailure(['let var: freddy'], 'E1010:')
317  call CheckDefFailure(['let var: john'], 'E1010:')
318  call CheckDefFailure(['let var: larry'], 'E1010:')
319  call CheckDefFailure(['let var: ned'], 'E1010:')
320  call CheckDefFailure(['let var: pam'], 'E1010:')
321  call CheckDefFailure(['let var: sam'], 'E1010:')
322  call CheckDefFailure(['let var: vim'], 'E1010:')
323endfunc
324
325func Test_const()
326  call CheckDefFailure(['const var = 234', 'var = 99'], 'E1018:')
327  call CheckDefFailure(['const one = 234', 'let one = 99'], 'E1017:')
328  call CheckDefFailure(['const two'], 'E1021:')
329  call CheckDefFailure(['const &option'], 'E996:')
330endfunc
331
332def Test_block()
333  let outer = 1
334  {
335    let inner = 2
336    assert_equal(1, outer)
337    assert_equal(2, inner)
338  }
339  assert_equal(1, outer)
340enddef
341
342func Test_block_failure()
343  call CheckDefFailure(['{', 'let inner = 1', '}', 'echo inner'], 'E1001:')
344  call CheckDefFailure(['}'], 'E1025:')
345  call CheckDefFailure(['{', 'echo 1'], 'E1026:')
346endfunc
347
348def Test_cmd_modifier()
349  tab echo '0'
350  call CheckDefFailure(['5tab echo 3'], 'E16:')
351enddef
352
353def Test_try_catch()
354  let l = []
355  try # comment
356    add(l, '1')
357    throw 'wrong'
358    add(l, '2')
359  catch # comment
360    add(l, v:exception)
361  finally # comment
362    add(l, '3')
363  endtry # comment
364  assert_equal(['1', 'wrong', '3'], l)
365enddef
366
367def ThrowFromDef()
368  throw "getout" # comment
369enddef
370
371func CatchInFunc()
372  try
373    call ThrowFromDef()
374  catch
375    let g:thrown_func = v:exception
376  endtry
377endfunc
378
379def CatchInDef()
380  try
381    ThrowFromDef()
382  catch
383    g:thrown_def = v:exception
384  endtry
385enddef
386
387def ReturnFinally(): string
388  try
389    return 'intry'
390  finally
391    g:in_finally = 'finally'
392  endtry
393  return 'end'
394enddef
395
396def Test_try_catch_nested()
397  CatchInFunc()
398  assert_equal('getout', g:thrown_func)
399
400  CatchInDef()
401  assert_equal('getout', g:thrown_def)
402
403  assert_equal('intry', ReturnFinally())
404  assert_equal('finally', g:in_finally)
405enddef
406
407def Test_try_catch_match()
408  let seq = 'a'
409  try
410    throw 'something'
411  catch /nothing/
412    seq ..= 'x'
413  catch /some/
414    seq ..= 'b'
415  catch /asdf/
416    seq ..= 'x'
417  catch ?a\?sdf?
418    seq ..= 'y'
419  finally
420    seq ..= 'c'
421  endtry
422  assert_equal('abc', seq)
423enddef
424
425def Test_try_catch_fails()
426  call CheckDefFailure(['catch'], 'E603:')
427  call CheckDefFailure(['try', 'echo 0', 'catch','catch'], 'E1033:')
428  call CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:')
429  call CheckDefFailure(['finally'], 'E606:')
430  call CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:')
431  call CheckDefFailure(['endtry'], 'E602:')
432  call CheckDefFailure(['while 1', 'endtry'], 'E170:')
433  call CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:')
434  call CheckDefFailure(['if 2', 'endtry'], 'E171:')
435  call CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:')
436
437  call CheckDefFailure(['throw'], 'E1015:')
438  call CheckDefFailure(['throw xxx'], 'E1001:')
439enddef
440
441let s:export_script_lines =<< trim END
442  vim9script
443  let name: string = 'bob'
444  def Concat(arg: string): string
445    return name .. arg
446  enddef
447  let g:result = Concat('bie')
448  let g:localname = name
449
450  export const CONST = 1234
451  export let exported = 9876
452  export let exp_name = 'John'
453  export def Exported(): string
454    return 'Exported'
455  enddef
456END
457
458def Test_vim9_import_export()
459  let import_script_lines =<< trim END
460    vim9script
461    import {exported, Exported} from './Xexport.vim'
462    g:imported = exported
463    exported += 3
464    g:imported_added = exported
465    g:imported_func = Exported()
466
467    import {exp_name} from './Xexport.vim'
468    g:imported_name = exp_name
469    exp_name ..= ' Doe'
470    g:imported_name_appended = exp_name
471    g:imported_later = exported
472  END
473
474  writefile(import_script_lines, 'Ximport.vim')
475  writefile(s:export_script_lines, 'Xexport.vim')
476
477  source Ximport.vim
478
479  assert_equal('bobbie', g:result)
480  assert_equal('bob', g:localname)
481  assert_equal(9876, g:imported)
482  assert_equal(9879, g:imported_added)
483  assert_equal(9879, g:imported_later)
484  assert_equal('Exported', g:imported_func)
485  assert_equal('John', g:imported_name)
486  assert_equal('John Doe', g:imported_name_appended)
487  assert_false(exists('g:name'))
488
489  unlet g:result
490  unlet g:localname
491  unlet g:imported
492  unlet g:imported_added
493  unlet g:imported_later
494  unlet g:imported_func
495  unlet g:imported_name g:imported_name_appended
496  delete('Ximport.vim')
497
498  let import_in_def_lines =<< trim END
499    vim9script
500    def ImportInDef()
501      import exported from './Xexport.vim'
502      g:imported = exported
503      exported += 7
504      g:imported_added = exported
505    enddef
506    ImportInDef()
507  END
508  writefile(import_in_def_lines, 'Ximport2.vim')
509  source Ximport2.vim
510  " TODO: this should be 9879
511  assert_equal(9876, g:imported)
512  assert_equal(9883, g:imported_added)
513  unlet g:imported
514  unlet g:imported_added
515  delete('Ximport2.vim')
516
517  let import_star_as_lines =<< trim END
518    vim9script
519    import * as Export from './Xexport.vim'
520    def UseExport()
521      g:imported = Export.exported
522    enddef
523    UseExport()
524  END
525  writefile(import_star_as_lines, 'Ximport.vim')
526  source Ximport.vim
527  assert_equal(9883, g:imported)
528
529  let import_star_as_lines_no_dot =<< trim END
530    vim9script
531    import * as Export from './Xexport.vim'
532    def Func()
533      let dummy = 1
534      let imported = Export + dummy
535    enddef
536  END
537  writefile(import_star_as_lines_no_dot, 'Ximport.vim')
538  assert_fails('source Ximport.vim', 'E1060:')
539
540  let import_star_as_lines_dot_space =<< trim END
541    vim9script
542    import * as Export from './Xexport.vim'
543    def Func()
544      let imported = Export . exported
545    enddef
546  END
547  writefile(import_star_as_lines_dot_space, 'Ximport.vim')
548  assert_fails('source Ximport.vim', 'E1074:')
549
550  let import_star_as_lines_missing_name =<< trim END
551    vim9script
552    import * as Export from './Xexport.vim'
553    def Func()
554      let imported = Export.
555    enddef
556  END
557  writefile(import_star_as_lines_missing_name, 'Ximport.vim')
558  assert_fails('source Ximport.vim', 'E1048:')
559
560  let import_star_lines =<< trim END
561    vim9script
562    import * from './Xexport.vim'
563    g:imported = exported
564  END
565  writefile(import_star_lines, 'Ximport.vim')
566  assert_fails('source Ximport.vim', 'E1045:')
567
568  " try to import something that exists but is not exported
569  let import_not_exported_lines =<< trim END
570    vim9script
571    import name from './Xexport.vim'
572  END
573  writefile(import_not_exported_lines, 'Ximport.vim')
574  assert_fails('source Ximport.vim', 'E1049:')
575
576  " try to import something that is already defined
577  let import_already_defined =<< trim END
578    vim9script
579    let exported = 'something'
580    import exported from './Xexport.vim'
581  END
582  writefile(import_already_defined, 'Ximport.vim')
583  assert_fails('source Ximport.vim', 'E1073:')
584
585  " try to import something that is already defined
586  import_already_defined =<< trim END
587    vim9script
588    let exported = 'something'
589    import * as exported from './Xexport.vim'
590  END
591  writefile(import_already_defined, 'Ximport.vim')
592  assert_fails('source Ximport.vim', 'E1073:')
593
594  " try to import something that is already defined
595  import_already_defined =<< trim END
596    vim9script
597    let exported = 'something'
598    import {exported} from './Xexport.vim'
599  END
600  writefile(import_already_defined, 'Ximport.vim')
601  assert_fails('source Ximport.vim', 'E1073:')
602
603  " import a very long name, requires making a copy
604  let import_long_name_lines =<< trim END
605    vim9script
606    import name012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 from './Xexport.vim'
607  END
608  writefile(import_long_name_lines, 'Ximport.vim')
609  assert_fails('source Ximport.vim', 'E1048:')
610
611  let import_no_from_lines =<< trim END
612    vim9script
613    import name './Xexport.vim'
614  END
615  writefile(import_no_from_lines, 'Ximport.vim')
616  assert_fails('source Ximport.vim', 'E1070:')
617
618  let import_invalid_string_lines =<< trim END
619    vim9script
620    import name from Xexport.vim
621  END
622  writefile(import_invalid_string_lines, 'Ximport.vim')
623  assert_fails('source Ximport.vim', 'E1071:')
624
625  let import_wrong_name_lines =<< trim END
626    vim9script
627    import name from './XnoExport.vim'
628  END
629  writefile(import_wrong_name_lines, 'Ximport.vim')
630  assert_fails('source Ximport.vim', 'E1053:')
631
632  let import_missing_comma_lines =<< trim END
633    vim9script
634    import {exported name} from './Xexport.vim'
635  END
636  writefile(import_missing_comma_lines, 'Ximport3.vim')
637  assert_fails('source Ximport3.vim', 'E1046:')
638
639  delete('Ximport.vim')
640  delete('Ximport3.vim')
641  delete('Xexport.vim')
642
643  " Check that in a Vim9 script 'cpo' is set to the Vim default.
644  set cpo&vi
645  let cpo_before = &cpo
646  let lines =<< trim END
647    vim9script
648    g:cpo_in_vim9script = &cpo
649  END
650  writefile(lines, 'Xvim9_script')
651  source Xvim9_script
652  assert_equal(cpo_before, &cpo)
653  set cpo&vim
654  assert_equal(&cpo, g:cpo_in_vim9script)
655  delete('Xvim9_script')
656enddef
657
658def Test_vim9script_fails()
659  CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:')
660  CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:')
661  CheckScriptFailure(['export let some = 123'], 'E1042:')
662  CheckScriptFailure(['import some from "./Xexport.vim"'], 'E1042:')
663  CheckScriptFailure(['vim9script', 'export let g:some'], 'E1044:')
664  CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:')
665
666  assert_fails('vim9script', 'E1038')
667  assert_fails('export something', 'E1043')
668enddef
669
670def Test_vim9script_reload()
671  let lines =<< trim END
672    vim9script
673    const var = ''
674    let valone = 1234
675    def MyFunc(arg: string)
676       valone = 5678
677    enddef
678  END
679  let morelines =<< trim END
680    let valtwo = 222
681    export def GetValtwo(): number
682      return valtwo
683    enddef
684  END
685  writefile(lines + morelines,
686            'Xreload.vim')
687  source Xreload.vim
688  source Xreload.vim
689  source Xreload.vim
690
691  let testlines =<< trim END
692    vim9script
693    def TheFunc()
694      import GetValtwo from './Xreload.vim'
695      assert_equal(222, GetValtwo())
696    enddef
697    TheFunc()
698  END
699  writefile(testlines, 'Ximport.vim')
700  source Ximport.vim
701
702  " test that when not using "morelines" valtwo is still defined
703  " need to source Xreload.vim again, import doesn't reload a script
704  writefile(lines, 'Xreload.vim')
705  source Xreload.vim
706  source Ximport.vim
707
708  " cannot declare a var twice
709  lines =<< trim END
710    vim9script
711    let valone = 1234
712    let valone = 5678
713  END
714  writefile(lines, 'Xreload.vim')
715  assert_fails('source Xreload.vim', 'E1041:')
716
717  delete('Xreload.vim')
718  delete('Ximport.vim')
719enddef
720
721def Test_import_absolute()
722  let import_lines = [
723        'vim9script',
724        'import exported from "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim"',
725        'def UseExported()',
726        '  g:imported_abs = exported',
727        '  exported = 8888',
728        '  g:imported_after = exported',
729        'enddef',
730        'UseExported()',
731        'g:import_disassembled = execute("disass UseExported")',
732        ]
733  writefile(import_lines, 'Ximport_abs.vim')
734  writefile(s:export_script_lines, 'Xexport_abs.vim')
735
736  source Ximport_abs.vim
737
738  assert_equal(9876, g:imported_abs)
739  assert_equal(8888, g:imported_after)
740  assert_match('<SNR>\d\+_UseExported.*' ..
741          'g:imported_abs = exported.*' ..
742          '0 LOADSCRIPT exported from .*Xexport_abs.vim.*' ..
743          '1 STOREG g:imported_abs.*' ..
744          'exported = 8888.*' ..
745          '3 STORESCRIPT exported in .*Xexport_abs.vim.*' ..
746          'g:imported_after = exported.*' ..
747          '4 LOADSCRIPT exported from .*Xexport_abs.vim.*' ..
748          '5 STOREG g:imported_after.*',
749        g:import_disassembled)
750  unlet g:imported_abs
751  unlet g:import_disassembled
752
753  delete('Ximport_abs.vim')
754  delete('Xexport_abs.vim')
755enddef
756
757def Test_import_rtp()
758  let import_lines = [
759        'vim9script',
760        'import exported from "Xexport_rtp.vim"',
761        'g:imported_rtp = exported',
762        ]
763  writefile(import_lines, 'Ximport_rtp.vim')
764  mkdir('import')
765  writefile(s:export_script_lines, 'import/Xexport_rtp.vim')
766
767  let save_rtp = &rtp
768  &rtp = getcwd()
769  source Ximport_rtp.vim
770  &rtp = save_rtp
771
772  assert_equal(9876, g:imported_rtp)
773  unlet g:imported_rtp
774
775  delete('Ximport_rtp.vim')
776  delete('import/Xexport_rtp.vim')
777  delete('import', 'd')
778enddef
779
780def Test_fixed_size_list()
781  " will be allocated as one piece of memory, check that changes work
782  let l = [1, 2, 3, 4]
783  l->remove(0)
784  l->add(5)
785  l->insert(99, 1)
786  assert_equal([2, 99, 3, 4, 5], l)
787enddef
788
789def IfElse(what: number): string
790  let res = ''
791  if what == 1
792    res = "one"
793  elseif what == 2
794    res = "two"
795  else
796    res = "three"
797  endif
798  return res
799enddef
800
801def Test_if_elseif_else()
802  assert_equal('one', IfElse(1))
803  assert_equal('two', IfElse(2))
804  assert_equal('three', IfElse(3))
805enddef
806
807def Test_if_elseif_else_fails()
808  call CheckDefFailure(['elseif true'], 'E582:')
809  call CheckDefFailure(['else'], 'E581:')
810  call CheckDefFailure(['endif'], 'E580:')
811  call CheckDefFailure(['if true', 'elseif xxx'], 'E1001:')
812  call CheckDefFailure(['if true', 'echo 1'], 'E171:')
813enddef
814
815let g:bool_true = v:true
816let g:bool_false = v:false
817
818def Test_if_const_expr()
819  let res = false
820  if true ? true : false
821    res = true
822  endif
823  assert_equal(true, res)
824
825  g:glob = 2
826  if false
827    execute('let g:glob = 3')
828  endif
829  assert_equal(2, g:glob)
830  if true
831    execute('let g:glob = 3')
832  endif
833  assert_equal(3, g:glob)
834
835  res = false
836  if g:bool_true ? true : false
837    res = true
838  endif
839  assert_equal(true, res)
840
841  res = false
842  if true ? g:bool_true : false
843    res = true
844  endif
845  assert_equal(true, res)
846
847  res = false
848  if true ? true : g:bool_false
849    res = true
850  endif
851  assert_equal(true, res)
852
853  res = false
854  if true ? false : true
855    res = true
856  endif
857  assert_equal(false, res)
858
859  res = false
860  if false ? false : true
861    res = true
862  endif
863  assert_equal(true, res)
864
865  res = false
866  if false ? true : false
867    res = true
868  endif
869  assert_equal(false, res)
870
871  res = false
872  if has('xyz') ? true : false
873    res = true
874  endif
875  assert_equal(false, res)
876
877  res = false
878  if true && true
879    res = true
880  endif
881  assert_equal(true, res)
882
883  res = false
884  if true && false
885    res = true
886  endif
887  assert_equal(false, res)
888
889  res = false
890  if g:bool_true && false
891    res = true
892  endif
893  assert_equal(false, res)
894
895  res = false
896  if true && g:bool_false
897    res = true
898  endif
899  assert_equal(false, res)
900
901  res = false
902  if false && false
903    res = true
904  endif
905  assert_equal(false, res)
906
907  res = false
908  if true || false
909    res = true
910  endif
911  assert_equal(true, res)
912
913  res = false
914  if g:bool_true || false
915    res = true
916  endif
917  assert_equal(true, res)
918
919  res = false
920  if true || g:bool_false
921    res = true
922  endif
923  assert_equal(true, res)
924
925  res = false
926  if false || false
927    res = true
928  endif
929  assert_equal(false, res)
930enddef
931
932def Test_if_const_expr_fails()
933  call CheckDefFailure(['if "aaa" == "bbb'], 'E114:')
934  call CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:')
935  call CheckDefFailure(["if has('aaa'"], 'E110:')
936  call CheckDefFailure(["if has('aaa') ? true false"], 'E109:')
937enddef
938
939def Test_execute_cmd()
940  new
941  setline(1, 'default')
942  execute 'call setline(1, "execute-string")'
943  assert_equal('execute-string', getline(1))
944
945  execute "call setline(1, 'execute-string')"
946  assert_equal('execute-string', getline(1))
947
948  let cmd1 = 'call setline(1,'
949  let cmd2 = '"execute-var")'
950  execute cmd1 cmd2 # comment
951  assert_equal('execute-var', getline(1))
952
953  execute cmd1 cmd2 '|call setline(1, "execute-var-string")'
954  assert_equal('execute-var-string', getline(1))
955
956  let cmd_first = 'call '
957  let cmd_last = 'setline(1, "execute-var-var")'
958  execute cmd_first .. cmd_last
959  assert_equal('execute-var-var', getline(1))
960  bwipe!
961
962  call CheckDefFailure(['execute xxx'], 'E1001:')
963  call CheckDefFailure(['execute "cmd"# comment'], 'E488:')
964enddef
965
966def Test_echo_cmd()
967  echo 'some' # comment
968  echon 'thing'
969  assert_match('^something$', Screenline(&lines))
970
971  echo "some" # comment
972  echon "thing"
973  assert_match('^something$', Screenline(&lines))
974
975  let str1 = 'some'
976  let str2 = 'more'
977  echo str1 str2
978  assert_match('^some more$', Screenline(&lines))
979
980  call CheckDefFailure(['echo "xxx"# comment'], 'E488:')
981enddef
982
983def Test_echomsg_cmd()
984  echomsg 'some' 'more' # comment
985  assert_match('^some more$', Screenline(&lines))
986  echo 'clear'
987  1messages
988  assert_match('^some more$', Screenline(&lines))
989
990  call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
991enddef
992
993def Test_echoerr_cmd()
994  # TODO: write this test
995enddef
996
997def Test_for_outside_of_function()
998  let lines =<< trim END
999    vim9script
1000    new
1001    for var in range(0, 3)
1002      append(line('$'), var)
1003    endfor
1004    assert_equal(['', '0', '1', '2', '3'], getline(1, '$'))
1005    bwipe!
1006  END
1007  writefile(lines, 'Xvim9for.vim')
1008  source Xvim9for.vim
1009  delete('Xvim9for.vim')
1010enddef
1011
1012def Test_for_loop()
1013  let result = ''
1014  for cnt in range(7)
1015    if cnt == 4
1016      break
1017    endif
1018    if cnt == 2
1019      continue
1020    endif
1021    result ..= cnt .. '_'
1022  endfor
1023  assert_equal('0_1_3_', result)
1024enddef
1025
1026def Test_for_loop_fails()
1027  CheckDefFailure(['for # in range(5)'], 'E690:')
1028  CheckDefFailure(['for i In range(5)'], 'E690:')
1029  CheckDefFailure(['let x = 5', 'for x in range(5)'], 'E1023:')
1030  CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef'], 'E1006:')
1031  CheckDefFailure(['for i in "text"'], 'E1024:')
1032  CheckDefFailure(['for i in xxx'], 'E1001:')
1033  CheckDefFailure(['endfor'], 'E588:')
1034  CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:')
1035enddef
1036
1037def Test_while_loop()
1038  let result = ''
1039  let cnt = 0
1040  while cnt < 555
1041    if cnt == 3
1042      break
1043    endif
1044    cnt += 1
1045    if cnt == 2
1046      continue
1047    endif
1048    result ..= cnt .. '_'
1049  endwhile
1050  assert_equal('1_3_', result)
1051enddef
1052
1053def Test_while_loop_fails()
1054  CheckDefFailure(['while xxx'], 'E1001:')
1055  CheckDefFailure(['endwhile'], 'E588:')
1056  CheckDefFailure(['continue'], 'E586:')
1057  CheckDefFailure(['if true', 'continue'], 'E586:')
1058  CheckDefFailure(['break'], 'E587:')
1059  CheckDefFailure(['if true', 'break'], 'E587:')
1060  CheckDefFailure(['while 1', 'echo 3'], 'E170:')
1061enddef
1062
1063def Test_interrupt_loop()
1064  let caught = false
1065  let x = 0
1066  try
1067    while 1
1068      x += 1
1069      if x == 100
1070        feedkeys("\<C-C>", 'Lt')
1071      endif
1072    endwhile
1073  catch
1074    caught = true
1075    assert_equal(100, x)
1076  endtry
1077  assert_true(caught, 'should have caught an exception')
1078enddef
1079
1080def Test_automatic_line_continuation()
1081  let mylist = [
1082      'one',
1083      'two',
1084      'three',
1085      ] " comment
1086  assert_equal(['one', 'two', 'three'], mylist)
1087
1088  let mydict = {
1089      'one': 1,
1090      'two': 2,
1091      'three':
1092          3,
1093      } " comment
1094  assert_equal({'one': 1, 'two': 2, 'three': 3}, mydict)
1095  mydict = #{
1096      one: 1,  # comment
1097      two:     # comment
1098           2,  # comment
1099      three: 3 # comment
1100      }
1101  assert_equal(#{one: 1, two: 2, three: 3}, mydict)
1102  mydict = #{
1103      one: 1,
1104      two:
1105           2,
1106      three: 3
1107      }
1108  assert_equal(#{one: 1, two: 2, three: 3}, mydict)
1109
1110  assert_equal(
1111        ['one', 'two', 'three'],
1112        split('one two three')
1113        )
1114enddef
1115
1116def Test_vim9_comment()
1117  CheckScriptSuccess([
1118      'vim9script',
1119      '# something',
1120      ])
1121  CheckScriptFailure([
1122      'vim9script',
1123      ':# something',
1124      ], 'E488:')
1125  CheckScriptFailure([
1126      '# something',
1127      ], 'E488:')
1128  CheckScriptFailure([
1129      ':# something',
1130      ], 'E488:')
1131
1132  { # block start
1133  } # block end
1134  CheckDefFailure([
1135      '{# comment',
1136      ], 'E488:')
1137  CheckDefFailure([
1138      '{',
1139      '}# comment',
1140      ], 'E488:')
1141
1142  echo "yes" # comment
1143  CheckDefFailure([
1144      'echo "yes"# comment',
1145      ], 'E488:')
1146  CheckScriptSuccess([
1147      'vim9script',
1148      'echo "yes" # something',
1149      ])
1150  CheckScriptFailure([
1151      'vim9script',
1152      'echo "yes"# something',
1153      ], 'E121:')
1154  CheckScriptFailure([
1155      'vim9script',
1156      'echo# something',
1157      ], 'E121:')
1158  CheckScriptFailure([
1159      'echo "yes" # something',
1160      ], 'E121:')
1161
1162  exe "echo" # comment
1163  CheckDefFailure([
1164      'exe "echo"# comment',
1165      ], 'E488:')
1166  CheckScriptSuccess([
1167      'vim9script',
1168      'exe "echo" # something',
1169      ])
1170  CheckScriptFailure([
1171      'vim9script',
1172      'exe "echo"# something',
1173      ], 'E121:')
1174  CheckDefFailure([
1175      'exe # comment',
1176      ], 'E1015:')
1177  CheckScriptFailure([
1178      'vim9script',
1179      'exe# something',
1180      ], 'E121:')
1181  CheckScriptFailure([
1182      'exe "echo" # something',
1183      ], 'E121:')
1184
1185  CheckDefFailure([
1186      'try# comment',
1187      '  echo "yes"',
1188      'catch',
1189      'endtry',
1190      ], 'E488:')
1191  CheckScriptFailure([
1192      'vim9script',
1193      'try# comment',
1194      'echo "yes"',
1195      ], 'E488:')
1196  CheckDefFailure([
1197      'try',
1198      '  throw#comment',
1199      'catch',
1200      'endtry',
1201      ], 'E1015:')
1202  CheckDefFailure([
1203      'try',
1204      '  throw "yes"#comment',
1205      'catch',
1206      'endtry',
1207      ], 'E488:')
1208  CheckDefFailure([
1209      'try',
1210      '  echo "yes"',
1211      'catch# comment',
1212      'endtry',
1213      ], 'E488:')
1214  CheckScriptFailure([
1215      'vim9script',
1216      'try',
1217      '  echo "yes"',
1218      'catch# comment',
1219      'endtry',
1220      ], 'E654:')
1221  CheckDefFailure([
1222      'try',
1223      '  echo "yes"',
1224      'catch /pat/# comment',
1225      'endtry',
1226      ], 'E488:')
1227  CheckScriptFailure([
1228      'vim9script',
1229      'try',
1230      '  throw "pat"',
1231      'catch /pat/# comment',
1232      'endtry',
1233      ], 'E605:')
1234  CheckDefFailure([
1235      'try',
1236      'echo "yes"',
1237      'catch',
1238      'endtry# comment',
1239      ], 'E488:')
1240  CheckScriptFailure([
1241      'vim9script',
1242      'try',
1243      '  echo "yes"',
1244      'catch',
1245      'endtry# comment',
1246      ], 'E600:')
1247
1248  CheckScriptSuccess([
1249      'vim9script',
1250      'hi # comment',
1251      ])
1252  CheckScriptFailure([
1253      'vim9script',
1254      'hi# comment',
1255      ], 'E416:')
1256  CheckScriptSuccess([
1257      'vim9script',
1258      'hi Search # comment',
1259      ])
1260  CheckScriptFailure([
1261      'vim9script',
1262      'hi Search# comment',
1263      ], 'E416:')
1264  CheckScriptSuccess([
1265      'vim9script',
1266      'hi link This Search # comment',
1267      ])
1268  CheckScriptFailure([
1269      'vim9script',
1270      'hi link This That# comment',
1271      ], 'E413:')
1272  CheckScriptSuccess([
1273      'vim9script',
1274      'hi clear This # comment',
1275      'hi clear # comment',
1276      ])
1277  " not tested, because it doesn't give an error but a warning:
1278  " hi clear This# comment',
1279  CheckScriptFailure([
1280      'vim9script',
1281      'hi clear# comment',
1282      ], 'E416:')
1283
1284  CheckScriptSuccess([
1285      'vim9script',
1286      'hi Group term=bold',
1287      'match Group /todo/ # comment',
1288      ])
1289  CheckScriptFailure([
1290      'vim9script',
1291      'hi Group term=bold',
1292      'match Group /todo/# comment',
1293      ], 'E488:')
1294  CheckScriptSuccess([
1295      'vim9script',
1296      'match # comment',
1297      ])
1298  CheckScriptFailure([
1299      'vim9script',
1300      'match# comment',
1301      ], 'E475:')
1302  CheckScriptSuccess([
1303      'vim9script',
1304      'match none # comment',
1305      ])
1306  CheckScriptFailure([
1307      'vim9script',
1308      'match none# comment',
1309      ], 'E475:')
1310
1311  CheckScriptSuccess([
1312      'vim9script',
1313      'menutrans clear # comment',
1314      ])
1315  CheckScriptFailure([
1316      'vim9script',
1317      'menutrans clear# comment text',
1318      ], 'E474:')
1319
1320  CheckScriptSuccess([
1321      'vim9script',
1322      'syntax clear # comment',
1323      ])
1324  CheckScriptFailure([
1325      'vim9script',
1326      'syntax clear# comment text',
1327      ], 'E28:')
1328  CheckScriptSuccess([
1329      'vim9script',
1330      'syntax keyword Word some',
1331      'syntax clear Word # comment',
1332      ])
1333  CheckScriptFailure([
1334      'vim9script',
1335      'syntax keyword Word some',
1336      'syntax clear Word# comment text',
1337      ], 'E28:')
1338
1339  CheckScriptSuccess([
1340      'vim9script',
1341      'syntax list # comment',
1342      ])
1343  CheckScriptFailure([
1344      'vim9script',
1345      'syntax list# comment text',
1346      ], 'E28:')
1347
1348  CheckScriptSuccess([
1349      'vim9script',
1350      'syntax match Word /pat/ oneline # comment',
1351      ])
1352  CheckScriptFailure([
1353      'vim9script',
1354      'syntax match Word /pat/ oneline# comment',
1355      ], 'E475:')
1356
1357  CheckScriptSuccess([
1358      'vim9script',
1359      'syntax keyword Word word # comm[ent',
1360      ])
1361  CheckScriptFailure([
1362      'vim9script',
1363      'syntax keyword Word word# comm[ent',
1364      ], 'E789:')
1365
1366  CheckScriptSuccess([
1367      'vim9script',
1368      'syntax match Word /pat/ # comment',
1369      ])
1370  CheckScriptFailure([
1371      'vim9script',
1372      'syntax match Word /pat/# comment',
1373      ], 'E402:')
1374
1375  CheckScriptSuccess([
1376      'vim9script',
1377      'syntax match Word /pat/ contains=Something # comment',
1378      ])
1379  CheckScriptFailure([
1380      'vim9script',
1381      'syntax match Word /pat/ contains=Something# comment',
1382      ], 'E475:')
1383  CheckScriptFailure([
1384      'vim9script',
1385      'syntax match Word /pat/ contains= # comment',
1386      ], 'E406:')
1387  CheckScriptFailure([
1388      'vim9script',
1389      'syntax match Word /pat/ contains=# comment',
1390      ], 'E475:')
1391
1392  CheckScriptSuccess([
1393      'vim9script',
1394      'syntax region Word start=/pat/ end=/pat/ # comment',
1395      ])
1396  CheckScriptFailure([
1397      'vim9script',
1398      'syntax region Word start=/pat/ end=/pat/# comment',
1399      ], 'E475:')
1400
1401  CheckScriptSuccess([
1402      'vim9script',
1403      'syntax sync # comment',
1404      ])
1405  CheckScriptFailure([
1406      'vim9script',
1407      'syntax sync# comment',
1408      ], 'E404:')
1409  CheckScriptSuccess([
1410      'vim9script',
1411      'syntax sync ccomment # comment',
1412      ])
1413  CheckScriptFailure([
1414      'vim9script',
1415      'syntax sync ccomment# comment',
1416      ], 'E404:')
1417
1418  CheckScriptSuccess([
1419      'vim9script',
1420      'syntax cluster Some contains=Word # comment',
1421      ])
1422  CheckScriptFailure([
1423      'vim9script',
1424      'syntax cluster Some contains=Word# comment',
1425      ], 'E475:')
1426
1427  CheckScriptSuccess([
1428      'vim9script',
1429      'command Echo echo # comment',
1430      'command Echo # comment',
1431      ])
1432  CheckScriptFailure([
1433      'vim9script',
1434      'command Echo echo# comment',
1435      'Echo',
1436      ], 'E121:')
1437  CheckScriptFailure([
1438      'vim9script',
1439      'command Echo# comment',
1440      ], 'E182:')
1441  CheckScriptFailure([
1442      'vim9script',
1443      'command Echo echo',
1444      'command Echo# comment',
1445      ], 'E182:')
1446
1447  CheckScriptSuccess([
1448      'vim9script',
1449      'function # comment',
1450      ])
1451  CheckScriptFailure([
1452      'vim9script',
1453      'function# comment',
1454      ], 'E129:')
1455  CheckScriptSuccess([
1456      'vim9script',
1457      'function CheckScriptSuccess # comment',
1458      ])
1459  CheckScriptFailure([
1460      'vim9script',
1461      'function CheckScriptSuccess# comment',
1462      ], 'E488:')
1463
1464  CheckScriptSuccess([
1465      'vim9script',
1466      'func DeleteMe()',
1467      'endfunc',
1468      'delfunction DeleteMe # comment',
1469      ])
1470  CheckScriptFailure([
1471      'vim9script',
1472      'func DeleteMe()',
1473      'endfunc',
1474      'delfunction DeleteMe# comment',
1475      ], 'E488:')
1476
1477  CheckScriptSuccess([
1478      'vim9script',
1479      'call execute("ls") # comment',
1480      ])
1481  CheckScriptFailure([
1482      'vim9script',
1483      'call execute("ls")# comment',
1484      ], 'E488:')
1485enddef
1486
1487def Test_vim9_comment_gui()
1488  CheckCanRunGui
1489
1490  CheckScriptFailure([
1491      'vim9script',
1492      'gui#comment'
1493      ], 'E499:')
1494  CheckScriptFailure([
1495      'vim9script',
1496      'gui -f#comment'
1497      ], 'E499:')
1498enddef
1499
1500def Test_vim9_comment_not_compiled()
1501  au TabEnter *.vim let g:entered = 1
1502  au TabEnter *.x let g:entered = 2
1503
1504  edit test.vim
1505  doautocmd TabEnter #comment
1506  assert_equal(1, g:entered)
1507
1508  doautocmd TabEnter f.x
1509  assert_equal(2, g:entered)
1510
1511  g:entered = 0
1512  doautocmd TabEnter f.x #comment
1513  assert_equal(2, g:entered)
1514
1515  assert_fails('doautocmd Syntax#comment', 'E216:')
1516
1517  au! TabEnter
1518  unlet g:entered
1519
1520  CheckScriptSuccess([
1521      'vim9script',
1522      'let g:var = 123',
1523      'let w:var = 777',
1524      'unlet g:var w:var # something',
1525      ])
1526
1527  CheckScriptFailure([
1528      'vim9script',
1529      'let g:var = 123',
1530      'unlet g:var# comment',
1531      ], 'E108:')
1532
1533  CheckScriptFailure([
1534      'let g:var = 123',
1535      'unlet g:var # something',
1536      ], 'E488:')
1537
1538  CheckScriptSuccess([
1539      'vim9script',
1540      'if 1 # comment',
1541      '  echo "yes"',
1542      'elseif 2 #comment',
1543      '  echo "no"',
1544      'endif',
1545      ])
1546
1547  CheckScriptFailure([
1548      'vim9script',
1549      'if 1# comment',
1550      '  echo "yes"',
1551      'endif',
1552      ], 'E15:')
1553
1554  CheckScriptFailure([
1555      'vim9script',
1556      'if 0 # comment',
1557      '  echo "yes"',
1558      'elseif 2#comment',
1559      '  echo "no"',
1560      'endif',
1561      ], 'E15:')
1562
1563  CheckScriptSuccess([
1564      'vim9script',
1565      'let # comment',
1566      ])
1567
1568  CheckScriptFailure([
1569      'vim9script',
1570      'let# comment',
1571      ], 'E121:')
1572
1573  CheckScriptSuccess([
1574      'vim9script',
1575      'let v:version # comment',
1576      ])
1577
1578  CheckScriptFailure([
1579      'vim9script',
1580      'let v:version# comment',
1581      ], 'E121:')
1582
1583  CheckScriptSuccess([
1584      'vim9script',
1585      'new'
1586      'call setline(1, ["# define pat", "last"])',
1587      '$',
1588      'dsearch /pat/ #comment',
1589      'bwipe!',
1590      ])
1591
1592  CheckScriptFailure([
1593      'vim9script',
1594      'new'
1595      'call setline(1, ["# define pat", "last"])',
1596      '$',
1597      'dsearch /pat/#comment',
1598      'bwipe!',
1599      ], 'E488:')
1600enddef
1601
1602" Keep this last, it messes up highlighting.
1603def Test_substitute_cmd()
1604  new
1605  setline(1, 'something')
1606  :substitute(some(other(
1607  assert_equal('otherthing', getline(1))
1608  bwipe!
1609
1610  " also when the context is Vim9 script
1611  let lines =<< trim END
1612    vim9script
1613    new
1614    setline(1, 'something')
1615    :substitute(some(other(
1616    assert_equal('otherthing', getline(1))
1617    bwipe!
1618  END
1619  writefile(lines, 'Xvim9lines')
1620  source Xvim9lines
1621
1622  delete('Xvim9lines')
1623enddef
1624
1625" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
1626