view src/testdir/test_hide.vim @ 10930:126405b39964 v8.0.0354

patch 8.0.0354: test to check that setting termcap key fails sometimes commit https://github.com/vim/vim/commit/1c410400fad79068b16dc4c6c7a023463a0858cf Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 23 15:20:03 2017 +0100 patch 8.0.0354: test to check that setting termcap key fails sometimes Problem: Test to check that setting termcap key fails sometimes. Solution: Check for "t_k1" to exist. (Christian Brabandt, closes https://github.com/vim/vim/issues/1459)
author Christian Brabandt <cb@256bit.org>
date Thu, 23 Feb 2017 15:30:05 +0100
parents b59df2194b01
children 45eca7143d7c
line wrap: on
line source

" Tests for :hide command/modifier and 'hidden' option

function SetUp()
  let s:save_hidden = &hidden
  let s:save_bufhidden = &bufhidden
  let s:save_autowrite = &autowrite
  set nohidden
  set bufhidden=
  set noautowrite
endfunc

function TearDown()
  let &hidden = s:save_hidden
  let &bufhidden = s:save_bufhidden
  let &autowrite = s:save_autowrite
endfunc

function Test_hide()
  let orig_bname = bufname('')
  let orig_winnr = winnr('$')

  new Xf1
  set modified
  call assert_fails('edit Xf2')
  bwipeout! Xf1

  new Xf1
  set modified
  edit! Xf2
  call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
  call assert_equal([1, 0], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf1
  bwipeout! Xf2

  new Xf1
  set modified
  " :hide as a command
  hide
  call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')])
  call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf1

  new Xf1
  set modified
  " :hide as a command with trailing comment
  hide " comment
  call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')])
  call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf1

  new Xf1
  set modified
  " :hide as a command with bar
  hide | new Xf2 " comment
  call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
  call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf1
  bwipeout! Xf2

  new Xf1
  set modified
  " :hide as a modifier with trailing comment
  hide edit Xf2 " comment
  call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
  call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf1
  bwipeout! Xf2

  new Xf1
  set modified
  " To check that the bar is not recognized to separate commands
  hide echo "one|two"
  call assert_equal(['Xf1', 2], [bufname(''), winnr('$')])
  call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf1

  " set hidden
  new Xf1
  set hidden
  set modified
  edit Xf2 " comment
  call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
  call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf1
  bwipeout! Xf2

  " set hidden bufhidden=wipe
  new Xf1
  set bufhidden=wipe
  set modified
  hide edit! Xf2 " comment
  call assert_equal(['Xf2', 2], [bufname(''), winnr('$')])
  call assert_equal([0, 0], [buflisted('Xf1'), bufloaded('Xf1')])
  bwipeout! Xf2
endfunc

" vim: shiftwidth=2 sts=2 expandtab