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