view src/testdir/test_man.vim @ 19783:546bdeef35f1 v8.2.0448

patch 8.2.0448: various functions not properly tested Commit: https://github.com/vim/vim/commit/0e05de46226eb4e5ea580beefa71831f92d613d3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 25 22:23:46 2020 +0100 patch 8.2.0448: various functions not properly tested Problem: Various functions not properly tested. Solution: Add more tests, especially for failures. (Yegappan Lakshmanan, closes #5843)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Mar 2020 22:30:04 +0100
parents d9aa921b7198
children 18043e7ab449
line wrap: on
line source

runtime ftplugin/man.vim

func Test_g_ft_man_open_mode()
  vnew
  let l:h = winheight(1)
  q
  let l:w = winwidth(1)

  " split horizontally
  let wincnt = winnr('$')
  Man vim
  if wincnt == winnr('$')
    " Vim manual page cannot be found.
    return
  endif

  call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
  call assert_true(l:h > winheight(1))
  call assert_equal(1, tabpagenr('$'))
  call assert_equal(1, tabpagenr())
  q

  " split horizontally
  let g:ft_man_open_mode = "horz"
  Man vim
  call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
  call assert_true(l:h > winheight(1))
  call assert_equal(1, tabpagenr('$'))
  call assert_equal(1, tabpagenr())
  q

  " split vertically
  let g:ft_man_open_mode = "vert"
  Man vim
  call assert_true(l:w > winwidth(1))
  call assert_equal(l:h, winheight(1))
  call assert_equal(1, tabpagenr('$'))
  call assert_equal(1, tabpagenr())
  q

  " separate tab
  let g:ft_man_open_mode = "tab"
  Man vim
  call assert_inrange(l:w - 2, l:w + 2, winwidth(1))
  call assert_inrange(l:h - 1, l:h + 1, winheight(1))
  call assert_equal(2, tabpagenr('$'))
  call assert_equal(2, tabpagenr())
  q

  unlet g:ft_man_open_mode
endfunc

func Test_nomodifiable()
  let wincnt = winnr('$')
  Man vim
  if wincnt == winnr('$')
    " Vim manual page cannot be found.
    return
  endif
  call assert_false(&l:modifiable)
  q
endfunc

func Test_buffer_count_hidden()
  %bw!
  set hidden

  call assert_equal(1, len(getbufinfo()))

  let wincnt = winnr('$')
  Man vim
  if wincnt == winnr('$')
    " Vim manual page cannot be found.
    return
  endif

  call assert_equal(1, len(getbufinfo({'buflisted':1})))
  call assert_equal(2, len(getbufinfo()))
  q

  Man vim

  call assert_equal(1, len(getbufinfo({'buflisted':1})))
  call assert_equal(2, len(getbufinfo()))
  q

  set hidden&
endfunc

" Check that we do not alter the settings in the initial window.
func Test_local_options()
  %bw!
  set foldcolumn=1 number

  let wincnt = winnr('$')
  Man vim
  if wincnt == winnr('$')
    " Vim manual page cannot be found.
    return
  endif

  " man page
  call assert_false(&nu)
  call assert_equal(0, &fdc)

  " initial window
  wincmd p
  call assert_true(&nu)
  call assert_equal(1, &fdc)

  %bw!
  set foldcolumn& number&
endfunc