1" Test commands that are not compiled in a :def function
2
3source check.vim
4source vim9.vim
5source term_util.vim
6source view_util.vim
7
8def Test_edit_wildcards()
9  var filename = 'Xtest'
10  edit `=filename`
11  assert_equal('Xtest', bufname())
12
13  var filenr = 123
14  edit Xtest`=filenr`
15  assert_equal('Xtest123', bufname())
16
17  filenr = 77
18  edit `=filename``=filenr`
19  assert_equal('Xtest77', bufname())
20
21  edit X`=filename`xx`=filenr`yy
22  assert_equal('XXtestxx77yy', bufname())
23
24  CheckDefFailure(['edit `=xxx`'], 'E1001:')
25  CheckDefFailure(['edit `="foo"'], 'E1083:')
26enddef
27
28def Test_expand_alternate_file()
29  var lines =<< trim END
30    edit Xfileone
31    var bone = bufnr()
32    edit Xfiletwo
33    var btwo = bufnr()
34    edit Xfilethree
35    var bthree = bufnr()
36
37    edit #
38    assert_equal(bthree, bufnr())
39    edit %%
40    assert_equal(btwo, bufnr())
41    edit %% # comment
42    assert_equal(bthree, bufnr())
43    edit %%yy
44    assert_equal('Xfiletwoyy', bufname())
45
46    exe "edit %%" .. bone
47    assert_equal(bone, bufnr())
48    exe "edit %%" .. btwo .. "xx"
49    assert_equal('Xfiletwoxx', bufname())
50
51    next Xfileone Xfiletwo Xfilethree
52    assert_equal('Xfileone', argv(0))
53    assert_equal('Xfiletwo', argv(1))
54    assert_equal('Xfilethree', argv(2))
55    next %%%zz
56    assert_equal('Xfileone', argv(0))
57    assert_equal('Xfiletwo', argv(1))
58    assert_equal('Xfilethreezz', argv(2))
59
60    v:oldfiles = ['Xonefile', 'Xtwofile']
61    edit %%<1
62    assert_equal('Xonefile', bufname())
63    edit %%<2
64    assert_equal('Xtwofile', bufname())
65    assert_fails('edit %%<3', 'E684:')
66
67    edit Xfileone.vim
68    edit Xfiletwo
69    edit %%:r
70    assert_equal('Xfileone', bufname())
71
72    assert_false(bufexists('altfoo'))
73    edit altfoo
74    edit bar
75    assert_true(bufexists('altfoo'))
76    assert_true(buflisted('altfoo'))
77    bdel %%
78    assert_true(bufexists('altfoo'))
79    assert_false(buflisted('altfoo'))
80    bwipe! altfoo
81    bwipe! bar
82  END
83  CheckDefAndScriptSuccess(lines)
84enddef
85
86def Test_global_backtick_expansion()
87  new
88  setline(1, 'xx')
89  var name = 'foobar'
90  g/^xx/s/.*/`=name`
91  assert_equal('foobar', getline(1))
92  bwipe!
93enddef
94
95def Test_folddo_backtick_expansion()
96  new
97  var name = 'xxx'
98  folddoopen edit `=name`
99  assert_equal('xxx', bufname())
100  bwipe!
101
102  new
103  setline(1, ['one', 'two'])
104  set nomodified
105  :1,2fold
106  foldclose
107  folddoclose edit `=name`
108  assert_equal('xxx', bufname())
109  bwipe!
110enddef
111
112def Test_hardcopy_wildcards()
113  CheckUnix
114  CheckFeature postscript
115
116  var outfile = 'print'
117  hardcopy > X`=outfile`.ps
118  assert_true(filereadable('Xprint.ps'))
119
120  delete('Xprint.ps')
121enddef
122
123def Test_syn_include_wildcards()
124  writefile(['syn keyword Found found'], 'Xthemine.vim')
125  var save_rtp = &rtp
126  &rtp = '.'
127
128  var fname = 'mine'
129  syn include @Group Xthe`=fname`.vim
130  assert_match('Found.* contained found', execute('syn list Found'))
131
132  &rtp = save_rtp
133  delete('Xthemine.vim')
134enddef
135
136def Test_echo_linebreak()
137  var lines =<< trim END
138      vim9script
139      redir @a
140      echo 'one'
141            .. 'two'
142      redir END
143      assert_equal("\nonetwo", @a)
144  END
145  CheckScriptSuccess(lines)
146
147  lines =<< trim END
148      vim9script
149      redir @a
150      echo 11 +
151            77
152            - 22
153      redir END
154      assert_equal("\n66", @a)
155  END
156  CheckScriptSuccess(lines)
157enddef
158
159def Test_condition_types()
160  var lines =<< trim END
161      if 'text'
162      endif
163  END
164  CheckDefAndScriptFailure(lines, 'E1135:', 1)
165
166  lines =<< trim END
167      if [1]
168      endif
169  END
170  CheckDefFailure(lines, 'E1012:', 1)
171  CheckScriptFailure(['vim9script'] + lines, 'E745:', 2)
172
173  lines =<< trim END
174      g:cond = 'text'
175      if g:cond
176      endif
177  END
178  CheckDefExecAndScriptFailure(lines, 'E1135:', 2)
179
180  lines =<< trim END
181      g:cond = 0
182      if g:cond
183      elseif 'text'
184      endif
185  END
186  CheckDefFailure(lines, 'E1012:', 3)
187  CheckScriptFailure(['vim9script'] + lines, 'E1135:', 4)
188
189  lines =<< trim END
190      if g:cond
191      elseif [1]
192      endif
193  END
194  CheckDefFailure(lines, 'E1012:', 2)
195  CheckScriptFailure(['vim9script'] + lines, 'E745:', 3)
196
197  lines =<< trim END
198      g:cond = 'text'
199      if 0
200      elseif g:cond
201      endif
202  END
203  CheckDefExecAndScriptFailure(lines, 'E1135:', 3)
204
205  lines =<< trim END
206      while 'text'
207      endwhile
208  END
209  CheckDefFailure(lines, 'E1012:', 1)
210  CheckScriptFailure(['vim9script'] + lines, 'E1135:', 2)
211
212  lines =<< trim END
213      while [1]
214      endwhile
215  END
216  CheckDefFailure(lines, 'E1012:', 1)
217  CheckScriptFailure(['vim9script'] + lines, 'E745:', 2)
218
219  lines =<< trim END
220      g:cond = 'text'
221      while g:cond
222      endwhile
223  END
224  CheckDefExecAndScriptFailure(lines, 'E1135:', 2)
225enddef
226
227def Test_if_linebreak()
228  var lines =<< trim END
229      vim9script
230      if 1 &&
231            true
232            || 1
233        g:res = 42
234      endif
235      assert_equal(42, g:res)
236  END
237  CheckScriptSuccess(lines)
238  unlet g:res
239
240  lines =<< trim END
241      vim9script
242      if 1 &&
243            0
244        g:res = 0
245      elseif 0 ||
246              0
247              || 1
248        g:res = 12
249      endif
250      assert_equal(12, g:res)
251  END
252  CheckScriptSuccess(lines)
253  unlet g:res
254enddef
255
256def Test_while_linebreak()
257  var lines =<< trim END
258      vim9script
259      var nr = 0
260      while nr <
261              10 + 3
262            nr = nr
263                  + 4
264      endwhile
265      assert_equal(16, nr)
266  END
267  CheckScriptSuccess(lines)
268
269  lines =<< trim END
270      vim9script
271      var nr = 0
272      while nr
273            <
274              10
275              +
276              3
277            nr = nr
278                  +
279                  4
280      endwhile
281      assert_equal(16, nr)
282  END
283  CheckScriptSuccess(lines)
284enddef
285
286def Test_for_linebreak()
287  var lines =<< trim END
288      vim9script
289      var nr = 0
290      for x
291            in
292              [1, 2, 3, 4]
293          nr = nr + x
294      endfor
295      assert_equal(10, nr)
296  END
297  CheckScriptSuccess(lines)
298
299  lines =<< trim END
300      vim9script
301      var nr = 0
302      for x
303            in
304              [1, 2,
305                  3, 4
306                  ]
307          nr = nr
308                 +
309                  x
310      endfor
311      assert_equal(10, nr)
312  END
313  CheckScriptSuccess(lines)
314enddef
315
316def Test_method_call_linebreak()
317  var lines =<< trim END
318      vim9script
319      var res = []
320      func RetArg(
321            arg
322            )
323            let s:res = a:arg
324      endfunc
325      [1,
326          2,
327          3]->RetArg()
328      assert_equal([1, 2, 3], res)
329  END
330  CheckScriptSuccess(lines)
331enddef
332
333def Test_method_call_whitespace()
334  var lines =<< trim END
335    new
336    var yank = 'text'
337    yank->setline(1)
338    yank  ->setline(2)
339    yank->  setline(3)
340    yank  ->  setline(4)
341    assert_equal(['text', 'text', 'text', 'text'], getline(1, 4))
342    bwipe!
343  END
344  CheckDefAndScriptSuccess(lines)
345enddef
346
347def Test_skipped_expr_linebreak()
348  if 0
349    var x = []
350               ->map(() => 0)
351  endif
352enddef
353
354def Test_dict_member()
355   var test: dict<list<number>> = {data: [3, 1, 2]}
356   test.data->sort()
357   assert_equal({data: [1, 2, 3]}, test)
358   test.data
359      ->reverse()
360   assert_equal({data: [3, 2, 1]}, test)
361
362  var lines =<< trim END
363      vim9script
364      var test: dict<list<number>> = {data: [3, 1, 2]}
365      test.data->sort()
366      assert_equal({data: [1, 2, 3]}, test)
367  END
368  CheckScriptSuccess(lines)
369enddef
370
371def Test_bar_after_command()
372  def RedrawAndEcho()
373    var x = 'did redraw'
374    redraw | echo x
375  enddef
376  RedrawAndEcho()
377  assert_match('did redraw', Screenline(&lines))
378
379  def CallAndEcho()
380    var x = 'did redraw'
381    reg_executing() | echo x
382  enddef
383  CallAndEcho()
384  assert_match('did redraw', Screenline(&lines))
385
386  if has('unix')
387    # bar in filter write command does not start new command
388    def WriteToShell()
389      new
390      setline(1, 'some text')
391      w !cat | cat > Xoutfile
392      bwipe!
393    enddef
394    WriteToShell()
395    assert_equal(['some text'], readfile('Xoutfile'))
396    delete('Xoutfile')
397
398    # bar in filter read command does not start new command
399    def ReadFromShell()
400      new
401      r! echo hello there | cat > Xoutfile
402      r !echo again | cat >> Xoutfile
403      bwipe!
404    enddef
405    ReadFromShell()
406    assert_equal(['hello there', 'again'], readfile('Xoutfile'))
407    delete('Xoutfile')
408  endif
409enddef
410
411def Test_filter_is_not_modifier()
412  var tags = [{a: 1, b: 2}, {x: 3, y: 4}]
413  filter(tags, ( _, v) => has_key(v, 'x') ? 1 : 0 )
414  assert_equal([{x: 3, y: 4}], tags)
415enddef
416
417def Test_command_modifier_filter()
418  var lines =<< trim END
419    final expected = "\nType Name Content\n  c  \"c   piyo"
420    @a = 'hoge'
421    @b = 'fuga'
422    @c = 'piyo'
423
424    assert_equal(execute('filter /piyo/ registers abc'), expected)
425  END
426  CheckDefAndScriptSuccess(lines)
427enddef
428
429def Test_win_command_modifiers()
430  assert_equal(1, winnr('$'))
431
432  set splitright
433  vsplit
434  assert_equal(2, winnr())
435  close
436  aboveleft vsplit
437  assert_equal(1, winnr())
438  close
439  set splitright&
440
441  vsplit
442  assert_equal(1, winnr())
443  close
444  belowright vsplit
445  assert_equal(2, winnr())
446  close
447  rightbelow vsplit
448  assert_equal(2, winnr())
449  close
450
451  if has('browse')
452    browse set
453    assert_equal('option-window', expand('%'))
454    close
455  endif
456
457  vsplit
458  botright split
459  assert_equal(3, winnr())
460  assert_equal(&columns, winwidth(0))
461  close
462  close
463
464  vsplit
465  topleft split
466  assert_equal(1, winnr())
467  assert_equal(&columns, winwidth(0))
468  close
469  close
470
471  gettabinfo()->len()->assert_equal(1)
472  tab split
473  gettabinfo()->len()->assert_equal(2)
474  tabclose
475
476  vertical new
477  assert_inrange(&columns / 2 - 2, &columns / 2 + 1, winwidth(0))
478  close
479enddef
480
481func Test_command_modifier_confirm()
482  CheckNotGui
483  CheckRunVimInTerminal
484
485  " Test for saving all the modified buffers
486  let lines =<< trim END
487    call setline(1, 'changed')
488    def Getout()
489      confirm write Xfile
490    enddef
491  END
492  call writefile(lines, 'Xconfirmscript')
493  call writefile(['empty'], 'Xfile')
494  let buf = RunVimInTerminal('-S Xconfirmscript', {'rows': 8})
495  call term_sendkeys(buf, ":call Getout()\n")
496  call WaitForAssert({-> assert_match('(Y)es, \[N\]o: ', term_getline(buf, 8))}, 1000)
497  call term_sendkeys(buf, "y")
498  call WaitForAssert({-> assert_match('(Y)es, \[N\]o: ', term_getline(buf, 8))}, 1000)
499  call term_sendkeys(buf, "\<CR>")
500  call TermWait(buf)
501  call StopVimInTerminal(buf)
502
503  call assert_equal(['changed'], readfile('Xfile'))
504  call delete('Xfile')
505  call delete('.Xfile.swp')  " in case Vim was killed
506  call delete('Xconfirmscript')
507endfunc
508
509def Test_command_modifiers_keep()
510  if has('unix')
511    def DoTest(addRflag: bool, keepMarks: bool, hasMarks: bool)
512      new
513      setline(1, ['one', 'two', 'three'])
514      normal 1Gma
515      normal 2Gmb
516      normal 3Gmc
517      if addRflag
518        set cpo+=R
519      else
520        set cpo-=R
521      endif
522      if keepMarks
523        keepmarks :%!cat
524      else
525        :%!cat
526      endif
527      if hasMarks
528        assert_equal(1, line("'a"))
529        assert_equal(2, line("'b"))
530        assert_equal(3, line("'c"))
531      else
532        assert_equal(0, line("'a"))
533        assert_equal(0, line("'b"))
534        assert_equal(0, line("'c"))
535      endif
536      quit!
537    enddef
538    DoTest(false, false, true)
539    DoTest(true, false, false)
540    DoTest(false, true, true)
541    DoTest(true, true, true)
542    set cpo&vim
543
544    new
545    setline(1, ['one', 'two', 'three', 'four'])
546    assert_equal(4, line("$"))
547    normal 1Gma
548    normal 2Gmb
549    normal 3Gmc
550    lockmarks :1,2!wc
551    # line is deleted, marks don't move
552    assert_equal(3, line("$"))
553    assert_equal('four', getline(3))
554    assert_equal(1, line("'a"))
555    assert_equal(2, line("'b"))
556    assert_equal(3, line("'c"))
557    quit!
558  endif
559
560  edit Xone
561  edit Xtwo
562  assert_equal('Xone', expand('#'))
563  keepalt edit Xthree
564  assert_equal('Xone', expand('#'))
565
566  normal /a*b*
567  assert_equal('a*b*', histget("search"))
568  keeppatterns normal /c*d*
569  assert_equal('a*b*', histget("search"))
570
571  new
572  setline(1, range(10))
573  :10
574  normal gg
575  assert_equal(10, getpos("''")[1])
576  keepjumps normal 5G
577  assert_equal(10, getpos("''")[1])
578  quit!
579enddef
580
581def Test_bar_line_continuation()
582  var lines =<< trim END
583      au BufNewFile Xfile g:readFile = 1
584          | g:readExtra = 2
585      g:readFile = 0
586      g:readExtra = 0
587      edit Xfile
588      assert_equal(1, g:readFile)
589      assert_equal(2, g:readExtra)
590      bwipe!
591      au! BufNewFile
592
593      au BufNewFile Xfile g:readFile = 1
594          | g:readExtra = 2
595          | g:readMore = 3
596      g:readFile = 0
597      g:readExtra = 0
598      g:readMore = 0
599      edit Xfile
600      assert_equal(1, g:readFile)
601      assert_equal(2, g:readExtra)
602      assert_equal(3, g:readMore)
603      bwipe!
604      au! BufNewFile
605      unlet g:readFile
606      unlet g:readExtra
607      unlet g:readMore
608  END
609  CheckDefAndScriptSuccess(lines)
610enddef
611
612def Test_command_modifier_other()
613  new Xsomefile
614  setline(1, 'changed')
615  var buf = bufnr()
616  hide edit Xotherfile
617  var info = getbufinfo(buf)
618  assert_equal(1, info[0].hidden)
619  assert_equal(1, info[0].changed)
620  edit Xsomefile
621  bwipe!
622
623  au BufNewFile Xfile g:readFile = 1
624  g:readFile = 0
625  edit Xfile
626  assert_equal(1, g:readFile)
627  bwipe!
628  g:readFile = 0
629  noautocmd edit Xfile
630  assert_equal(0, g:readFile)
631  au! BufNewFile
632  unlet g:readFile
633
634  noswapfile edit XnoSwap
635  assert_equal(false, &l:swapfile)
636  bwipe!
637
638  var caught = false
639  try
640    sandbox !ls
641  catch /E48:/
642    caught = true
643  endtry
644  assert_true(caught)
645
646  :8verbose g:verbose_now = &verbose
647  assert_equal(8, g:verbose_now)
648  unlet g:verbose_now
649enddef
650
651def EchoHere()
652  echomsg 'here'
653enddef
654def EchoThere()
655  unsilent echomsg 'there'
656enddef
657
658def Test_modifier_silent_unsilent()
659  echomsg 'last one'
660  silent echomsg "text"
661  assert_equal("\nlast one", execute(':1messages'))
662
663  silent! echoerr "error"
664
665  echomsg 'last one'
666  silent EchoHere()
667  assert_equal("\nlast one", execute(':1messages'))
668
669  silent EchoThere()
670  assert_equal("\nthere", execute(':1messages'))
671
672  try
673    silent eval [][0]
674  catch
675    echomsg "caught"
676  endtry
677  assert_equal("\ncaught", execute(':1messages'))
678enddef
679
680def Test_range_after_command_modifier()
681  CheckScriptFailure(['vim9script', 'silent keepjump 1d _'], 'E1050: Colon required before a range: 1d _', 2)
682  new
683  setline(1, 'xxx')
684  CheckScriptSuccess(['vim9script', 'silent keepjump :1d _'])
685  assert_equal('', getline(1))
686  bwipe!
687enddef
688
689def Test_silent_pattern()
690  new
691  silent! :/pat/put _
692  bwipe!
693enddef
694
695def Test_eval_command()
696  var from = 3
697  var to = 5
698  g:val = 111
699  def Increment(nrs: list<number>)
700    for nr in nrs
701      g:val += nr
702    endfor
703  enddef
704  eval range(from, to)
705        ->Increment()
706  assert_equal(111 + 3 + 4 + 5, g:val)
707  unlet g:val
708
709  var lines =<< trim END
710    vim9script
711    g:caught = 'no'
712    try
713      eval 123 || 0
714    catch
715      g:caught = 'yes'
716    endtry
717    assert_equal('yes', g:caught)
718    unlet g:caught
719  END
720  CheckScriptSuccess(lines)
721enddef
722
723def Test_map_command()
724  var lines =<< trim END
725      nnoremap <F3> :echo 'hit F3 #'<CR>
726      assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n"))
727  END
728  CheckDefSuccess(lines)
729  CheckScriptSuccess(['vim9script'] + lines)
730enddef
731
732def Test_normal_command()
733  new
734  setline(1, 'doesnotexist')
735  var caught = 0
736  try
737    exe "norm! \<C-]>"
738  catch /E433/
739    caught = 2
740  endtry
741  assert_equal(2, caught)
742
743  try
744    exe "norm! 3\<C-]>"
745  catch /E433/
746    caught = 3
747  endtry
748  assert_equal(3, caught)
749  bwipe!
750enddef
751
752def Test_put_command()
753  new
754  @p = 'ppp'
755  put p
756  assert_equal('ppp', getline(2))
757
758  put ='below'
759  assert_equal('below', getline(3))
760  put! ='above'
761  assert_equal('above', getline(3))
762  assert_equal('below', getline(4))
763
764  :2put =['a', 'b', 'c']
765  assert_equal(['ppp', 'a', 'b', 'c', 'above'], getline(2, 6))
766
767  # compute range at runtime
768  setline(1, range(1, 8))
769  @a = 'aaa'
770  :$-2put a
771  assert_equal('aaa', getline(7))
772
773  setline(1, range(1, 8))
774  :2
775  :+2put! a
776  assert_equal('aaa', getline(4))
777
778  []->mapnew(() => 0)
779  :$put ='end'
780  assert_equal('end', getline('$'))
781
782  bwipe!
783
784  CheckDefFailure(['put =xxx'], 'E1001:')
785enddef
786
787def Test_put_with_linebreak()
788  new
789  var lines =<< trim END
790    vim9script
791    pu =split('abc', '\zs')
792            ->join()
793  END
794  CheckScriptSuccess(lines)
795  getline(2)->assert_equal('a b c')
796  bwipe!
797enddef
798
799def Test_command_star_range()
800  new
801  setline(1, ['xxx foo xxx', 'xxx bar xxx', 'xxx foo xx bar'])
802  setpos("'<", [0, 1, 0, 0])
803  setpos("'>", [0, 3, 0, 0])
804  :*s/\(foo\|bar\)/baz/g
805  getline(1, 3)->assert_equal(['xxx baz xxx', 'xxx baz xxx', 'xxx baz xx baz'])
806
807  bwipe!
808enddef
809
810def Test_f_args()
811  var lines =<< trim END
812    vim9script
813
814    func SaveCmdArgs(...)
815      let g:args = a:000
816    endfunc
817
818    command -nargs=* TestFArgs call SaveCmdArgs(<f-args>)
819
820    TestFArgs
821    assert_equal([], g:args)
822
823    TestFArgs one two three
824    assert_equal(['one', 'two', 'three'], g:args)
825  END
826  CheckScriptSuccess(lines)
827enddef
828
829def Test_user_command_comment()
830  command -nargs=1 Comd echom <q-args>
831
832  var lines =<< trim END
833    vim9script
834    Comd # comment
835  END
836  CheckScriptSuccess(lines)
837
838  lines =<< trim END
839    vim9script
840    Comd# comment
841  END
842  CheckScriptFailure(lines, 'E1144:')
843
844  delcommand Comd
845enddef
846
847def Test_star_command()
848  var lines =<< trim END
849    vim9script
850    @s = 'g:success = 8'
851    set cpo+=*
852    exe '*s'
853    assert_equal(8, g:success)
854    unlet g:success
855    set cpo-=*
856    assert_fails("exe '*s'", 'E1050:')
857  END
858  CheckScriptSuccess(lines)
859enddef
860
861def Test_cmd_argument_without_colon()
862  new Xfile
863  setline(1, ['a', 'b', 'c', 'd'])
864  write
865  edit +3 %
866  assert_equal(3, getcurpos()[1])
867  edit +/a %
868  assert_equal(1, getcurpos()[1])
869  bwipe
870  delete('Xfile')
871enddef
872
873def Test_ambiguous_user_cmd()
874  command Cmd1 eval 0
875  command Cmd2 eval 0
876  var lines =<< trim END
877      Cmd
878  END
879  CheckDefAndScriptFailure(lines, 'E464:', 1)
880  delcommand Cmd1
881  delcommand Cmd2
882enddef
883
884def Test_command_not_recognized()
885  var lines =<< trim END
886    d.key = 'asdf'
887  END
888  CheckDefFailure(lines, 'E1146:', 1)
889
890  lines =<< trim END
891    d['key'] = 'asdf'
892  END
893  CheckDefFailure(lines, 'E1146:', 1)
894enddef
895
896def Test_magic_not_used()
897  new
898  for cmd in ['set magic', 'set nomagic']
899    exe cmd
900    setline(1, 'aaa')
901    s/.../bbb/
902    assert_equal('bbb', getline(1))
903  endfor
904
905  set magic
906  setline(1, 'aaa')
907  assert_fails('s/.\M../bbb/', 'E486:')
908  assert_fails('snomagic/.../bbb/', 'E486:')
909  assert_equal('aaa', getline(1))
910
911  bwipe!
912enddef
913
914def Test_gdefault_not_used()
915  new
916  for cmd in ['set gdefault', 'set nogdefault']
917    exe cmd
918    setline(1, 'aaa')
919    s/./b/
920    assert_equal('baa', getline(1))
921  endfor
922
923  set nogdefault
924  bwipe!
925enddef
926
927def g:SomeComplFunc(findstart: number, base: string): any
928  if findstart
929    return 0
930  else
931    return ['aaa', 'bbb']
932  endif
933enddef
934
935def Test_insert_complete()
936  # this was running into an error with the matchparen hack
937  new
938  set completefunc=SomeComplFunc
939  feedkeys("i\<c-x>\<c-u>\<Esc>", 'ntx')
940  assert_equal('aaa', getline(1))
941
942  set completefunc=
943  bwipe!
944enddef
945
946def Test_wincmd()
947  split
948  var id1 = win_getid()
949  if true
950    try | wincmd w | catch | endtry
951  endif
952  assert_notequal(id1, win_getid())
953  close
954enddef
955
956def Test_windo_missing_endif()
957  var lines =<< trim END
958      windo if 1
959  END
960  CheckDefExecFailure(lines, 'E171:', 1)
961enddef
962
963" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
964