robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
af23d17388
master
1" Various tests for inserting a Tab. 2 3" Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set. 4" Also test that dv_ works correctly 5func Test_smarttab () 6enew ! 7set smarttab expandtab ts = 8 sw = 4 8" make sure that backspace works, no matter what termcap is used 9exe "set t_kD=\<C-V>x7f t_kb=\<C-V>x08" 10call append ( 0 , [ 'start text' , 11 \"\t\tsome test text" , 12 \'test text' , 13 \"\t\tother test text" , 14 \' a cde' , 15 \' f ghi' , 16 \'test text' , 17 \' Second line beginning with whitespace' 18 \]) 19call cursor ( 1 , 1 ) 20exe "normal /some\<CR>" 21exe "normal r\t" 22call assert_equal ( "\t\t ome test text" , getline ( '.' )) 23set noexpandtab 24exe "normal /other\<CR>" 25exe "normal r\t" 26call assert_equal ( "\t\t ther test text" , getline ( '.' )) 27 28" Test replacing with Tabs and then backspacing to undo it 29exe "normal j0wR\t\t\t\<BS>\<BS>\<BS>" 30call assert_equal ( " a cde" , getline ( '.' )) 31" Test replacing with Tabs 32exe "normal j0wR\t\t\t" 33call assert_equal ( " \t\thi" , getline ( '.' )) 34 35" Test that copyindent works with expandtab set 36set expandtab smartindent copyindent ts = 8 sw = 8 sts = 8 37exe "normal jo{\<CR>x" 38call assert_equal ( '{' , getline ( line ( '.' ) - 1 )) 39call assert_equal ( ' x' , getline ( '.' )) 40set nosol 41exe "normal /Second line/\<CR>" 42exe "normal fwdv_" 43call assert_equal ( ' with whitespace' , getline ( '.' )) 44enew ! 45set expandtab & smartindent & copyindent & ts & sw & sts & 46endfunc 47 48func Test_softtabstop () 49new 50set sts = 0 sw = 0 51exe "normal ix\<Tab>x\<Esc>" 52call assert_equal ( "x\tx" , getline ( 1 )) 53 54call setline ( 1 , '' ) 55set sts = 4 56exe "normal ix\<Tab>x\<Esc>" 57call assert_equal ( "x x" , getline ( 1 )) 58 59call setline ( 1 , '' ) 60set sts = -1sw = 4 61exe "normal ix\<Tab>x\<Esc>" 62call assert_equal ( "x x" , getline ( 1 )) 63 64call setline ( 1 , 'x ' ) 65set sts = 0 sw = 0 backspace = start 66exe "normal A\<BS>x\<Esc>" 67call assert_equal ( "x x" , getline ( 1 )) 68 69call setline ( 1 , 'x ' ) 70set sts = 4 71exe "normal A\<BS>x\<Esc>" 72call assert_equal ( "x x" , getline ( 1 )) 73 74call setline ( 1 , 'x ' ) 75set sts = -1sw = 4 76exe "normal A\<BS>x\<Esc>" 77call assert_equal ( "x x" , getline ( 1 )) 78 79call setline ( 1 , 'x' ) 80set sts = -1sw = 0 smarttab 81exe "normal I\<Tab>\<Esc>" 82call assert_equal ( "\tx" , getline ( 1 )) 83 84call setline ( 1 , 'x' ) 85exe "normal I\<Tab>\<BS>\<Esc>" 86call assert_equal ( "x" , getline ( 1 )) 87 88set sts = 0 sw = 0 backspace & nosmarttab 89bwipe ! 90endfunc