neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

test_arglist.vim (19793B)


      1 " Test argument list commands
      2 
      3 source check.vim
      4 source shared.vim
      5 source term_util.vim
      6 
      7 func Reset_arglist()
      8  args a | %argd
      9 endfunc
     10 
     11 func Test_argidx()
     12  args a b c
     13  last
     14  call assert_equal(2, argidx())
     15  %argdelete
     16  call assert_equal(0, argidx())
     17  " doing it again doesn't result in an error
     18  %argdelete
     19  call assert_equal(0, argidx())
     20  call assert_fails('2argdelete', 'E16:')
     21 
     22  args a b c
     23  call assert_equal(0, argidx())
     24  next
     25  call assert_equal(1, argidx())
     26  next
     27  call assert_equal(2, argidx())
     28  1argdelete
     29  call assert_equal(1, argidx())
     30  1argdelete
     31  call assert_equal(0, argidx())
     32  1argdelete
     33  call assert_equal(0, argidx())
     34 endfunc
     35 
     36 func Test_argadd()
     37  call Reset_arglist()
     38 
     39  %argdelete
     40  argadd a b c
     41  call assert_equal(0, argidx())
     42 
     43  %argdelete
     44  argadd a
     45  call assert_equal(0, argidx())
     46  argadd b c d
     47  call assert_equal(0, argidx())
     48 
     49  call Init_abc()
     50  argadd x
     51  call Assert_argc(['a', 'b', 'x', 'c'])
     52  call assert_equal(1, argidx())
     53 
     54  call Init_abc()
     55  0argadd x
     56  call Assert_argc(['x', 'a', 'b', 'c'])
     57  call assert_equal(2, argidx())
     58 
     59  call Init_abc()
     60  1argadd x
     61  call Assert_argc(['a', 'x', 'b', 'c'])
     62  call assert_equal(2, argidx())
     63 
     64  call Init_abc()
     65  $argadd x
     66  call Assert_argc(['a', 'b', 'c', 'x'])
     67  call assert_equal(1, argidx())
     68 
     69  call Init_abc()
     70  $argadd x
     71  +2argadd y
     72  call Assert_argc(['a', 'b', 'c', 'x', 'y'])
     73  call assert_equal(1, argidx())
     74 
     75  %argd
     76  edit d
     77  arga
     78  call assert_equal(1, len(argv()))
     79  call assert_equal('d', get(argv(), 0, ''))
     80 
     81  %argd
     82  edit some\ file
     83  arga
     84  call assert_equal(1, len(argv()))
     85  call assert_equal('some file', get(argv(), 0, ''))
     86 
     87  %argd
     88  new
     89  arga
     90  call assert_equal(0, len(argv()))
     91 
     92  if has('unix')
     93    call assert_fails('argadd `Xdoes_not_exist`', 'E479:')
     94  endif
     95 endfunc
     96 
     97 func Test_argadd_empty_curbuf()
     98  new
     99  let curbuf = bufnr('%')
    100  call writefile(['test', 'Xargadd'], 'Xargadd', 'D')
    101  " must not re-use the current buffer.
    102  argadd Xargadd
    103  call assert_equal(curbuf, bufnr('%'))
    104  call assert_equal('', bufname('%'))
    105  call assert_equal(1, '$'->line())
    106  rew
    107  call assert_notequal(curbuf, '%'->bufnr())
    108  call assert_equal('Xargadd', '%'->bufname())
    109  call assert_equal(2, line('$'))
    110 
    111  %argd
    112  bwipe!
    113 endfunc
    114 
    115 func Init_abc()
    116  args a b c
    117  next
    118 endfunc
    119 
    120 func Assert_argc(l)
    121  call assert_equal(len(a:l), argc())
    122  let i = 0
    123  while i < len(a:l) && i < argc()
    124    call assert_equal(a:l[i], argv(i))
    125    let i += 1
    126  endwhile
    127 endfunc
    128 
    129 " Test for [count]argument and [count]argdelete commands
    130 " Ported from the test_argument_count.in test script
    131 func Test_argument()
    132  call Reset_arglist()
    133 
    134  let save_hidden = &hidden
    135  set hidden
    136 
    137  let g:buffers = []
    138  augroup TEST
    139    au BufEnter * call add(buffers, expand('%:t'))
    140  augroup END
    141 
    142  argadd a b c d
    143  $argu
    144  $-argu
    145  -argu
    146  1argu
    147  +2argu
    148 
    149  augroup TEST
    150    au!
    151  augroup END
    152 
    153  call assert_equal(['d', 'c', 'b', 'a', 'c'], g:buffers)
    154 
    155  call assert_equal("\na   b   [c] d   ", execute(':args'))
    156 
    157  .argd
    158  call assert_equal(['a', 'b', 'd'], argv())
    159 
    160  -argd
    161  call assert_equal(['a', 'd'], argv())
    162 
    163  $argd
    164  call assert_equal(['a'], argv())
    165 
    166  1arga c
    167  1arga b
    168  $argu
    169  $arga x
    170  call assert_equal(['a', 'b', 'c', 'x'], argv())
    171 
    172  0arga y
    173  call assert_equal(['y', 'a', 'b', 'c', 'x'], argv())
    174 
    175  %argd
    176  call assert_equal([], argv())
    177 
    178  arga a b c d e f
    179  2,$-argd
    180  call assert_equal(['a', 'f'], argv())
    181 
    182  let &hidden = save_hidden
    183 
    184  let save_columns = &columns
    185  let &columns = 79
    186  try
    187    exe 'args ' .. join(range(1, 81))
    188    call assert_equal(join([
    189          \ '',
    190          \ '[1] 6   11  16  21  26  31  36  41  46  51  56  61  66  71  76  81  ',
    191          \ '2   7   12  17  22  27  32  37  42  47  52  57  62  67  72  77  ',
    192          \ '3   8   13  18  23  28  33  38  43  48  53  58  63  68  73  78  ',
    193          \ '4   9   14  19  24  29  34  39  44  49  54  59  64  69  74  79  ',
    194          \ '5   10  15  20  25  30  35  40  45  50  55  60  65  70  75  80  ',
    195          \ ], "\n"),
    196          \ execute('args'))
    197 
    198    " No trailing newline with one item per row.
    199    let long_arg = repeat('X', 81)
    200    exe 'args ' .. long_arg
    201    call assert_equal("\n[".long_arg.']', execute('args'))
    202  finally
    203    let &columns = save_columns
    204  endtry
    205 
    206  " Setting argument list should fail when the current buffer has unsaved
    207  " changes
    208  %argd
    209  enew!
    210  set modified
    211  call assert_fails('args x y z', 'E37:')
    212  args! x y z
    213  call assert_equal(['x', 'y', 'z'], argv())
    214  call assert_equal('x', expand('%:t'))
    215 
    216  last | enew | argu
    217  call assert_equal('z', expand('%:t'))
    218 
    219  %argdelete
    220  call assert_fails('argument', 'E163:')
    221 endfunc
    222 
    223 func Test_list_arguments()
    224  " Clean the argument list
    225  arga a | %argd
    226 
    227  " four args half the screen width makes two lines with two columns
    228  let aarg = repeat('a', &columns / 2 - 4)
    229  let barg = repeat('b', &columns / 2 - 4)
    230  let carg = repeat('c', &columns / 2 - 4)
    231  let darg = repeat('d', &columns / 2 - 4)
    232  exe 'argadd ' aarg barg carg darg
    233 
    234  redir => result
    235  args
    236  redir END
    237  call assert_match('\[' . aarg . '] \+' . carg . '\n' . barg . ' \+' . darg, trim(result))
    238 
    239  " if one arg is longer than half the screen make one column
    240  exe 'argdel' aarg
    241  let aarg = repeat('a', &columns / 2 + 2)
    242  exe '0argadd' aarg
    243  redir => result
    244  args
    245  redir END
    246  call assert_match(aarg . '\n\[' . barg . ']\n' . carg . '\n' . darg, trim(result))
    247 
    248  %argdelete
    249 endfunc
    250 
    251 func Test_args_with_quote()
    252  " Only on Unix can a file name include a double quote.
    253  if has('unix')
    254    args \"foobar
    255    call assert_equal('"foobar', argv(0))
    256    %argdelete
    257  endif
    258 endfunc
    259 
    260 " Test for 0argadd and 0argedit
    261 " Ported from the test_argument_0count.in test script
    262 func Test_zero_argadd()
    263  call Reset_arglist()
    264 
    265  arga a b c d
    266  2argu
    267  0arga added
    268  call assert_equal(['added', 'a', 'b', 'c', 'd'], argv())
    269 
    270  2argu
    271  arga third
    272  call assert_equal(['added', 'a', 'third', 'b', 'c', 'd'], argv())
    273 
    274  %argd
    275  arga a b c d
    276  2argu
    277  0arge edited
    278  call assert_equal(['edited', 'a', 'b', 'c', 'd'], argv())
    279 
    280  2argu
    281  arga third
    282  call assert_equal(['edited', 'a', 'third', 'b', 'c', 'd'], argv())
    283 
    284  2argu
    285  argedit file\ with\ spaces another file
    286  call assert_equal(['edited', 'a', 'file with spaces', 'another', 'file', 'third', 'b', 'c', 'd'], argv())
    287  call assert_equal('file with spaces', expand('%'))
    288 endfunc
    289 
    290 " Test for argc()
    291 func Test_argc()
    292  call Reset_arglist()
    293  call assert_equal(0, argc())
    294  argadd a b
    295  call assert_equal(2, argc())
    296 endfunc
    297 
    298 " Test for arglistid()
    299 func Test_arglistid()
    300  call Reset_arglist()
    301  arga a b
    302  call assert_equal(0, arglistid())
    303  split
    304  arglocal
    305  call assert_equal(1, arglistid())
    306  tabnew | tabfirst
    307  call assert_equal(0, arglistid(2))
    308  call assert_equal(1, arglistid(1, 1))
    309  call assert_equal(0, arglistid(2, 1))
    310  call assert_equal(1, arglistid(1, 2))
    311  tabonly | only | enew!
    312  argglobal
    313  call assert_equal(0, arglistid())
    314 endfunc
    315 
    316 " Tests for argv() and argc()
    317 func Test_argv()
    318  call Reset_arglist()
    319  call assert_equal([], argv())
    320  call assert_equal("", argv(2))
    321  call assert_equal(0, argc())
    322  argadd a b c d
    323  call assert_equal(4, argc())
    324  call assert_equal('c', argv(2))
    325 
    326  let w1_id = win_getid()
    327  split
    328  let w2_id = win_getid()
    329  arglocal
    330  args e f g
    331  tabnew
    332  let w3_id = win_getid()
    333  split
    334  let w4_id = win_getid()
    335  argglobal
    336  tabfirst
    337  call assert_equal(4, argc(w1_id))
    338  call assert_equal('b', argv(1, w1_id))
    339  call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w1_id))
    340 
    341  call assert_equal(3, argc(w2_id))
    342  call assert_equal('f', argv(1, w2_id))
    343  call assert_equal(['e', 'f', 'g'], argv(-1, w2_id))
    344 
    345  call assert_equal(3, argc(w3_id))
    346  call assert_equal('e', argv(0, w3_id))
    347  call assert_equal(['e', 'f', 'g'], argv(-1, w3_id))
    348 
    349  call assert_equal(4, argc(w4_id))
    350  call assert_equal('c', argv(2, w4_id))
    351  call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w4_id))
    352 
    353  call assert_equal(4, argc(-1))
    354  call assert_equal(3, argc())
    355  call assert_equal('d', argv(3, -1))
    356  call assert_equal(['a', 'b', 'c', 'd'], argv(-1, -1))
    357  tabonly | only | enew!
    358  " Negative test cases
    359  call assert_equal(-1, argc(100))
    360  call assert_equal('', argv(1, 100))
    361  call assert_equal([], argv(-1, 100))
    362  call assert_equal('', argv(10, -1))
    363  %argdelete
    364 endfunc
    365 
    366 " Test for the :argedit command
    367 func Test_argedit()
    368  call Reset_arglist()
    369  argedit a
    370  call assert_equal(['a'], argv())
    371  call assert_equal('a', expand('%:t'))
    372  argedit b
    373  call assert_equal(['a', 'b'], argv())
    374  call assert_equal('b', expand('%:t'))
    375  argedit a
    376  call assert_equal(['a', 'b', 'a'], argv())
    377  call assert_equal('a', expand('%:t'))
    378  " When file name case is ignored, an existing buffer with only case
    379  " difference is re-used.
    380  argedit C D
    381  call assert_equal('C', expand('%:t'))
    382  call assert_equal(['a', 'b', 'a', 'C', 'D'], argv())
    383  argedit c
    384  if has('fname_case')
    385    call assert_equal(['a', 'b', 'a', 'C', 'c', 'D'], argv())
    386  else
    387    call assert_equal(['a', 'b', 'a', 'C', 'C', 'D'], argv())
    388  endif
    389  0argedit x
    390  if has('fname_case')
    391    call assert_equal(['x', 'a', 'b', 'a', 'C', 'c', 'D'], argv())
    392  else
    393    call assert_equal(['x', 'a', 'b', 'a', 'C', 'C', 'D'], argv())
    394  endif
    395  enew! | set modified
    396  call assert_fails('argedit y', 'E37:')
    397  argedit! y
    398  if has('fname_case')
    399    call assert_equal(['x', 'y', 'y', 'a', 'b', 'a', 'C', 'c', 'D'], argv())
    400  else
    401    call assert_equal(['x', 'y', 'y', 'a', 'b', 'a', 'C', 'C', 'D'], argv())
    402  endif
    403  %argd
    404  bwipe! C
    405  bwipe! D
    406 
    407  " :argedit reuses the current buffer if it is empty
    408  %argd
    409  " make sure to use a new buffer number for x when it is loaded
    410  bw! x
    411  new
    412  let a = bufnr()
    413  argedit x
    414  call assert_equal(a, bufnr())
    415  call assert_equal('x', bufname())
    416  %argd
    417  bw! x
    418 endfunc
    419 
    420 " Test for the :argdedupe command
    421 func Test_argdedupe()
    422  call Reset_arglist()
    423  argdedupe
    424  call assert_equal([], argv())
    425 
    426  args a a a aa b b a b aa
    427  argdedupe
    428  call assert_equal(['a', 'aa', 'b'], argv())
    429 
    430  args a b c
    431  argdedupe
    432  call assert_equal(['a', 'b', 'c'], argv())
    433 
    434  args a
    435  argdedupe
    436  call assert_equal(['a'], argv())
    437 
    438  args a A b B
    439  argdedupe
    440  if has('fname_case')
    441    call assert_equal(['a', 'A', 'b', 'B'], argv())
    442  else
    443    call assert_equal(['a', 'b'], argv())
    444  endif
    445 
    446  args a b a c a b
    447  last
    448  argdedupe
    449  next
    450  call assert_equal('c', expand('%:t'))
    451 
    452  args a ./a
    453  argdedupe
    454  call assert_equal(['a'], argv())
    455 
    456  %argd
    457 endfunc
    458 
    459 " Test for the :argdelete command
    460 func Test_argdelete()
    461  call Reset_arglist()
    462  args aa a aaa b bb
    463  argdelete a*
    464  call assert_equal(['b', 'bb'], argv())
    465  call assert_equal('aa', expand('%:t'))
    466  last
    467  argdelete %
    468  call assert_equal(['b'], argv())
    469  call assert_fails('argdelete', 'E610:')
    470  call assert_fails('1,100argdelete', 'E16:')
    471  call assert_fails('argdel /\)/', 'E55:')
    472  call assert_fails('1argdel 1', 'E474:')
    473 
    474  call Reset_arglist()
    475  args a b c d
    476  next
    477  argdel
    478  call Assert_argc(['a', 'c', 'd'])
    479  %argdel
    480 
    481  call assert_fails('argdel does_not_exist', 'E480:')
    482 endfunc
    483 
    484 func Test_argdelete_completion()
    485  args foo bar
    486 
    487  call feedkeys(":argdelete \<C-A>\<C-B>\"\<CR>", 'tx')
    488  call assert_equal('"argdelete bar foo', @:)
    489 
    490  call feedkeys(":argdelete x \<C-A>\<C-B>\"\<CR>", 'tx')
    491  call assert_equal('"argdelete x bar foo', @:)
    492 
    493  %argd
    494 endfunc
    495 
    496 " Tests for the :next, :prev, :first, :last, :rewind commands
    497 func Test_argpos()
    498  call Reset_arglist()
    499  args a b c d
    500  last
    501  call assert_equal(3, argidx())
    502  call assert_fails('next', 'E165:')
    503  prev
    504  call assert_equal(2, argidx())
    505  Next
    506  call assert_equal(1, argidx())
    507  first
    508  call assert_equal(0, argidx())
    509  call assert_fails('prev', 'E164:')
    510  3next
    511  call assert_equal(3, argidx())
    512  rewind
    513  call assert_equal(0, argidx())
    514  %argd
    515 endfunc
    516 
    517 " Test for autocommand that redefines the argument list, when doing ":all".
    518 func Test_arglist_autocmd()
    519  autocmd BufReadPost Xxx2 next Xxx2 Xxx1
    520  call writefile(['test file Xxx1'], 'Xxx1', 'D')
    521  call writefile(['test file Xxx2'], 'Xxx2', 'D')
    522  call writefile(['test file Xxx3'], 'Xxx3', 'D')
    523 
    524  new
    525  " redefine arglist; go to Xxx1
    526  next! Xxx1 Xxx2 Xxx3
    527  " open window for all args; Reading Xxx2 will try to change the arglist and
    528  " that will fail
    529  call assert_fails("all", "E1156:")
    530  call assert_equal('test file Xxx1', getline(1))
    531  wincmd w
    532  call assert_equal('test file Xxx2', getline(1))
    533  wincmd w
    534  call assert_equal('test file Xxx3', getline(1))
    535 
    536  autocmd! BufReadPost Xxx2
    537  enew! | only
    538  argdelete Xxx*
    539  bwipe! Xxx1 Xxx2 Xxx3
    540 endfunc
    541 
    542 func Test_arg_all_expand()
    543  call writefile(['test file Xxx1'], 'Xx x', 'D')
    544  next notexist Xx\ x runtest.vim
    545  call assert_equal('notexist Xx\ x runtest.vim', expand('##'))
    546 endfunc
    547 
    548 func Test_large_arg()
    549  " Argument longer or equal to the number of columns used to cause
    550  " access to invalid memory.
    551  exe 'argadd ' .repeat('x', &columns)
    552  args
    553 endfunc
    554 
    555 func Test_argdo()
    556  next! Xa.c Xb.c Xc.c
    557  new
    558 
    559  let g:bufenter = 0
    560  let g:bufleave = 0
    561  autocmd BufEnter * let g:bufenter += 1
    562  autocmd BufLeave * let g:bufleave += 1
    563 
    564  let l = []
    565  argdo call add(l, expand('%'))
    566  call assert_equal(['Xa.c', 'Xb.c', 'Xc.c'], l)
    567  call assert_equal(3, g:bufenter)
    568  call assert_equal(3, g:bufleave)
    569 
    570  let g:bufenter = 0
    571  let g:bufleave = 0
    572 
    573  set eventignore=BufEnter,BufLeave
    574  let l = []
    575  argdo call add(l, expand('%'))
    576  call assert_equal(['Xa.c', 'Xb.c', 'Xc.c'], l)
    577  call assert_equal(0, g:bufenter)
    578  call assert_equal(0, g:bufleave)
    579  call assert_equal('BufEnter,BufLeave', &eventignore)
    580  set eventignore&
    581 
    582  autocmd! BufEnter
    583  autocmd! BufLeave
    584  unlet g:bufenter
    585  unlet g:bufleave
    586  bwipe Xa.c Xb.c Xc.c
    587 endfunc
    588 
    589 " Test for quitting Vim with unedited files in the argument list
    590 func Test_quit_with_arglist()
    591  CheckRunVimInTerminal
    592  let buf = RunVimInTerminal('', {'rows': 6})
    593  call term_sendkeys(buf, ":set nomore\n")
    594  call term_sendkeys(buf, ":args a b c\n")
    595  call term_sendkeys(buf, ":quit\n")
    596  call TermWait(buf)
    597  call WaitForAssert({-> assert_match('^E173:', term_getline(buf, 6))})
    598  call StopVimInTerminal(buf)
    599 
    600  " Try :confirm quit with unedited files in arglist
    601  let buf = RunVimInTerminal('', {'rows': 6})
    602  call term_sendkeys(buf, ":set nomore\n")
    603  call term_sendkeys(buf, ":args a b c\n")
    604  call term_sendkeys(buf, ":confirm quit\n")
    605  call TermWait(buf)
    606  call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$',
    607        \ term_getline(buf, 6))})
    608  call term_sendkeys(buf, "N")
    609  call TermWait(buf)
    610  call term_sendkeys(buf, ":confirm quit\n")
    611  call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$',
    612        \ term_getline(buf, 6))})
    613  call term_sendkeys(buf, "Y")
    614  call TermWait(buf)
    615  call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))})
    616  only!
    617  " When this test fails, swap files are left behind which breaks subsequent
    618  " tests
    619  call delete('.a.swp')
    620  call delete('.b.swp')
    621  call delete('.c.swp')
    622 endfunc
    623 
    624 " Test for ":all" not working when in the cmdline window
    625 func Test_all_not_allowed_from_cmdwin()
    626  au BufEnter * all
    627  next x
    628  " Use try/catch here, somehow assert_fails() doesn't work on MS-Windows
    629  " console.
    630  let caught = 'no'
    631  try
    632    exe ":norm! 7q?apat\<CR>"
    633  catch /E11:/
    634    let caught = 'yes'
    635  endtry
    636  call assert_equal('yes', caught)
    637  au! BufEnter
    638 endfunc
    639 
    640 func Test_clear_arglist_in_all()
    641  n 0 00 000 0000 00000 000000
    642  au WinNew 0 n 0
    643  call assert_fails("all", "E1156:")
    644  au! *
    645 endfunc
    646 
    647 " Test for the :all command
    648 func Test_all_command()
    649  %argdelete
    650 
    651  " :all command should not close windows with files in the argument list,
    652  " but can rearrange the windows.
    653  args Xargnew1 Xargnew2
    654  %bw!
    655  edit Xargold1
    656  split Xargnew1
    657  let Xargnew1_winid = win_getid()
    658  split Xargold2
    659  split Xargnew2
    660  let Xargnew2_winid = win_getid()
    661  split Xargold3
    662  all
    663  call assert_equal(2, winnr('$'))
    664  call assert_equal([Xargnew1_winid, Xargnew2_winid],
    665        \ [win_getid(1), win_getid(2)])
    666  call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')],
    667        \ [winbufnr(1), winbufnr(2)])
    668 
    669  " :all command should close windows for files which are not in the
    670  " argument list in the current tab page.
    671  %bw!
    672  edit Xargold1
    673  split Xargold2
    674  tabedit Xargold3
    675  split Xargold4
    676  tabedit Xargold5
    677  tabfirst
    678  all
    679  call assert_equal(3, tabpagenr('$'))
    680  call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')], tabpagebuflist(1))
    681  call assert_equal([bufnr('Xargold4'), bufnr('Xargold3')], tabpagebuflist(2))
    682  call assert_equal([bufnr('Xargold5')], tabpagebuflist(3))
    683 
    684  " :tab all command should close windows for files which are not in the
    685  " argument list across all the tab pages.
    686  %bw!
    687  edit Xargold1
    688  split Xargold2
    689  tabedit Xargold3
    690  split Xargold4
    691  tabedit Xargold5
    692  tabfirst
    693  args Xargnew1 Xargnew2
    694  tab all
    695  call assert_equal(2, tabpagenr('$'))
    696  call assert_equal([bufnr('Xargnew1')], tabpagebuflist(1))
    697  call assert_equal([bufnr('Xargnew2')], tabpagebuflist(2))
    698 
    699  " If a count is specified, then :all should open only that many windows.
    700  %bw!
    701  args Xargnew1 Xargnew2 Xargnew3 Xargnew4 Xargnew5
    702  all 3
    703  call assert_equal(3, winnr('$'))
    704  call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2'), bufnr('Xargnew3')],
    705        \ [winbufnr(1), winbufnr(2), winbufnr(3)])
    706 
    707  " The :all command should not open more than 'tabpagemax' tab pages.
    708  " If there are more files, then they should be opened in the last tab page.
    709  %bw!
    710  set tabpagemax=3
    711  tab all
    712  call assert_equal(3, tabpagenr('$'))
    713  call assert_equal([bufnr('Xargnew1')], tabpagebuflist(1))
    714  call assert_equal([bufnr('Xargnew2')], tabpagebuflist(2))
    715  call assert_equal([bufnr('Xargnew3'), bufnr('Xargnew4'), bufnr('Xargnew5')],
    716        \ tabpagebuflist(3))
    717  set tabpagemax&
    718 
    719  " Without the 'hidden' option, modified buffers should not be closed.
    720  args Xargnew1 Xargnew2
    721  %bw!
    722  edit Xargtemp1
    723  call setline(1, 'temp buffer 1')
    724  split Xargtemp2
    725  call setline(1, 'temp buffer 2')
    726  all
    727  call assert_equal(4, winnr('$'))
    728  call assert_equal([bufnr('Xargtemp2'), bufnr('Xargtemp1'), bufnr('Xargnew1'),
    729        \ bufnr('Xargnew2')],
    730        \ [winbufnr(1), winbufnr(2), winbufnr(3), winbufnr(4)])
    731 
    732  " With the 'hidden' option set, both modified and unmodified buffers in
    733  " closed windows should be hidden.
    734  set hidden
    735  all
    736  call assert_equal(2, winnr('$'))
    737  call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')],
    738        \ [winbufnr(1), winbufnr(2)])
    739  call assert_equal([1, 1, 0, 0], [getbufinfo('Xargtemp1')[0].hidden,
    740        \ getbufinfo('Xargtemp2')[0].hidden,
    741        \ getbufinfo('Xargnew1')[0].hidden,
    742        \ getbufinfo('Xargnew2')[0].hidden])
    743  set nohidden
    744 
    745  " When 'winheight' is set to a large value, :all should open only one
    746  " window.
    747  args Xargnew1 Xargnew2 Xargnew3 Xargnew4 Xargnew5
    748  %bw!
    749  set winheight=9999
    750  call assert_fails('all', 'E36:')
    751  call assert_equal([1, bufnr('Xargnew1')], [winnr('$'), winbufnr(1)])
    752  set winheight&
    753 
    754  " When 'winwidth' is set to a large value, :vert all should open only one
    755  " window.
    756  %bw!
    757  set winwidth=9999
    758  call assert_fails('vert all', 'E36:')
    759  call assert_equal([1, bufnr('Xargnew1')], [winnr('$'), winbufnr(1)])
    760  set winwidth&
    761 
    762  " empty argument list tests
    763  %bw!
    764  %argdelete
    765  call assert_equal('', execute('args'))
    766  all
    767  call assert_equal(1, winnr('$'))
    768 
    769  %argdelete
    770  %bw!
    771 endfunc
    772 
    773 " Test for deleting buffer when creating an arglist. This was accessing freed
    774 " memory
    775 func Test_crash_arglist_uaf()
    776  "%argdelete
    777  new one
    778  au BufAdd XUAFlocal :bw
    779  arglocal XUAFlocal
    780  au! BufAdd
    781  bw! XUAFlocal
    782 
    783  au BufAdd XUAFlocal2 :bw
    784  new two
    785  new three
    786  arglocal
    787  argadd XUAFlocal2 Xfoobar
    788  bw! XUAFlocal2
    789  bw! two
    790 
    791  au! BufAdd
    792 endfunc
    793 
    794 " This was using freed memory again
    795 func Test_crash_arglist_uaf2()
    796  new
    797  au BufAdd XUAFlocal :bw
    798  arglocal XUAFlocal
    799  redraw!
    800  put ='abc'
    801  2#
    802  au! BufAdd
    803 endfunc
    804 
    805 " vim: shiftwidth=2 sts=2 expandtab