robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
4edeaaa6e2
master
1" Tests for :hide command/modifier and 'hidden' option 2 3func SetUp () 4let s: save_hidden = & hidden 5let s: save_bufhidden = & bufhidden 6let s: save_autowrite = & autowrite 7set nohidden 8set bufhidden = 9set noautowrite 10endfunc 11 12function TearDown () 13let & hidden = s: save_hidden 14let & bufhidden = s: save_bufhidden 15let & autowrite = s: save_autowrite 16endfunc 17 18function Test_hide () 19let orig_bname = bufname ( '' ) 20let orig_winnr = winnr ( '$' ) 21 22new Xf1 23set modified 24call assert_fails ( 'edit Xf2' , 'E37: No write since last change (add ! to override)' ) 25bwipeout ! Xf1 26 27new Xf1 28set modified 29edit ! Xf2 30call assert_equal ([ 'Xf2' , 2 ], [ bufname ( '' ), winnr ( '$' )]) 31call assert_equal ([ 1 , 0 ], [ buflisted ( 'Xf1' ), bufloaded ( 'Xf1' )]) 32bwipeout ! Xf1 33bwipeout ! Xf2 34 35new Xf1 36set modified 37" :hide as a command 38hide 39call assert_equal ([ orig_bname , orig_winnr ], [ bufname ( '' ), winnr ( '$' )]) 40call assert_equal ([ 1 , 1 ], [ 'Xf1' ->buflisted (), 'Xf1' ->bufloaded ()]) 41bwipeout ! Xf1 42 43new Xf1 44set modified 45" :hide as a command with trailing comment 46hide " comment 47call assert_equal ([ orig_bname , orig_winnr ], [ bufname ( '' ), winnr ( '$' )]) 48call assert_equal ([ 1 , 1 ], [ buflisted ( 'Xf1' ), bufloaded ( 'Xf1' )]) 49bwipeout ! Xf1 50 51new Xf1 52set modified 53" :hide as a command with bar 54hide | new Xf2 " comment 55call assert_equal ([ 'Xf2' , 2 ], [ bufname ( '' ), winnr ( '$' )]) 56call assert_equal ([ 1 , 1 ], [ buflisted ( 'Xf1' ), bufloaded ( 'Xf1' )]) 57bwipeout ! Xf1 58bwipeout ! Xf2 59 60new Xf1 61set modified 62" :hide as a modifier with trailing comment 63hide edit Xf2 " comment 64call assert_equal ([ 'Xf2' , 2 ], [ bufname ( '' ), winnr ( '$' )]) 65call assert_equal ([ 1 , 1 ], [ buflisted ( 'Xf1' ), bufloaded ( 'Xf1' )]) 66bwipeout ! Xf1 67bwipeout ! Xf2 68 69new Xf1 70set modified 71" To check that the bar is not recognized to separate commands 72hide echo "one|two" 73call assert_equal ([ 'Xf1' , 2 ], [ bufname ( '' ), winnr ( '$' )]) 74call assert_equal ([ 1 , 1 ], [ buflisted ( 'Xf1' ), bufloaded ( 'Xf1' )]) 75bwipeout ! Xf1 76 77" set hidden 78new Xf1 79set hidden 80set modified 81edit Xf2 " comment 82call assert_equal ([ 'Xf2' , 2 ], [ bufname ( '' ), winnr ( '$' )]) 83call assert_equal ([ 1 , 1 ], [ buflisted ( 'Xf1' ), bufloaded ( 'Xf1' )]) 84bwipeout ! Xf1 85bwipeout ! Xf2 86 87" set hidden bufhidden=wipe 88new Xf1 89set bufhidden = wipe 90set modified 91hide edit! Xf2 " comment 92call assert_equal ([ 'Xf2' , 2 ], [ bufname ( '' ), winnr ( '$' )]) 93call assert_equal ([ 0 , 0 ], [ buflisted ( 'Xf1' ), bufloaded ( 'Xf1' )]) 94bwipeout ! Xf2 95endfunc 96 97" vim: shiftwidth=2 sts=2 expandtab