-
Notifications
You must be signed in to change notification settings - Fork 323
Expand file tree
/
Copy pathMovementTest.VI.Multiline.cs
More file actions
199 lines (168 loc) · 7.47 KB
/
MovementTest.VI.Multiline.cs
File metadata and controls
199 lines (168 loc) · 7.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using Microsoft.PowerShell;
using Xunit;
namespace Test
{
public partial class ReadLine
{
[SkippableFact]
public void ViMoveToLine_DesiredColumn()
{
TestSetup(KeyMode.Vi);
const string buffer = "\"\n12345\n1234\n123\n12\n1\n\"";
Test(buffer, Keys(
_.DQuote, _.Enter,
"12345", _.Enter,
"1234", _.Enter,
"123", _.Enter,
"12", _.Enter,
"1", _.Enter,
_.DQuote,
_.Escape,
// move to second line at column 4
"ggj3l", CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 3)),
// moving down on shorter lines will position the cursor at the end of each logical line
_.j, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 3)),
_.j, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 2)),
// moving back up will position the cursor at the end of shorter lines or at the desired column number
_.k, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 3)),
_.k, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 3)),
// move at end of line (column 5)
_.Dollar, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 4)),
// moving down on shorter lines will position the cursor at the end of each logical line
_.j, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 3)),
_.j, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 2)),
// moving back up will position the cursor at the end of each logical line
_.k, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 3)),
_.k, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 4))
));
}
[SkippableFact]
public void ViBackwardChar()
{
TestSetup(KeyMode.Vi);
const string buffer = "\"\nline2\nline3\n\"";
Test(buffer, Keys(
_.DQuote, _.Enter,
"line2", _.Enter,
"line3", _.Enter,
_.DQuote,
_.Escape,
_.k, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0)),
// move left
_.h, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0)),
_.l, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 1)),
"2h", CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0))
));
}
[SkippableFact]
public void ViForwardChar()
{
TestSetup(KeyMode.Vi);
const string buffer = "\"\nline2\nline3\n\"";
Test(buffer, Keys(
_.DQuote, _.Enter,
"line2", _.Enter,
"line3", _.Enter,
_.DQuote,
_.Escape,
_.k, _.k, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 0)),
// move right
_.l, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 1)),
"10l", CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 4))
));
}
[SkippableFact]
public void ViMoveToFirstLogicalLineThenJumpToLastLogicalLine()
{
TestSetup(KeyMode.Vi);
const string buffer = "\"Multiline buffer\n containing an empty line\n\nand text aligned on the left\n\"";
Test(buffer, Keys(
_.DQuote, "Multiline buffer", _.Enter,
" containing an empty line", _.Enter,
_.Enter,
"and text aligned on the left", _.Enter,
_.DQuote,
_.Escape, CheckThat(() => AssertCursorTopIs(4)),
"gg", CheckThat(() => AssertCursorLeftTopIs(0, 0)),
'G', CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 4))
));
}
[SkippableFact]
public void ViMoveToLastLogicalLine_MustDing_ForEmptyLine()
{
const string buffer = "";
var keys = new object[] {"", _.Escape, 'G',};
ViJumpMustDing(buffer, keys);
}
[SkippableFact]
public void ViMoveToFirstLogicalLine_MustDing_ForEmptyLine()
{
const string buffer = "";
var keys = new object[] {"", _.Escape, "gg",};
ViJumpMustDing(buffer, keys);
}
[SkippableFact]
public void ViMoveToLastLogicalLine_MustDing_ForSingleLine()
{
const string buffer = "Ding";
var keys = new object[] {"Ding", _.Escape, 'G',};
ViJumpMustDing(buffer, keys);
}
[SkippableFact]
public void ViMoveToFirstLogicalLine_MustDing_ForSingleLine()
{
const string buffer = "Ding";
var keys = new object[] {"Ding", _.Escape, "gg",};
ViJumpMustDing(buffer, keys);
}
[SkippableFact]
public void ViMoveToFirstNonBlankOfLogicalLineThenJumpToEndOfLogicalLine()
{
TestSetup(KeyMode.Vi);
const string buffer = "\"\n line\"";
Test(buffer, Keys(
_.DQuote, _.Enter, " line", _.DQuote, _.Escape, CheckThat(() => AssertCursorLeftIs(ContinuationPromptLength + 6)),
_.Underbar, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength + 2, 1)),
_.Dollar, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength + 6, 1)),
// also works forward
'0', CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength, 1)),
_.Underbar, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength + 2, 1))
));
}
[SkippableFact]
public void ViMoveToFirstNonBlankOfLogicalLine_NoOp_OnEmptyLine()
{
TestSetup(KeyMode.Vi);
const string buffer = "\"\n\n\"";
Test(buffer, Keys(
_.DQuote, _.Enter, _.Enter, _.DQuote, _.Escape, _.k,
CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength + 0, 1)),
_.Underbar, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength + 0, 1))
));
}
[SkippableFact]
public void ViDefect2050()
{
TestSetup(KeyMode.Vi);
Test("", Keys(
_.Escape, _.Underbar
));
}
[SkippableFact]
public void ViMoveToEndOfLine_NoOp_OnEmptyLine()
{
TestSetup(KeyMode.Vi);
const string buffer = "\"\n\n\"";
Test(buffer, Keys(
_.DQuote, _.Enter, _.Enter, _.DQuote, _.Escape, _.k,
CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength + 0, 1)),
_.Dollar, CheckThat(() => AssertCursorLeftTopIs(ContinuationPromptLength + 0, 1))
));
}
private void ViJumpMustDing(string expectedResult, params object[] keys)
{
TestSetup(KeyMode.Vi);
TestMustDing(expectedResult, Keys(keys));
}
}
}