comparison src/testdir/test_shift.vim @ 17688:c945f1d03b1c v8.1.1841

patch 8.1.1841: no test for Ex shift commands commit https://github.com/vim/vim/commit/d5e3cc11d391f3aa80bf66f91001f11a3a145b43 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 12 14:38:02 2019 +0200 patch 8.1.1841: no test for Ex shift commands Problem: No test for Ex shift commands. Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/4801)
author Bram Moolenaar <Bram@vim.org>
date Mon, 12 Aug 2019 14:45:05 +0200
parents
children 08940efa6b4e
comparison
equal deleted inserted replaced
17687:b8738c462084 17688:c945f1d03b1c
1 " Test shifting lines with :> and :<
2
3 source check.vim
4
5 func Test_ex_shift_right()
6 set shiftwidth=2
7
8 " shift right current line.
9 call setline(1, range(1, 5))
10 2
11 >
12 3
13 >>
14 call assert_equal(['1',
15 \ ' 2',
16 \ ' 3',
17 \ '4',
18 \ '5'], getline(1, '$'))
19
20 " shift right with range.
21 call setline(1, range(1, 4))
22 2,3>>
23 call assert_equal(['1',
24 \ ' 2',
25 \ ' 3',
26 \ '4',
27 \ '5'], getline(1, '$'))
28
29 " shift right with range and count.
30 call setline(1, range(1, 4))
31 2>3
32 call assert_equal(['1',
33 \ ' 2',
34 \ ' 3',
35 \ ' 4',
36 \ '5'], getline(1, '$'))
37
38 bw!
39 set shiftwidth&
40 endfunc
41
42 func Test_ex_shift_left()
43 set shiftwidth=2
44
45 call setline(1, range(1, 5))
46 %>>>
47
48 " left shift current line.
49 2<
50 3<<
51 4<<<<<
52 call assert_equal([' 1',
53 \ ' 2',
54 \ ' 3',
55 \ '4',
56 \ ' 5'], getline(1, '$'))
57
58 " shift right with range.
59 call setline(1, range(1, 5))
60 %>>>
61 2,3<<
62 call assert_equal([' 1',
63 \ ' 2',
64 \ ' 3',
65 \ ' 4',
66 \ ' 5'], getline(1, '$'))
67
68 " shift right with range and count.
69 call setline(1, range(1, 5))
70 %>>>
71 2<<3
72 call assert_equal([' 1',
73 \ ' 2',
74 \ ' 3',
75 \ ' 4',
76 \ ' 5'], getline(1, '$'))
77
78 bw!
79 set shiftwidth&
80 endfunc
81
82 func Test_ex_shift_rightleft()
83 CheckFeature rightleft
84
85 set shiftwidth=2 rightleft
86
87 call setline(1, range(1, 4))
88 2,3<<
89 call assert_equal(['1',
90 \ ' 2',
91 \ ' 3',
92 \ '4'], getline(1, '$'))
93
94 3,4>
95 call assert_equal(['1',
96 \ ' 2',
97 \ ' 3',
98 \ '4'], getline(1, '$'))
99
100 bw!
101 set rightleft& shiftwidth&
102 endfunc
103
104 func Test_ex_shift_errors()
105 call assert_fails('><', 'E488:')
106 call assert_fails('<>', 'E488:')
107
108 call assert_fails('>!', 'E477:')
109 call assert_fails('<!', 'E477:')
110
111 call assert_fails('2,1>', 'E493:')
112 call assert_fails('2,1<', 'E493:')
113 endfunc