robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
813a6d3b11
master
1" Test the ":move" command. 2 3source check.vim 4source screendump.vim 5 6func Test_move () 7enew ! 8call append ( 0 , [ 'line 1' , 'line 2' , 'line 3' ]) 9g /^$ /delete _ 10set nomodified 11 12move . 13call assert_equal ([ 'line 1' , 'line 2' , 'line 3' ], getline ( 1 , 3 )) 14call assert_false ( & modified ) 15 161 , 2 move 0 17call assert_equal ([ 'line 1' , 'line 2' , 'line 3' ], getline ( 1 , 3 )) 18call assert_false ( & modified ) 19 201 , 3 move 3 21call assert_equal ([ 'line 1' , 'line 2' , 'line 3' ], getline ( 1 , 3 )) 22call assert_false ( & modified ) 23 241 move 2 25call assert_equal ([ 'line 2' , 'line 1' , 'line 3' ], getline ( 1 , 3 )) 26call assert_true ( & modified ) 27set nomodified 28 293 move 0 30call assert_equal ([ 'line 3' , 'line 2' , 'line 1' ], getline ( 1 , 3 )) 31call assert_true ( & modified ) 32set nomodified 33 342 , 3 move 0 35call assert_equal ([ 'line 2' , 'line 1' , 'line 3' ], getline ( 1 , 3 )) 36call assert_true ( & modified ) 37set nomodified 38 39call assert_fails ( '1,2move 1' , 'E134' ) 40call assert_fails ( '2,3move 2' , 'E134' ) 41call assert_fails ( "move -100" , 'E16:' ) 42call assert_fails ( "move +100" , 'E16:' ) 43call assert_fails ( 'move' , 'E16:' ) 44call assert_fails ( "move 'r" , 'E20:' ) 45 46 %bwipeout ! 47endfunc 48 49func Test_move_undo () 50CheckScreendump 51CheckRunVimInTerminal 52 53let lines =<< trim END 54call setline(1, ['First', 'Second', 'Third', 'Fourth']) 55END 56call writefile ( lines , 'Xtest_move_undo.vim' , 'D' ) 57let buf = RunVimInTerminal ( '-S Xtest_move_undo.vim' , #{ rows : 10 , cols : 60 , statusoff : 2 }) 58 59call term_sendkeys ( buf , "gg:move +1\<CR>" ) 60call VerifyScreenDump ( buf , 'Test_move_undo_1' , {}) 61 62" here the display would show the last few lines scrolled down 63call term_sendkeys ( buf , "u" ) 64call term_sendkeys ( buf , ":\<Esc>" ) 65call VerifyScreenDump ( buf , 'Test_move_undo_2' , {}) 66 67call StopVimInTerminal ( buf ) 68endfunc 69 70 71" vim: shiftwidth=2 sts=2 expandtab