@@ -142,11 +142,11 @@ def test_delete_from_cursor_forward(self):
142
142
line = "everything after this will be deleted"
143
143
pos = line .find ("this" )
144
144
expected = (pos , "everything after " )
145
- result = delete_from_cursor_forward (line .find ("this" ), line )
145
+ result = delete_from_cursor_forward (line .find ("this" ), line )[: - 1 ]
146
146
self .assertEquals (expected , result )
147
147
148
148
def test_delete_rest_of_word (self ):
149
- self .try_stages (['z|s;df asdf d s;a;a' ,
149
+ self .try_stages_kill (['z|s;df asdf d s;a;a' ,
150
150
'z|;df asdf d s;a;a' ,
151
151
'z| asdf d s;a;a' ,
152
152
'z| d s;a;a' ,
@@ -156,7 +156,7 @@ def test_delete_rest_of_word(self):
156
156
'z|' ], delete_rest_of_word )
157
157
158
158
def test_delete_word_to_cursor (self ):
159
- self .try_stages ([
159
+ self .try_stages_kill ([
160
160
' a;d sdf ;a;s;d; fjksald|a' ,
161
161
' a;d sdf ;a;s;d; |a' ,
162
162
' a;d sdf |a' ,
@@ -179,6 +179,15 @@ def try_stages(self, strings, func):
179
179
for (initial_pos , initial ), (final_pos , final ) in zip (stages [:- 1 ], stages [1 :]):
180
180
self .assertEquals (func (initial_pos , initial ), (final_pos , final ))
181
181
182
+ def try_stages_kill (self , strings , func ):
183
+ if not all ('|' in s for s in strings ):
184
+ raise ValueError ("Need to use '|' to specify cursor" )
185
+
186
+ stages = [(s .index ('|' ), s .replace ('|' , '' )) for s in strings ]
187
+ for (initial_pos , initial ), (final_pos , final ) in zip (stages [:- 1 ], stages [1 :]):
188
+ self .assertEquals (func (initial_pos , initial )[:- 1 ], (final_pos , final ))
189
+
190
+
182
191
def test_transpose_character_before_cursor (self ):
183
192
self .try_stages (["as|df asdf" ,
184
193
"ads|f asdf" ,
@@ -194,7 +203,7 @@ def test_backspace(self):
194
203
self .assertEquals (backspace (3 , 'as ' ), (2 , 'as' ))
195
204
196
205
def test_delete_word_from_cursor_back (self ):
197
- self .try_stages ([
206
+ self .try_stages_kill ([
198
207
"asd;fljk asd;lfjas;dlkfj asdlk jasdf;ljk|" ,
199
208
"asd;fljk asd;lfjas;dlkfj asdlk jasdf;|" ,
200
209
"asd;fljk asd;lfjas;dlkfj asdlk |" ,
0 commit comments