Coverage for commands\test_editCommands.py : 95%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2#@+leo-ver=5-thin
3#@+node:ekr.20201202144422.1: * @file ../unittests/commands/test_editCommands.py
4#@@first
5"""Tests for leo.commands.editCommands."""
6import textwrap
7from leo.core import leoGlobals as g
8from leo.core.leoTest2 import LeoUnitTest
9#@+others
10#@+node:ekr.20210829060957.1: ** class TestEditCommands(LeoUnitTest)
11class TestEditCommands(LeoUnitTest):
12 """Unit tests for leo/commands/editCommands.py."""
13 # For pylint.
14 before_p = after_p = parent_p = tempNode = None
15 #@+others
16 #@+node:ekr.20201129161726.5: *3* TestEditCommands.run_test
17 def run_test(self,
18 before_b, after_b, # before/after body text.
19 before_sel, after_sel, # before and after selection ranges.
20 command_name,
21 directives='',
22 dedent=True,
23 ):
24 """
25 A helper for many commands tests.
26 """
27 c = self.c
28 # For shortDescription().
29 self.command_name = command_name
30 # Compute the result in tempNode.b
31 command = c.commandsDict.get(command_name)
32 assert command, f"no command: {command_name}"
33 # Set the text.
34 if dedent:
35 parent_b = textwrap.dedent(directives)
36 before_b = textwrap.dedent(before_b)
37 after_b = textwrap.dedent(after_b)
38 else:
39 # The unit test is responsible for all indentation.
40 parent_b = directives
41 self.parent_p.b = parent_b
42 self.tempNode.b = before_b
43 self.before_p.b = before_b
44 self.after_p.b = after_b
45 # Set the selection range and insert point.
46 w = c.frame.body.wrapper
47 i, j = before_sel
48 i = g.toPythonIndex(before_b, i)
49 j = g.toPythonIndex(before_b, j)
50 w.setSelectionRange(i, j, insert=j)
51 # Run the command!
52 c.k.simulateCommand(command_name)
53 self.assertEqual(self.tempNode.b, self.after_p.b, msg=command_name)
54 #@+node:ekr.20201201084621.1: *3* TestEditCommands.setUp
55 def setUp(self):
56 """Create the nodes in the commander."""
57 super().setUp()
58 c = self.c
59 # Create top-level parent node.
60 self.parent_p = self.root_p.insertAsLastChild()
61 # Create children of the parent node.
62 self.tempNode = self.parent_p.insertAsLastChild()
63 self.before_p = self.parent_p.insertAsLastChild()
64 self.after_p = self.parent_p.insertAsLastChild()
65 self.tempNode.h = 'tempNode'
66 self.before_p.h = 'before'
67 self.after_p.h = 'after'
68 c.selectPosition(self.tempNode)
70 # def tearDown(self):
71 # self.c = None
72 #@+node:ekr.20201130091020.1: *3* TestEditCommands: Commands...
73 #@+node:ekr.20210829061326.1: *4* Commands A-B
74 #@+node:ekr.20201130090918.1: *5* add-space-to-lines
75 def test_add_space_to_lines(self):
76 """Test case for add-space-to-lines"""
77 before_b = """\
78 first line
79 line 1
80 line a
81 line b
82 last line
83 """
84 after_b = """\
85 first line
86 line 1
87 line a
88 line b
89 last line
90 """
91 self.run_test(
92 before_b=before_b,
93 after_b=after_b,
94 before_sel=("2.0", "4.6"),
95 after_sel=("2.0", "4.7"),
96 command_name="add-space-to-lines",
97 )
98 #@+node:ekr.20201130090918.2: *5* add-tab-to-lines
99 def test_add_tab_to_lines(self):
100 """Test case for add-tab-to-lines"""
101 before_b = """\
102 first line
103 line 1
104 line a
105 line b
106 line c
107 last line
108 """
109 after_b = """\
110 first line
111 line 1
112 line a
113 line b
114 line c
115 last line
116 """
117 self.run_test(
118 before_b=before_b,
119 after_b=after_b,
120 before_sel=("2.0", "5.6"),
121 after_sel=("2.0", "5.10"),
122 command_name="add-tab-to-lines",
123 )
124 #@+node:ekr.20201130090918.3: *5* back-char
125 def test_back_char(self):
126 """Test case for back-char"""
127 before_b = """\
128 first line
129 line 1
130 line a
131 line b
132 line c
133 last line
134 """
135 after_b = """\
136 first line
137 line 1
138 line a
139 line b
140 line c
141 last line
142 """
143 self.run_test(
144 before_b=before_b,
145 after_b=after_b,
146 before_sel=("3.8", "3.8"),
147 after_sel=("3.7", "3.7"),
148 command_name="back-char",
149 )
150 #@+node:ekr.20201130090918.4: *5* back-char-extend-selection
151 def test_back_char_extend_selection(self):
152 """Test case for back-char-extend-selection"""
153 before_b = """\
154 first line
155 line 1
156 line a
157 line b
158 line c
159 last line
160 """
161 after_b = """\
162 first line
163 line 1
164 line a
165 line b
166 line c
167 last line
168 """
169 self.run_test(
170 before_b=before_b,
171 after_b=after_b,
172 before_sel=("4.12", "4.12"),
173 after_sel=("4.11", "4.12"),
174 command_name="back-char-extend-selection",
175 )
176 #@+node:ekr.20201130090918.5: *5* back-paragraph
177 def test_back_paragraph(self):
178 """Test case for back-paragraph"""
179 before_b = """\
180 Americans live in the most severe weather-prone country on Earth. Each year,
181 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
182 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
183 weather impacts every American. Communities can now rely on the National Weather
184 Service’s StormReady program to help them guard against the ravages of Mother
185 Nature.
187 Some 90% of all presidentially declared disasters are weather related, leading
188 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
189 program started in 1999 in Tulsa, OK, helps arm America's communities with the
190 communication and safety skills needed to save lives and property– before and
191 during the event. StormReady helps community leaders and emergency managers
192 strengthen local safety programs.
194 StormReady communities are better prepared to save lives from the onslaught of
195 severe weather through better planning, education, and awareness. No community
196 is storm proof, but StormReady can help communities save lives. Does StormReady
197 make a difference?
198 """
199 after_b = """\
200 Americans live in the most severe weather-prone country on Earth. Each year,
201 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
202 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
203 weather impacts every American. Communities can now rely on the National Weather
204 Service’s StormReady program to help them guard against the ravages of Mother
205 Nature.
207 Some 90% of all presidentially declared disasters are weather related, leading
208 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
209 program started in 1999 in Tulsa, OK, helps arm America's communities with the
210 communication and safety skills needed to save lives and property– before and
211 during the event. StormReady helps community leaders and emergency managers
212 strengthen local safety programs.
214 StormReady communities are better prepared to save lives from the onslaught of
215 severe weather through better planning, education, and awareness. No community
216 is storm proof, but StormReady can help communities save lives. Does StormReady
217 make a difference?
218 """
219 self.run_test(
220 before_b=before_b,
221 after_b=after_b,
222 before_sel=("9.0", "9.0"),
223 after_sel=("6.7", "6.7"),
224 command_name="back-paragraph",
225 )
226 #@+node:ekr.20201130090918.6: *5* back-paragraph-extend-selection
227 def test_back_paragraph_extend_selection(self):
228 """Test case for back-paragraph-extend-selection"""
229 before_b = """\
230 Americans live in the most severe weather-prone country on Earth. Each year,
231 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
232 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
233 weather impacts every American. Communities can now rely on the National Weather
234 Service’s StormReady program to help them guard against the ravages of Mother
235 Nature.
237 Some 90% of all presidentially declared disasters are weather related, leading
238 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
239 program started in 1999 in Tulsa, OK, helps arm America's communities with the
240 communication and safety skills needed to save lives and property– before and
241 during the event. StormReady helps community leaders and emergency managers
242 strengthen local safety programs.
244 StormReady communities are better prepared to save lives from the onslaught of
245 severe weather through better planning, education, and awareness. No community
246 is storm proof, but StormReady can help communities save lives. Does StormReady
247 make a difference?
248 """
249 after_b = """\
250 Americans live in the most severe weather-prone country on Earth. Each year,
251 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
252 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
253 weather impacts every American. Communities can now rely on the National Weather
254 Service’s StormReady program to help them guard against the ravages of Mother
255 Nature.
257 Some 90% of all presidentially declared disasters are weather related, leading
258 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
259 program started in 1999 in Tulsa, OK, helps arm America's communities with the
260 communication and safety skills needed to save lives and property– before and
261 during the event. StormReady helps community leaders and emergency managers
262 strengthen local safety programs.
264 StormReady communities are better prepared to save lives from the onslaught of
265 severe weather through better planning, education, and awareness. No community
266 is storm proof, but StormReady can help communities save lives. Does StormReady
267 make a difference?
268 """
269 self.run_test(
270 before_b=before_b,
271 after_b=after_b,
272 before_sel=("9.0", "9.5"),
273 after_sel=("6.7", "9.5"),
274 command_name="back-paragraph-extend-selection",
275 )
276 #@+node:ekr.20201130090918.7: *5* back-sentence
277 def test_back_sentence(self):
278 """Test case for back-sentence"""
279 before_b = """\
280 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
282 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
284 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
285 """
286 after_b = """\
287 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
289 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
291 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
292 """
293 self.run_test(
294 before_b=before_b,
295 after_b=after_b,
296 before_sel=("3.169", "3.169"),
297 after_sel=("3.143", "3.143"),
298 command_name="back-sentence",
299 )
300 #@+node:ekr.20201130090918.8: *5* back-sentence-extend-selection
301 def test_back_sentence_extend_selection(self):
302 """Test case for back-sentence-extend-selection"""
303 before_b = """\
304 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
306 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
308 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
309 """
310 after_b = """\
311 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
313 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
315 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
316 """
317 self.run_test(
318 before_b=before_b,
319 after_b=after_b,
320 before_sel=("3.208", "3.208"),
321 after_sel=("3.143", "3.208"),
322 command_name="back-sentence-extend-selection",
323 )
324 #@+node:ekr.20201130090918.12: *5* back-to-home (at end of line)
325 def test_back_to_home_at_end_of_line(self):
326 """Test case for back-to-home (at end of line)"""
327 before_b = """\
328 if a:
329 b = 'xyz'
330 """
331 after_b = """\
332 if a:
333 b = 'xyz'
334 """
335 self.run_test(
336 before_b=before_b,
337 after_b=after_b,
338 before_sel=("2.12", "2.12"),
339 after_sel=("2.4", "2.4"),
340 command_name="back-to-home",
341 )
342 #@+node:ekr.20201130090918.11: *5* back-to-home (at indentation
343 def test_back_to_home_at_indentation(self):
344 """Test case for back-to-home (at indentation"""
345 before_b = """\
346 if a:
347 b = 'xyz'
348 """
349 after_b = """\
350 if a:
351 b = 'xyz'
352 """
353 self.run_test(
354 before_b=before_b,
355 after_b=after_b,
356 before_sel=("2.4", "2.4"),
357 after_sel=("2.0", "2.0"),
358 command_name="back-to-home",
359 )
360 #@+node:ekr.20201130090918.10: *5* back-to-home (at start of line)
361 def test_back_to_home_at_start_of_line(self):
362 """Test case for back-to-home (at start of line)"""
363 before_b = """\
364 if a:
365 b = 'xyz'
366 """
367 after_b = """\
368 if a:
369 b = 'xyz'
370 """
371 self.run_test(
372 before_b=before_b,
373 after_b=after_b,
374 before_sel=("2.0", "2.0"),
375 after_sel=("2.4", "2.4"),
376 command_name="back-to-home",
377 )
378 #@+node:ekr.20201130090918.9: *5* back-to-indentation
379 def test_back_to_indentation(self):
380 """Test case for back-to-indentation"""
381 before_b = """\
382 first line
383 line 1
384 line a
385 line b
386 line c
387 last line
388 """
389 after_b = """\
390 first line
391 line 1
392 line a
393 line b
394 line c
395 last line
396 """
397 self.run_test(
398 before_b=before_b,
399 after_b=after_b,
400 before_sel=("4.13", "4.13"),
401 after_sel=("4.8", "4.8"),
402 command_name="back-to-indentation",
403 )
404 #@+node:ekr.20201130090918.13: *5* back-word
405 def test_back_word(self):
406 """Test case for back-word"""
407 before_b = """\
408 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
410 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
412 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
413 """
414 after_b = """\
415 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
417 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
419 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
420 """
421 self.run_test(
422 before_b=before_b,
423 after_b=after_b,
424 before_sel=("1.183", "1.183"),
425 after_sel=("1.178", "1.178"),
426 command_name="back-word",
427 )
428 #@+node:ekr.20201130090918.14: *5* back-word-extend-selection
429 def test_back_word_extend_selection(self):
430 """Test case for back-word-extend-selection"""
431 before_b = """\
432 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
434 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
436 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
437 """
438 after_b = """\
439 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
441 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
443 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
444 """
445 self.run_test(
446 before_b=before_b,
447 after_b=after_b,
448 before_sel=("3.342", "3.342"),
449 after_sel=("3.332", "3.342"),
450 command_name="back-word-extend-selection",
451 )
452 #@+node:ekr.20201130090918.15: *5* backward-delete-char
453 def test_backward_delete_char(self):
454 """Test case for backward-delete-char"""
455 before_b = """\
456 first line
457 line 1
458 line a
459 line b
460 line c
461 last line
462 """
463 after_b = """\
464 first lie
465 line 1
466 line a
467 line b
468 line c
469 last line
470 """
471 self.run_test(
472 before_b=before_b,
473 after_b=after_b,
474 before_sel=("1.9", "1.9"),
475 after_sel=("1.8", "1.8"),
476 command_name="backward-delete-char",
477 )
478 #@+node:ekr.20201130090918.16: *5* backward-delete-char (middle of line)
479 def test_backward_delete_char__middle_of_line(self):
480 """Test case for backward-delete-char (middle of line)"""
481 before_b = """\
482 first line
483 last line
484 """
485 after_b = """\
486 firstline
487 last line
488 """
489 self.run_test(
490 before_b=before_b,
491 after_b=after_b,
492 before_sel=("1.6", "1.6"),
493 after_sel=("1.5", "1.5"),
494 command_name="backward-delete-char",
495 )
496 #@+node:ekr.20201130090918.17: *5* backward-delete-char (last char)
497 def test_backward_delete_char_last_char(self):
498 """Test case for backward-delete-char (last char)"""
499 before_b = """\
500 first line
501 last line
502 """
503 after_b = """\
504 first line
505 last lin
506 """
507 self.run_test(
508 before_b=before_b,
509 after_b=after_b,
510 before_sel=("2.9", "2.9"),
511 after_sel=("2.8", "2.8"),
512 command_name="backward-delete-char",
513 )
514 #@+node:ekr.20201130090918.18: *5* backward-delete-word (no selection)
515 def test_backward_delete_word_no_selection(self):
516 """Test case for backward-delete-word (no selection)"""
517 before_b = """\
518 aaaa bbbb cccc dddd
519 """
520 after_b = """\
521 aaaa cccc dddd
522 """
523 self.run_test(
524 before_b=before_b,
525 after_b=after_b,
526 before_sel=("1.10", "1.10"),
527 after_sel=("1.5", "1.5"),
528 command_name="backward-delete-word",
529 )
530 #@+node:ekr.20201130090918.19: *5* backward-delete-word (selection)
531 def test_backward_delete_word_selection(self):
532 """Test case for backward-delete-word (selection)"""
533 before_b = """\
534 aaaa bbbb cccc dddd
535 """
536 after_b = """\
537 aaaa bbcc dddd
538 """
539 self.run_test(
540 before_b=before_b,
541 after_b=after_b,
542 before_sel=("1.7", "1.12"),
543 after_sel=("1.7", "1.7"),
544 command_name="backward-delete-word",
545 )
546 #@+node:ekr.20201130090918.20: *5* backward-kill-paragraph
547 def test_backward_kill_paragraph(self):
548 """Test case for backward-kill-paragraph"""
549 before_b = """\
550 Americans live in the most severe weather-prone country on Earth. Each year,
551 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
552 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
553 weather impacts every American. Communities can now rely on the National Weather
554 Service’s StormReady program to help them guard against the ravages of Mother
555 Nature.
557 Some 90% of all presidentially declared disasters are weather related, leading
558 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
559 program started in 1999 in Tulsa, OK, helps arm America's communities with the
560 communication and safety skills needed to save lives and property– before and
561 during the event. StormReady helps community leaders and emergency managers
562 strengthen local safety programs.
564 StormReady communities are better prepared to save lives from the onslaught of
565 severe weather through better planning, education, and awareness. No community
566 is storm proof, but StormReady can help communities save lives. Does StormReady
567 make a difference?
568 """
569 after_b = """\
570 Americans live in the most severe weather-prone country on Earth. Each year,
571 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
572 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
573 weather impacts every American. Communities can now rely on the National Weather
574 Service’s StormReady program to help them guard against the ravages of Mother
575 Nature.
576 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
577 program started in 1999 in Tulsa, OK, helps arm America's communities with the
578 communication and safety skills needed to save lives and property– before and
579 during the event. StormReady helps community leaders and emergency managers
580 strengthen local safety programs.
582 StormReady communities are better prepared to save lives from the onslaught of
583 severe weather through better planning, education, and awareness. No community
584 is storm proof, but StormReady can help communities save lives. Does StormReady
585 make a difference?
586 """
587 self.run_test(
588 before_b=before_b,
589 after_b=after_b,
590 before_sel=("9.0", "9.0"),
591 after_sel=("7.0", "7.0"),
592 command_name="backward-kill-paragraph",
593 )
594 #@+node:ekr.20201130090918.21: *5* backward-kill-sentence
595 def test_backward_kill_sentence(self):
596 """Test case for backward-kill-sentence"""
597 before_b = """\
598 This is the first sentence. This
599 is the second sentence. And
600 this is the last sentence.
601 """
602 after_b = """\
603 This is the first sentence. This
604 is the second sentence.
605 """
606 self.run_test(
607 before_b=before_b,
608 after_b=after_b,
609 before_sel=("3.2", "3.2"),
610 after_sel=("2.23", "2.23"),
611 command_name="backward-kill-sentence",
612 )
613 #@+node:ekr.20201130090918.22: *5* backward-kill-word
614 def test_backward_kill_word(self):
615 """Test case for backward-kill-word"""
616 before_b = """\
617 This is the first sentence. This
618 is the second sentence. And
619 this is the last sentence.
620 """
621 after_b = """\
622 This is the first sentence. This
623 is the second sentence. And
624 this the last sentence.
625 """
626 self.run_test(
627 before_b=before_b,
628 after_b=after_b,
629 before_sel=("3.7", "3.7"),
630 after_sel=("3.5", "3.5"),
631 command_name="backward-kill-word",
632 )
633 #@+node:ekr.20201130090918.23: *5* beginning-of-buffer
634 def test_beginning_of_buffer(self):
635 """Test case for beginning-of-buffer"""
636 before_b = """\
637 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
639 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
641 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
642 """
643 after_b = """\
644 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
646 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
648 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
649 """
650 self.run_test(
651 before_b=before_b,
652 after_b=after_b,
653 before_sel=("5.56", "5.56"),
654 after_sel=("1.0", "1.0"),
655 command_name="beginning-of-buffer",
656 )
657 #@+node:ekr.20201130090918.24: *5* beginning-of-buffer-extend-selection
658 def test_beginning_of_buffer_extend_selection(self):
659 """Test case for beginning-of-buffer-extend-selection"""
660 before_b = """\
661 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
663 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
665 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
666 """
667 after_b = """\
668 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
670 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
672 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
673 """
674 self.run_test(
675 before_b=before_b,
676 after_b=after_b,
677 before_sel=("3.423", "3.423"),
678 after_sel=("1.0", "3.423"),
679 command_name="beginning-of-buffer-extend-selection",
680 )
681 #@+node:ekr.20201130090918.25: *5* beginning-of-line
682 def test_beginning_of_line(self):
683 """Test case for beginning-of-line"""
684 before_b = """\
685 first line
686 line 1
687 line a
688 line b
689 line c
690 last line
691 """
692 after_b = """\
693 first line
694 line 1
695 line a
696 line b
697 line c
698 last line
699 """
700 self.run_test(
701 before_b=before_b,
702 after_b=after_b,
703 before_sel=("3.10", "3.10"),
704 after_sel=("3.0", "3.0"),
705 command_name="beginning-of-line",
706 )
707 #@+node:ekr.20201130090918.26: *5* beginning-of-line-extend-selection
708 def test_beginning_of_line_extend_selection(self):
709 """Test case for beginning-of-line-extend-selection"""
710 before_b = """\
711 first line
712 line 1
713 line a
714 line b
715 line c
716 last line
717 """
718 after_b = """\
719 first line
720 line 1
721 line a
722 line b
723 line c
724 last line
725 """
726 self.run_test(
727 before_b=before_b,
728 after_b=after_b,
729 before_sel=("4.10", "4.10"),
730 after_sel=("4.0", "4.10"),
731 command_name="beginning-of-line-extend-selection",
732 )
733 #@+node:ekr.20210829061337.1: *4* Commands C-E
734 #@+node:ekr.20201130090918.27: *5* capitalize-word
735 def test_capitalize_word(self):
736 """Test case for capitalize-word"""
737 before_b = """\
738 first line
739 line 1
740 line a
741 line b
742 line c
743 last line
744 """
745 after_b = """\
746 first line
747 line 1
748 Line a
749 line b
750 line c
751 last line
752 """
753 self.run_test(
754 before_b=before_b,
755 after_b=after_b,
756 before_sel=("3.6", "3.6"),
757 after_sel=("3.6", "3.6"),
758 command_name="capitalize-word",
759 )
760 #@+node:ekr.20201130090918.28: *5* center-line
761 def test_center_line(self):
762 """Test case for center-line"""
763 before_b = """\
764 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
766 Some 90% of all presidentially declared disasters are weather related,
767 leading to around 500 deaths per year and nearly $14 billion in damage.
768 StormReady, a program started in 1999 in Tulsa, OK,
769 helps arm America's communities with the communication and safety
770 skills needed to save lives and property– before and during the event.
771 StormReady helps community leaders and emergency managers strengthen local safety programs.
773 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
774 """
775 after_b = """\
776 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
778 Some 90% of all presidentially declared disasters are weather related,
779 leading to around 500 deaths per year and nearly $14 billion in damage.
780 StormReady, a program started in 1999 in Tulsa, OK,
781 helps arm America's communities with the communication and safety
782 skills needed to save lives and property– before and during the event.
783 StormReady helps community leaders and emergency managers strengthen local safety programs.
785 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
786 """
787 self.run_test(
788 before_b=before_b,
789 after_b=after_b,
790 before_sel=("3.0", "9.0"),
791 after_sel=("3.0", "9.0"),
792 command_name="center-line",
793 )
794 #@+node:ekr.20201130090918.29: *5* center-region
795 def test_center_region(self):
796 """Test case for center-region"""
797 before_b = """\
798 Some 90% of all presidentially declared disasters are weather related,
799 leading to around 500 deaths per year and nearly $14 billion in damage.
800 StormReady, a program started in 1999 in Tulsa, OK,
801 helps arm America's communities with the communication and safety
802 skills needed to save lives and property– before and during the event.
803 StormReady helps community leaders and emergency managers strengthen local safety programs.
804 """
805 after_b = """\
806 Some 90% of all presidentially declared disasters are weather related,
807 leading to around 500 deaths per year and nearly $14 billion in damage.
808 StormReady, a program started in 1999 in Tulsa, OK,
809 helps arm America's communities with the communication and safety
810 skills needed to save lives and property– before and during the event.
811 StormReady helps community leaders and emergency managers strengthen local safety programs.
812 """
813 self.run_test(
814 before_b=before_b,
815 after_b=after_b,
816 before_sel=("1.0", "7.0"),
817 after_sel=("1.0", "7.0"),
818 command_name="center-region",
819 directives="@pagewidth 70",
820 )
821 #@+node:ekr.20201130090918.30: *5* clean-lines
822 def test_clean_lines(self):
823 """Test case for clean-lines"""
824 before_b = textwrap.dedent("""\
825 # Should remove all trailing whitespace.
827 a = 2
829 b = 3
830 c = 4
831 d = 5
832 e = 6
833 x
834 """)
835 after_b = before_b
836 # Add some trailing ws to before_b
837 i = 1 + before_b.find('3')
838 before_b = before_b[:i] + ' ' + before_b[i:]
839 self.assertNotEqual(before_b, after_b)
840 self.run_test(
841 before_b=before_b,
842 after_b=after_b,
843 before_sel=("1.0", "1.0"),
844 after_sel=("1.0", "1.0"),
845 command_name="clean-lines",
846 )
847 #@+node:ekr.20201130090918.31: *5* clear-selected-text
848 def test_clear_selected_text(self):
849 """Test case for clear-selected-text"""
850 before_b = """\
851 first line
852 line 1
853 line a
854 line b
855 line c
856 last line
857 """
858 after_b = """\
859 first line
860 line line b
861 line c
862 last line
863 """
864 self.run_test(
865 before_b=before_b,
866 after_b=after_b,
867 before_sel=("2.4", "4.4"),
868 after_sel=("2.4", "2.4"),
869 command_name="clear-selected-text",
870 )
871 #@+node:ekr.20201130090918.32: *5* count-region
872 def test_count_region(self):
873 """Test case for count-region"""
874 before_b = """\
875 first line
876 line 1
877 line a
878 line b
879 line c
880 last line
881 """
882 after_b = """\
883 first line
884 line 1
885 line a
886 line b
887 line c
888 last line
889 """
890 self.run_test(
891 before_b=before_b,
892 after_b=after_b,
893 before_sel=("2.4", "4.8"),
894 after_sel=("2.4", "4.8"),
895 command_name="count-region",
896 )
897 #@+node:ekr.20201130090918.33: *5* delete-char
898 def test_delete_char(self):
899 """Test case for delete-char"""
900 before_b = """\
901 first line
902 line 1
903 line a
904 line b
905 line c
906 last line
907 """
908 after_b = """\
909 firstline
910 line 1
911 line a
912 line b
913 line c
914 last line
915 """
916 self.run_test(
917 before_b=before_b,
918 after_b=after_b,
919 before_sel=("1.5", "1.5"),
920 after_sel=("1.5", "1.5"),
921 command_name="delete-char",
922 )
923 #@+node:ekr.20201130090918.34: *5* delete-indentation
924 def test_delete_indentation(self):
925 """Test case for delete-indentation"""
926 before_b = """\
927 first line
928 line 1
929 last line
930 """
931 after_b = """\
932 first line
933 line 1
934 last line
935 """
936 self.run_test(
937 before_b=before_b,
938 after_b=after_b,
939 before_sel=("2.8", "2.8"),
940 after_sel=("2.4", "2.4"),
941 command_name="delete-indentation",
942 )
943 #@+node:ekr.20201130090918.35: *5* delete-spaces
944 def test_delete_spaces(self):
945 """Test case for delete-spaces"""
946 before_b = """\
947 first line
948 line 1
949 line a
950 line b
951 line c
952 last line
953 """
954 after_b = """\
955 first line
956 line 1
957 line a
958 line b
959 line c
960 last line
961 """
962 self.run_test(
963 before_b=before_b,
964 after_b=after_b,
965 before_sel=("3.2", "3.2"),
966 after_sel=("3.0", "3.0"),
967 command_name="delete-spaces",
968 )
969 #@+node:ekr.20201130090918.36: *5* do-nothing
970 def test_do_nothing(self):
971 """Test case for do-nothing"""
972 before_b = """\
973 first line
974 line 1
975 line a
976 line b
977 line c
978 last line
979 """
980 after_b = """\
981 first line
982 line 1
983 line a
984 line b
985 line c
986 last line
987 """
988 self.run_test(
989 before_b=before_b,
990 after_b=after_b,
991 before_sel=("1.0", "1.0"),
992 after_sel=("1.0", "1.0"),
993 command_name="do-nothing",
994 )
995 #@+node:ekr.20201130090918.37: *5* downcase-region
996 def test_downcase_region(self):
997 """Test case for downcase-region"""
998 before_b = """\
999 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1001 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1003 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1004 """
1005 after_b = """\
1006 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1008 some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. stormready, a program started in 1999 in tulsa, ok, helps arm america's communities with the communication and safety skills needed to save lives and property– before and during the event. stormready helps community leaders and emergency managers strengthen local safety programs.
1010 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1011 """
1012 self.run_test(
1013 before_b=before_b,
1014 after_b=after_b,
1015 before_sel=("3.0", "4.0"),
1016 after_sel=("3.0", "4.0"),
1017 command_name="downcase-region",
1018 )
1019 #@+node:ekr.20201130090918.38: *5* downcase-word
1020 def test_downcase_word(self):
1021 """Test case for downcase-word"""
1022 before_b = """\
1023 XYZZY line
1024 line 1
1025 line a
1026 line b
1027 line c
1028 last line
1029 """
1030 after_b = """\
1031 xyzzy line
1032 line 1
1033 line a
1034 line b
1035 line c
1036 last line
1037 """
1038 self.run_test(
1039 before_b=before_b,
1040 after_b=after_b,
1041 before_sel=("1.4", "1.4"),
1042 after_sel=("1.4", "1.4"),
1043 command_name="downcase-word",
1044 )
1045 #@+node:ekr.20201130090918.39: *5* end-of-buffer
1046 def test_end_of_buffer(self):
1047 """Test case for end-of-buffer"""
1048 before_b = """\
1049 first line
1050 line 1
1051 line a
1052 line b
1053 line c
1054 last line
1055 """
1056 after_b = """\
1057 first line
1058 line 1
1059 line a
1060 line b
1061 line c
1062 last line
1063 """
1064 self.run_test(
1065 before_b=before_b,
1066 after_b=after_b,
1067 before_sel=("1.3", "1.3"),
1068 after_sel=("7.0", "7.0"),
1069 command_name="end-of-buffer",
1070 )
1071 #@+node:ekr.20201130090918.40: *5* end-of-buffer-extend-selection
1072 def test_end_of_buffer_extend_selection(self):
1073 """Test case for end-of-buffer-extend-selection"""
1074 before_b = """\
1075 first line
1076 line 1
1077 line a
1078 line b
1079 line c
1080 last line
1081 """
1082 after_b = """\
1083 first line
1084 line 1
1085 line a
1086 line b
1087 line c
1088 last line
1089 """
1090 self.run_test(
1091 before_b=before_b,
1092 after_b=after_b,
1093 before_sel=("1.0", "1.0"),
1094 after_sel=("1.0", "7.0"),
1095 command_name="end-of-buffer-extend-selection",
1096 )
1097 #@+node:ekr.20201130090918.41: *5* end-of-line
1098 def test_end_of_line(self):
1099 """Test case for end-of-line"""
1100 before_b = """\
1101 first line
1102 line 1
1103 line a
1104 line b
1105 line c
1106 last line
1107 """
1108 after_b = """\
1109 first line
1110 line 1
1111 line a
1112 line b
1113 line c
1114 last line
1115 """
1116 self.run_test(
1117 before_b=before_b,
1118 after_b=after_b,
1119 before_sel=("1.0", "1.0"),
1120 after_sel=("1.10", "1.10"),
1121 command_name="end-of-line",
1122 )
1123 #@+node:ekr.20201130090918.44: *5* end-of-line (blank last line)
1124 def test_end_of_line_blank_last_line(self):
1125 """Test case for end-of-line (blank last line)"""
1126 before_b = """\
1127 first line
1128 line 1
1129 line a
1130 line b
1131 line c
1132 last non-blank line
1133 """
1134 after_b = """\
1135 first line
1136 line 1
1137 line a
1138 line b
1139 line c
1140 last non-blank line
1141 """
1142 self.run_test(
1143 before_b=before_b,
1144 after_b=after_b,
1145 before_sel=("7.0", "7.0"),
1146 after_sel=("7.0", "7.0"),
1147 command_name="end-of-line",
1148 )
1149 #@+node:ekr.20201130090918.43: *5* end-of-line (internal blank line)
1150 def test_end_of_line_internal_blank_line(self):
1151 """Test case for end-of-line (internal blank line)"""
1152 before_b = """\
1153 first line
1155 line 1
1156 line a
1157 line b
1158 line c
1159 last line
1160 """
1161 after_b = """\
1162 first line
1164 line 1
1165 line a
1166 line b
1167 line c
1168 last line
1169 """
1170 self.run_test(
1171 before_b=before_b,
1172 after_b=after_b,
1173 before_sel=("2.0", "2.0"),
1174 after_sel=("2.0", "2.0"),
1175 command_name="end-of-line",
1176 )
1177 #@+node:ekr.20201130090918.45: *5* end-of-line (single char last line)
1178 def test_end_of_line_single_char_last_line(self):
1179 """Test case for end-of-line (single char last line)"""
1180 before_b = """\
1181 first line
1182 line 1
1183 line a
1184 line b
1185 line c
1186 last non-blank line
1188 """
1189 after_b = """\
1190 first line
1191 line 1
1192 line a
1193 line b
1194 line c
1195 last non-blank line
1197 """
1198 self.run_test(
1199 before_b=before_b,
1200 after_b=after_b,
1201 before_sel=("7.0", "7.0"),
1202 after_sel=("7.1", "7.1"),
1203 command_name="end-of-line",
1204 )
1205 #@+node:ekr.20201130090918.42: *5* end-of-line 2
1206 def test_end_of_line_2(self):
1207 """Test case for end-of-line 2"""
1208 before_b = """\
1209 first line
1210 line 1
1211 line a
1212 line b
1213 line c
1214 last line
1215 """
1216 after_b = """\
1217 first line
1218 line 1
1219 line a
1220 line b
1221 line c
1222 last line
1223 """
1224 self.run_test(
1225 before_b=before_b,
1226 after_b=after_b,
1227 before_sel=("6.0", "6.0"),
1228 after_sel=("6.9", "6.9"),
1229 command_name="end-of-line",
1230 )
1231 #@+node:ekr.20201130090918.46: *5* end-of-line-extend-selection
1232 def test_end_of_line_extend_selection(self):
1233 """Test case for end-of-line-extend-selection"""
1234 before_b = """\
1235 first line
1236 line 1
1237 line a
1238 line b
1239 line c
1240 last line
1241 """
1242 after_b = """\
1243 first line
1244 line 1
1245 line a
1246 line b
1247 line c
1248 last line
1249 """
1250 self.run_test(
1251 before_b=before_b,
1252 after_b=after_b,
1253 before_sel=("3.0", "3.0"),
1254 after_sel=("3.0", "3.10"),
1255 command_name="end-of-line-extend-selection",
1256 )
1257 #@+node:ekr.20201130090918.47: *5* end-of-line-extend-selection (blank last line)
1258 def test_end_of_line_extend_selection_blank_last_line(self):
1259 """Test case for end-of-line-extend-selection (blank last line)"""
1260 before_b = """\
1261 first line
1262 line 1
1263 line a
1264 line b
1265 line c
1266 last non-blank line
1267 """
1268 after_b = """\
1269 first line
1270 line 1
1271 line a
1272 line b
1273 line c
1274 last non-blank line
1275 """
1276 self.run_test(
1277 before_b=before_b,
1278 after_b=after_b,
1279 before_sel=("7.0", "7.0"),
1280 after_sel=("7.0", "7.0"),
1281 command_name="end-of-line-extend-selection",
1282 )
1283 #@+node:ekr.20201130090918.48: *5* exchange-point-mark
1284 def test_exchange_point_mark(self):
1285 """Test case for exchange-point-mark"""
1286 before_b = """\
1287 first line
1288 line 1
1289 line a
1290 line b
1291 line c
1292 last line
1293 """
1294 after_b = """\
1295 first line
1296 line 1
1297 line a
1298 line b
1299 line c
1300 last line
1301 """
1302 self.run_test(
1303 before_b=before_b,
1304 after_b=after_b,
1305 before_sel=("1.0", "1.10"),
1306 after_sel=("1.0", "1.10"),
1307 command_name="exchange-point-mark",
1308 )
1309 #@+node:ekr.20201130090918.49: *5* extend-to-line
1310 def test_extend_to_line(self):
1311 """Test case for extend-to-line"""
1312 before_b = """\
1313 first line
1314 line 1
1315 line a
1316 line b
1317 line c
1318 last line
1319 """
1320 after_b = """\
1321 first line
1322 line 1
1323 line a
1324 line b
1325 line c
1326 last line
1327 """
1328 self.run_test(
1329 before_b=before_b,
1330 after_b=after_b,
1331 before_sel=("3.3", "3.3"),
1332 after_sel=("3.0", "3.10"),
1333 command_name="extend-to-line",
1334 )
1335 #@+node:ekr.20201130090918.50: *5* extend-to-paragraph
1336 def test_extend_to_paragraph(self):
1337 """Test case for extend-to-paragraph"""
1338 before_b = """\
1339 Americans live in the most severe weather-prone country on Earth. Each year,
1340 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
1341 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
1342 weather impacts every American. Communities can now rely on the National Weather
1343 Service’s StormReady program to help them guard against the ravages of Mother
1344 Nature.
1346 Some 90% of all presidentially declared disasters are weather related, leading
1347 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
1348 program started in 1999 in Tulsa, OK, helps arm America's communities with the
1349 communication and safety skills needed to save lives and property– before and
1350 during the event. StormReady helps community leaders and emergency managers
1351 strengthen local safety programs.
1353 StormReady communities are better prepared to save lives from the onslaught of
1354 severe weather through better planning, education, and awareness. No community
1355 is storm proof, but StormReady can help communities save lives. Does StormReady
1356 make a difference?
1357 """
1358 after_b = """\
1359 Americans live in the most severe weather-prone country on Earth. Each year,
1360 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
1361 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
1362 weather impacts every American. Communities can now rely on the National Weather
1363 Service’s StormReady program to help them guard against the ravages of Mother
1364 Nature.
1366 Some 90% of all presidentially declared disasters are weather related, leading
1367 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
1368 program started in 1999 in Tulsa, OK, helps arm America's communities with the
1369 communication and safety skills needed to save lives and property– before and
1370 during the event. StormReady helps community leaders and emergency managers
1371 strengthen local safety programs.
1373 StormReady communities are better prepared to save lives from the onslaught of
1374 severe weather through better planning, education, and awareness. No community
1375 is storm proof, but StormReady can help communities save lives. Does StormReady
1376 make a difference?
1377 """
1378 self.run_test(
1379 before_b=before_b,
1380 after_b=after_b,
1381 before_sel=("9.0", "9.0"),
1382 after_sel=("8.0", "13.33"),
1383 command_name="extend-to-paragraph",
1384 )
1385 #@+node:ekr.20201130090918.51: *5* extend-to-sentence
1386 def test_extend_to_sentence(self):
1387 """Test case for extend-to-sentence"""
1388 before_b = """\
1389 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1391 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1393 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1394 """
1395 after_b = """\
1396 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1398 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1400 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1401 """
1402 self.run_test(
1403 before_b=before_b,
1404 after_b=after_b,
1405 before_sel=("3.5", "3.5"),
1406 after_sel=("1.395", "3.142"),
1407 command_name="extend-to-sentence",
1408 )
1409 #@+node:ekr.20201130090918.52: *5* extend-to-word
1410 def test_extend_to_word(self):
1411 """Test case for extend-to-word"""
1412 before_b = """\
1413 first line
1414 line 1
1415 line_24a a
1416 line b
1417 line c
1418 last line
1419 """
1420 after_b = """\
1421 first line
1422 line 1
1423 line_24a a
1424 line b
1425 line c
1426 last line
1427 """
1428 self.run_test(
1429 before_b=before_b,
1430 after_b=after_b,
1431 before_sel=("3.10", "3.10"),
1432 after_sel=("3.4", "3.12"),
1433 command_name="extend-to-word",
1434 )
1435 #@+node:ekr.20210829062134.1: *4* Commands F-L
1436 #@+node:ekr.20201130090918.56: *5* fill-paragraph
1437 def test_fill_paragraph(self):
1438 """Test case for fill-paragraph"""
1439 before_b = """\
1440 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Services StormReady program to help them guard against the ravages of Mother Nature.
1442 Some 90% of all presidentially
1443 declared disasters are weather related,
1444 leading to around 500 deaths per year
1445 and nearly $14 billion in damage.
1446 StormReady, a program
1447 started in 1999 in Tulsa, OK,
1448 helps arm America's
1449 communities with the communication and
1450 safety skills needed to save lives and
1451 property--before and during the event.
1452 StormReady helps community leaders and
1453 emergency managers strengthen local safety programs.
1455 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1456 """
1457 after_b = """\
1458 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Services StormReady program to help them guard against the ravages of Mother Nature.
1460 Some 90% of all presidentially declared disasters are weather related, leading
1461 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
1462 program started in 1999 in Tulsa, OK, helps arm America's communities with the
1463 communication and safety skills needed to save lives and property--before and
1464 during the event. StormReady helps community leaders and emergency managers
1465 strengthen local safety programs.
1467 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1468 """
1469 self.run_test(
1470 before_b=before_b,
1471 after_b=after_b,
1472 before_sel=("3.0", "3.7"),
1473 after_sel=("10.0", " 10.0"),
1474 command_name="fill-paragraph",
1475 directives="@pagewidth 80",
1476 )
1477 #@+node:ekr.20201130090918.53: *5* finish-of-line
1478 def test_finish_of_line(self):
1479 """Test case for finish-of-line"""
1480 before_b = """\
1481 first line
1482 line 1
1483 line a
1484 line b
1485 line c
1486 last line
1487 """
1488 after_b = """\
1489 first line
1490 line 1
1491 line a
1492 line b
1493 line c
1494 last line
1495 """
1496 self.run_test(
1497 before_b=before_b,
1498 after_b=after_b,
1499 before_sel=("3.12", "3.12"),
1500 after_sel=("3.9", "3.9"),
1501 command_name="finish-of-line",
1502 )
1503 #@+node:ekr.20201130090918.54: *5* finish-of-line (2)
1504 def test_finish_of_line_2(self):
1505 """Test case for finish-of-line (2)"""
1506 before_b = """\
1507 first line
1508 line 1
1509 line a
1510 line b
1511 line c
1512 last line
1513 """
1514 after_b = """\
1515 first line
1516 line 1
1517 line a
1518 line b
1519 line c
1520 last line
1521 """
1522 self.run_test(
1523 before_b=before_b,
1524 after_b=after_b,
1525 before_sel=("3.1", "3.1"),
1526 after_sel=("3.9", "3.9"),
1527 command_name="finish-of-line",
1528 )
1529 #@+node:ekr.20201130090918.55: *5* finish-of-line-extend-selection
1530 def test_finish_of_line_extend_selection(self):
1531 """Test case for finish-of-line-extend-selection"""
1532 before_b = """\
1533 first line
1534 line 1
1535 line a
1536 line b
1537 line c
1538 last line
1539 """
1540 after_b = """\
1541 first line
1542 line 1
1543 line a
1544 line b
1545 line c
1546 last line
1547 """
1548 self.run_test(
1549 before_b=before_b,
1550 after_b=after_b,
1551 before_sel=("3.1", "3.1"),
1552 after_sel=("3.1", "3.9"),
1553 command_name="finish-of-line-extend-selection",
1554 )
1555 #@+node:ekr.20201130090918.57: *5* forward-char
1556 def test_forward_char(self):
1557 """Test case for forward-char"""
1558 before_b = """\
1559 first line
1560 line 1
1561 line a
1562 line b
1563 line c
1564 last line
1565 """
1566 after_b = """\
1567 first line
1568 line 1
1569 line a
1570 line b
1571 line c
1572 last line
1573 """
1574 self.run_test(
1575 before_b=before_b,
1576 after_b=after_b,
1577 before_sel=("1.2", "1.2"),
1578 after_sel=("1.3", "1.3"),
1579 command_name="forward-char",
1580 )
1581 #@+node:ekr.20201130090918.58: *5* forward-char-extend-selection
1582 def test_forward_char_extend_selection(self):
1583 """Test case for forward-char-extend-selection"""
1584 before_b = """\
1585 first line
1586 line 1
1587 line a
1588 line b
1589 line c
1590 last line
1591 """
1592 after_b = """\
1593 first line
1594 line 1
1595 line a
1596 line b
1597 line c
1598 last line
1599 """
1600 self.run_test(
1601 before_b=before_b,
1602 after_b=after_b,
1603 before_sel=("1.1", "1.1"),
1604 after_sel=("1.1", "1.2"),
1605 command_name="forward-char-extend-selection",
1606 )
1607 #@+node:ekr.20201130090918.59: *5* forward-end-word (end of line)
1608 def test_forward_end_word_end_of_line(self):
1609 """Test case for forward-end-word (end of line)"""
1610 before_b = """\
1611 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1613 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1615 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1616 """
1617 after_b = """\
1618 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1620 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1622 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1623 """
1624 self.run_test(
1625 before_b=before_b,
1626 after_b=after_b,
1627 before_sel=("1.395", "1.395"),
1628 after_sel=("3.4", "3.4"),
1629 command_name="forward-end-word",
1630 )
1631 #@+node:ekr.20201130090918.60: *5* forward-end-word (start of word)
1632 def test_forward_end_word_start_of_word(self):
1633 """Test case for forward-end-word (start of word)"""
1634 before_b = """\
1635 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1637 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1639 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1640 """
1641 after_b = """\
1642 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1644 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1646 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1647 """
1648 self.run_test(
1649 before_b=before_b,
1650 after_b=after_b,
1651 before_sel=("1.310", "1.310"),
1652 after_sel=("1.317", "1.317"),
1653 command_name="forward-end-word",
1654 )
1655 #@+node:ekr.20201130090918.61: *5* forward-end-word-extend-selection
1656 def test_forward_end_word_extend_selection(self):
1657 """Test case for forward-end-word-extend-selection"""
1658 before_b = """\
1659 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1661 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1663 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1664 """
1665 after_b = """\
1666 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1668 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1670 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1671 """
1672 self.run_test(
1673 before_b=before_b,
1674 after_b=after_b,
1675 before_sel=("3.20", "3.20"),
1676 after_sel=("3.20", "3.30"),
1677 command_name="forward-end-word-extend-selection",
1678 )
1679 #@+node:ekr.20201130090918.62: *5* forward-paragraph
1680 def test_forward_paragraph(self):
1681 """Test case for forward-paragraph"""
1682 before_b = """\
1683 Americans live in the most severe weather-prone country on Earth. Each year,
1684 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
1685 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
1686 weather impacts every American. Communities can now rely on the National Weather
1687 Service’s StormReady program to help them guard against the ravages of Mother
1688 Nature.
1690 Some 90% of all presidentially declared disasters are weather related, leading
1691 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
1692 program started in 1999 in Tulsa, OK, helps arm America's communities with the
1693 communication and safety skills needed to save lives and property– before and
1694 during the event. StormReady helps community leaders and emergency managers
1695 strengthen local safety programs.
1697 StormReady communities are better prepared to save lives from the onslaught of
1698 severe weather through better planning, education, and awareness. No community
1699 is storm proof, but StormReady can help communities save lives. Does StormReady
1700 make a difference?
1701 """
1702 after_b = """\
1703 Americans live in the most severe weather-prone country on Earth. Each year,
1704 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
1705 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
1706 weather impacts every American. Communities can now rely on the National Weather
1707 Service’s StormReady program to help them guard against the ravages of Mother
1708 Nature.
1710 Some 90% of all presidentially declared disasters are weather related, leading
1711 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
1712 program started in 1999 in Tulsa, OK, helps arm America's communities with the
1713 communication and safety skills needed to save lives and property– before and
1714 during the event. StormReady helps community leaders and emergency managers
1715 strengthen local safety programs.
1717 StormReady communities are better prepared to save lives from the onslaught of
1718 severe weather through better planning, education, and awareness. No community
1719 is storm proof, but StormReady can help communities save lives. Does StormReady
1720 make a difference?
1721 """
1722 self.run_test(
1723 before_b=before_b,
1724 after_b=after_b,
1725 before_sel=("9.0", "9.0"),
1726 after_sel=("15.0", "15.0"),
1727 command_name="forward-paragraph",
1728 )
1729 #@+node:ekr.20201130090918.63: *5* forward-paragraph-extend-selection
1730 def test_forward_paragraph_extend_selection(self):
1731 """Test case for forward-paragraph-extend-selection"""
1732 before_b = """\
1733 Americans live in the most severe weather-prone country on Earth. Each year,
1734 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
1735 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
1736 weather impacts every American. Communities can now rely on the National Weather
1737 Service’s StormReady program to help them guard against the ravages of Mother
1738 Nature.
1740 Some 90% of all presidentially declared disasters are weather related, leading
1741 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
1742 program started in 1999 in Tulsa, OK, helps arm America's communities with the
1743 communication and safety skills needed to save lives and property– before and
1744 during the event. StormReady helps community leaders and emergency managers
1745 strengthen local safety programs.
1747 StormReady communities are better prepared to save lives from the onslaught of
1748 severe weather through better planning, education, and awareness. No community
1749 is storm proof, but StormReady can help communities save lives. Does StormReady
1750 make a difference?
1751 """
1752 after_b = """\
1753 Americans live in the most severe weather-prone country on Earth. Each year,
1754 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
1755 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
1756 weather impacts every American. Communities can now rely on the National Weather
1757 Service’s StormReady program to help them guard against the ravages of Mother
1758 Nature.
1760 Some 90% of all presidentially declared disasters are weather related, leading
1761 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
1762 program started in 1999 in Tulsa, OK, helps arm America's communities with the
1763 communication and safety skills needed to save lives and property– before and
1764 during the event. StormReady helps community leaders and emergency managers
1765 strengthen local safety programs.
1767 StormReady communities are better prepared to save lives from the onslaught of
1768 severe weather through better planning, education, and awareness. No community
1769 is storm proof, but StormReady can help communities save lives. Does StormReady
1770 make a difference?
1771 """
1772 self.run_test(
1773 before_b=before_b,
1774 after_b=after_b,
1775 before_sel=("10.0", "10.0"),
1776 after_sel=("10.0", "15.0"),
1777 command_name="forward-paragraph-extend-selection",
1778 )
1779 #@+node:ekr.20201130090918.64: *5* forward-sentence
1780 def test_forward_sentence(self):
1781 """Test case for forward-sentence"""
1782 before_b = """\
1783 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1785 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1787 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1788 """
1789 after_b = """\
1790 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1792 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1794 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1795 """
1796 self.run_test(
1797 before_b=before_b,
1798 after_b=after_b,
1799 before_sel=("3.17", "3.17"),
1800 after_sel=("3.142", "3.142"),
1801 command_name="forward-sentence",
1802 )
1803 #@+node:ekr.20201130090918.65: *5* forward-sentence-extend-selection
1804 def test_forward_sentence_extend_selection(self):
1805 """Test case for forward-sentence-extend-selection"""
1806 before_b = """\
1807 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1809 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1811 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1812 """
1813 after_b = """\
1814 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1816 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1818 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1819 """
1820 self.run_test(
1821 before_b=before_b,
1822 after_b=after_b,
1823 before_sel=("1.264", "1.264"),
1824 after_sel=("1.264", "1.395"),
1825 command_name="forward-sentence-extend-selection",
1826 )
1827 #@+node:ekr.20201130090918.66: *5* forward-word
1828 def test_forward_word(self):
1829 """Test case for forward-word"""
1830 before_b = """\
1831 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1833 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1835 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1836 """
1837 after_b = """\
1838 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1840 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1842 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1843 """
1844 self.run_test(
1845 before_b=before_b,
1846 after_b=after_b,
1847 before_sel=("1.261", "1.261"),
1848 after_sel=("1.272", "1.272"),
1849 command_name="forward-word",
1850 )
1851 #@+node:ekr.20201130090918.67: *5* forward-word-extend-selection
1852 def test_forward_word_extend_selection(self):
1853 """Test case for forward-word-extend-selection"""
1854 before_b = """\
1855 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1857 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1859 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1860 """
1861 after_b = """\
1862 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
1864 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
1866 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
1867 """
1868 self.run_test(
1869 before_b=before_b,
1870 after_b=after_b,
1871 before_sel=("1.395", "1.395"),
1872 after_sel=("1.395", "3.4"),
1873 command_name="forward-word-extend-selection",
1874 )
1875 #@+node:ekr.20201130090918.68: *5* indent-relative
1876 def test_indent_relative(self):
1877 """Test case for indent-relative"""
1878 before_b = """\
1879 first line
1880 line 1
1881 line a
1882 line b
1883 line c
1884 last line
1885 """
1886 after_b = """\
1887 first line
1888 line 1
1889 line a
1890 line b
1891 line c
1892 last line
1893 """
1894 self.run_test(
1895 before_b=before_b,
1896 after_b=after_b,
1897 before_sel=("5.0", "5.0"),
1898 after_sel=("5.8", "5.8"),
1899 command_name="indent-relative",
1900 )
1901 #@+node:ekr.20201130090918.69: *5* indent-rigidly
1902 def test_indent_rigidly(self):
1903 """Test case for indent-rigidly"""
1904 before_b = """\
1905 first line
1906 line 1
1907 line a
1908 line b
1909 line c
1910 last line
1911 """
1912 after_b = """\
1913 first line
1914 line 1
1915 line a
1916 line b
1917 line c
1918 last line
1919 """
1920 self.run_test(
1921 before_b=before_b,
1922 after_b=after_b,
1923 before_sel=("2.0", "5.0"),
1924 after_sel=("2.0", "5.1"),
1925 command_name="indent-rigidly",
1926 )
1927 #@+node:ekr.20201130090918.70: *5* indent-to-comment-column
1928 def test_indent_to_comment_column(self):
1929 """Test case for indent-to-comment-column"""
1930 before_b = """\
1931 first line
1932 line b
1933 last line
1934 """
1935 after_b = """\
1936 first line
1937 line b
1938 last line
1939 """
1940 self.c.editCommands.ccolumn = 4 # Set the comment column
1941 self.run_test(
1942 before_b=before_b,
1943 after_b=after_b,
1944 before_sel=("2.0", "2.0"),
1945 after_sel=("2.4", "2.4"),
1946 command_name="indent-to-comment-column",
1947 )
1948 #@+node:ekr.20201130090918.71: *5* insert-newline
1949 def test_insert_newline(self):
1950 """Test case for insert-newline"""
1951 before_b = """\
1952 first line
1953 line 1
1954 line a
1955 line b
1956 line c
1957 last line
1958 """
1959 after_b = """\
1960 first li
1961 ne
1962 line 1
1963 line a
1964 line b
1965 line c
1966 last line
1967 """
1968 self.run_test(
1969 before_b=before_b,
1970 after_b=after_b,
1971 before_sel=("1.8", "1.8"),
1972 after_sel=("2.0", "2.0"),
1973 command_name="insert-newline",
1974 )
1975 #@+node:ekr.20210926144000.1: *5* insert-newline-bug-2230
1976 def test_insert_newline_bug_2230(self):
1977 """Test case for insert-newline"""
1978 before_b = textwrap.dedent("""\
1979 #@@language python
1980 def spam():
1981 if 1: # test
1982 # after line
1983 """)
1984 # There are 8 spaces in the line after "if 1:..."
1985 after_b = textwrap.dedent("""\
1986 #@@language python
1987 def spam():
1988 if 1: # test
1990 # after line
1991 """)
1992 self.run_test(
1993 before_b=before_b,
1994 after_b=after_b,
1995 before_sel=("3.18", "3.18"),
1996 after_sel=("4.8", "4.8"),
1997 command_name="insert-newline",
1998 )
1999 #@+node:ekr.20201130090918.72: *5* insert-parentheses
2000 def test_insert_parentheses(self):
2001 """Test case for insert-parentheses"""
2002 before_b = """\
2003 first line
2004 line 1
2005 line a
2006 line b
2007 line c
2008 last line
2009 """
2010 after_b = """\
2011 first() line
2012 line 1
2013 line a
2014 line b
2015 line c
2016 last line
2017 """
2018 self.run_test(
2019 before_b=before_b,
2020 after_b=after_b,
2021 before_sel=("1.5", "1.5"),
2022 after_sel=("1.6", "1.6"),
2023 command_name="insert-parentheses",
2024 )
2025 #@+node:ekr.20201130090918.76: *5* kill-line end-body-text
2026 def test_kill_line_end_body_text(self):
2027 """Test case for kill-line end-body-text"""
2028 before_b = """\
2029 line 1
2030 line 2
2031 line 3
2032 """
2033 after_b = """\
2034 line 1
2035 line 2
2036 line 3"""
2037 self.run_test(
2038 before_b=before_b,
2039 after_b=after_b,
2040 before_sel=("4.1", "4.1"),
2041 after_sel=("3.6", "3.6"),
2042 command_name="kill-line",
2043 )
2044 #@+node:ekr.20201130090918.77: *5* kill-line end-line-text
2045 def test_kill_line_end_line_text(self):
2046 """Test case for kill-line end-line-text"""
2047 before_b = """\
2048 line 1
2049 line 2
2050 line 3
2051 """
2052 after_b = """\
2053 line 1
2054 line 2
2056 """
2057 self.run_test(
2058 before_b=before_b,
2059 after_b=after_b,
2060 before_sel=("3.5", "3.5"),
2061 after_sel=("3.0", "3.0"),
2062 command_name="kill-line",
2063 )
2064 #@+node:ekr.20201130090918.79: *5* kill-line start-blank-line
2065 def test_kill_line_start_blank_line(self):
2066 """Test case for kill-line start-blank-line"""
2067 before_b = """\
2068 line 1
2069 line 2
2071 line 4
2072 """
2073 after_b = """\
2074 line 1
2075 line 2
2076 line 4
2077 """
2078 self.run_test(
2079 before_b=before_b,
2080 after_b=after_b,
2081 before_sel=("3.0", "3.0"),
2082 after_sel=("3.0", "3.0"),
2083 command_name="kill-line",
2084 )
2085 #@+node:ekr.20201130090918.78: *5* kill-line start-line
2086 def test_kill_line_start_line(self):
2087 """Test case for kill-line start-line"""
2088 before_b = """\
2089 line 1
2090 line 2
2091 line 3
2092 line 4
2093 """
2094 after_b = """\
2095 line 1
2096 line 2
2098 line 4
2099 """
2100 self.run_test(
2101 before_b=before_b,
2102 after_b=after_b,
2103 before_sel=("3.0", "3.0"),
2104 after_sel=("3.0", "3.0"),
2105 command_name="kill-line",
2106 )
2107 #@+node:ekr.20201130090918.73: *5* kill-paragraph
2108 def test_kill_paragraph(self):
2109 """Test case for kill-paragraph"""
2110 before_b = """\
2111 Americans live in the most severe weather-prone country on Earth. Each year,
2112 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
2113 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
2114 weather impacts every American. Communities can now rely on the National Weather
2115 Service’s StormReady program to help them guard against the ravages of Mother
2116 Nature.
2118 Some 90% of all presidentially declared disasters are weather related, leading
2119 to around 500 deaths per year and nearly $14 billion in damage. StormReady, a
2120 program started in 1999 in Tulsa, OK, helps arm America's communities with the
2121 communication and safety skills needed to save lives and property– before and
2122 during the event. StormReady helps community leaders and emergency managers
2123 strengthen local safety programs.
2125 StormReady communities are better prepared to save lives from the onslaught of
2126 severe weather through better planning, education, and awareness. No community
2127 is storm proof, but StormReady can help communities save lives. Does StormReady
2128 make a difference?
2129 """
2130 after_b = """\
2131 Americans live in the most severe weather-prone country on Earth. Each year,
2132 Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000
2133 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly
2134 weather impacts every American. Communities can now rely on the National Weather
2135 Service’s StormReady program to help them guard against the ravages of Mother
2136 Nature.
2140 StormReady communities are better prepared to save lives from the onslaught of
2141 severe weather through better planning, education, and awareness. No community
2142 is storm proof, but StormReady can help communities save lives. Does StormReady
2143 make a difference?
2144 """
2145 self.run_test(
2146 before_b=before_b,
2147 after_b=after_b,
2148 before_sel=("9.0", "9.0"),
2149 after_sel=("8.0", "8.0"),
2150 command_name="kill-paragraph",
2151 )
2152 #@+node:ekr.20201130090918.74: *5* kill-sentence
2153 def test_kill_sentence(self):
2154 """Test case for kill-sentence"""
2155 before_b = """\
2156 This is the first sentence. This
2157 is the second sentence. And
2158 this is the last sentence.
2159 """
2160 after_b = """\
2161 This is the first sentence. And
2162 this is the last sentence.
2163 """
2164 self.run_test(
2165 before_b=before_b,
2166 after_b=after_b,
2167 before_sel=("2.2", "2.2"),
2168 after_sel=("1.27", "1.27"),
2169 command_name="kill-sentence",
2170 )
2171 #@+node:ekr.20201130090918.82: *5* kill-to-end-of-line after last visible char
2172 def test_kill_to_end_of_line_after_last_visible_char(self):
2173 """Test case for kill-to-end-of-line after last visible char"""
2174 before_b = """\
2175 line 1
2176 # The next line contains two trailing blanks.
2177 line 3
2178 line 4
2179 """
2180 after_b = """\
2181 line 1
2182 # The next line contains two trailing blanks.
2183 line 3line 4
2184 """
2185 self.run_test(
2186 before_b=before_b,
2187 after_b=after_b,
2188 before_sel=("3.6", "3.6"),
2189 after_sel=("3.6", "3.6"),
2190 command_name="kill-to-end-of-line",
2191 )
2192 #@+node:ekr.20201130090918.80: *5* kill-to-end-of-line end-body-text
2193 def test_kill_to_end_of_line_end_body_text(self):
2194 """Test case for kill-to-end-of-line end-body-text"""
2195 before_b = """\
2196 line 1
2197 line 2
2198 line 3
2199 """
2200 after_b = """\
2201 line 1
2202 line 2
2203 line 3"""
2204 self.run_test(
2205 before_b=before_b,
2206 after_b=after_b,
2207 before_sel=("4.1", "4.1"),
2208 after_sel=("3.6", "3.6"),
2209 command_name="kill-to-end-of-line",
2210 )
2211 #@+node:ekr.20201130090918.81: *5* kill-to-end-of-line end-line
2212 def test_kill_to_end_of_line_end_line(self):
2213 """Test case for kill-to-end-of-line end-line"""
2214 before_b = """\
2215 line 1
2216 line 2
2217 line 3
2218 """
2219 after_b = """\
2220 line 1
2221 line 2line 3
2222 """
2223 self.run_test(
2224 before_b=before_b,
2225 after_b=after_b,
2226 before_sel=("2.6", "2.6"),
2227 after_sel=("2.6", "2.6"),
2228 command_name="kill-to-end-of-line",
2229 )
2230 #@+node:ekr.20201130090918.85: *5* kill-to-end-of-line middle-line
2231 def test_kill_to_end_of_line_middle_line(self):
2232 """Test case for kill-to-end-of-line middle-line"""
2233 before_b = """\
2234 line 1
2235 line 2
2236 line 3
2237 """
2238 after_b = """\
2239 line 1
2240 li
2241 line 3
2242 """
2243 self.run_test(
2244 before_b=before_b,
2245 after_b=after_b,
2246 before_sel=("2.2", "2.2"),
2247 after_sel=("2.2", "2.2"),
2248 command_name="kill-to-end-of-line",
2249 )
2250 #@+node:ekr.20201130090918.84: *5* kill-to-end-of-line start-blank-line
2251 def test_kill_to_end_of_line_start_blank_line(self):
2252 """Test case for kill-to-end-of-line start-blank-line"""
2253 before_b = """\
2254 line 1
2255 line 2
2257 line 4
2258 """
2259 after_b = """\
2260 line 1
2261 line 2
2262 line 4
2263 """
2264 self.run_test(
2265 before_b=before_b,
2266 after_b=after_b,
2267 before_sel=("3.0", "3.0"),
2268 after_sel=("3.0", "3.0"),
2269 command_name="kill-to-end-of-line",
2270 )
2271 #@+node:ekr.20201130090918.83: *5* kill-to-end-of-line start-line
2272 def test_kill_to_end_of_line_start_line(self):
2273 """Test case for kill-to-end-of-line start-line"""
2274 before_b = """\
2275 line 1
2276 line 2
2277 line 3
2278 line 4
2279 """
2280 after_b = """\
2281 line 1
2282 line 2
2284 line 4
2285 """
2286 self.run_test(
2287 before_b=before_b,
2288 after_b=after_b,
2289 before_sel=("3.0", "3.0"),
2290 after_sel=("3.0", "3.0"),
2291 command_name="kill-to-end-of-line",
2292 )
2293 #@+node:ekr.20201130090918.75: *5* kill-word
2294 def test_kill_word(self):
2295 """Test case for kill-word"""
2296 before_b = """\
2297 This is the first sentence. This
2298 is the second sentence. And
2299 this is the last sentence.
2300 """
2301 after_b = """\
2302 This is the first sentence. This
2303 is the sentence. And
2304 this is the last sentence.
2305 """
2306 self.run_test(
2307 before_b=before_b,
2308 after_b=after_b,
2309 before_sel=("2.6", "2.6"),
2310 after_sel=("2.7", "2.7"),
2311 command_name="kill-word",
2312 )
2313 #@+node:ekr.20210829062149.1: *4* Commands M-R
2314 #@+node:ekr.20201130090918.86: *5* move-lines-down
2315 def test_move_lines_down(self):
2316 """Test case for move-lines-down"""
2317 before_b = """\
2318 first line
2319 line 1
2320 line a
2321 line b
2322 line c
2323 last line
2324 """
2325 after_b = """\
2326 first line
2327 line 1
2328 line c
2329 line a
2330 line b
2331 last line
2332 """
2333 self.run_test(
2334 before_b=before_b,
2335 after_b=after_b,
2336 before_sel=("3.3", "4.3"),
2337 after_sel=("4.3", "5.3"),
2338 command_name="move-lines-down",
2339 )
2340 #@+node:ekr.20201130090918.87: *5* move-lines-up
2341 def test_move_lines_up(self):
2342 """Test case for move-lines-up"""
2343 before_b = """\
2344 first line
2345 line 1
2346 line a
2347 line b
2348 line c
2349 last line
2350 """
2351 after_b = """\
2352 line 1
2353 first line
2354 line a
2355 line b
2356 line c
2357 last line
2358 """
2359 self.run_test(
2360 before_b=before_b,
2361 after_b=after_b,
2362 before_sel=("2.2", "2.2"),
2363 after_sel=("1.2", "1.2"),
2364 command_name="move-lines-up",
2365 )
2366 #@+node:ekr.20201130090918.88: *5* move-lines-up (into docstring)
2367 def test_move_lines_up_into_docstring(self):
2368 """Test case for move-lines-up (into docstring)"""
2369 before_b = '''\
2370 #@@language python
2371 def test():
2372 """ a
2373 b
2374 c
2375 """
2376 print 1
2378 print 2
2379 '''
2380 after_b = '''\
2381 #@@language python
2382 def test():
2383 """ a
2384 b
2385 c
2386 print 1
2387 """
2389 print 2
2390 '''
2391 self.run_test(
2392 before_b=before_b,
2393 after_b=after_b,
2394 before_sel=("7.1", "7.1"),
2395 after_sel=("6.1", "6.1"),
2396 command_name="move-lines-up",
2397 )
2398 #@+node:ekr.20201130090918.89: *5* move-past-close
2399 def test_move_past_close(self):
2400 """Test case for move-past-close"""
2401 before_b = """\
2402 first (line)
2403 line 1
2404 line a
2405 line b
2406 line c
2407 last line
2408 """
2409 after_b = """\
2410 first (line)
2411 line 1
2412 line a
2413 line b
2414 line c
2415 last line
2416 """
2417 self.run_test(
2418 before_b=before_b,
2419 after_b=after_b,
2420 before_sel=("1.10", "1.10"),
2421 after_sel=("1.12", "1.12"),
2422 command_name="move-past-close",
2423 )
2424 #@+node:ekr.20201130090918.90: *5* move-past-close-extend-selection
2425 def test_move_past_close_extend_selection(self):
2426 """Test case for move-past-close-extend-selection"""
2427 before_b = """\
2428 first line
2429 line 1
2430 (line )a
2431 line b
2432 line c
2433 last line
2434 """
2435 after_b = """\
2436 first line
2437 line 1
2438 (line )a
2439 line b
2440 line c
2441 last line
2442 """
2443 self.run_test(
2444 before_b=before_b,
2445 after_b=after_b,
2446 before_sel=("3.7", "3.7"),
2447 after_sel=("3.7", "3.11"),
2448 command_name="move-past-close-extend-selection",
2449 )
2450 #@+node:ekr.20201130090918.91: *5* newline-and-indent
2451 def test_newline_and_indent(self):
2452 """Test case for newline-and-indent"""
2453 before_b = textwrap.dedent("""\
2454 first line
2455 line 1
2456 line a
2457 line b
2458 line c
2459 last line
2460 """)
2461 # docstrings strip blank lines, so we can't use a doctring here!
2462 after_b = ''.join([
2463 'first line\n'
2464 'line 1\n'
2465 ' \n', # Would be stripped in a docstring!
2466 ' line a\n'
2467 ' line b\n'
2468 'line c\n'
2469 'last line\n'
2470 ])
2471 self.run_test(
2472 before_b=before_b,
2473 after_b=after_b,
2474 before_sel=("2.6", "2.6"),
2475 after_sel=("3.4", "3.4"),
2476 command_name="newline-and-indent",
2477 dedent=False
2478 )
2479 #@+node:ekr.20201130090918.92: *5* next-line
2480 def test_next_line(self):
2481 """Test case for next-line"""
2482 before_b = """\
2483 a
2485 b
2486 """
2487 after_b = """\
2488 a
2490 b
2491 """
2492 self.run_test(
2493 before_b=before_b,
2494 after_b=after_b,
2495 before_sel=("1.1", "1.1"),
2496 after_sel=("2.0", "2.0"),
2497 command_name="next-line",
2498 )
2499 #@+node:ekr.20201130090918.93: *5* previous-line
2500 def test_previous_line(self):
2501 """Test case for previous-line"""
2502 before_b = """\
2503 a
2505 b
2506 """
2507 after_b = """\
2508 a
2510 b
2511 """
2512 self.run_test(
2513 before_b=before_b,
2514 after_b=after_b,
2515 before_sel=("3.0", "3.0"),
2516 after_sel=("2.0", "2.0"),
2517 command_name="previous-line",
2518 )
2519 #@+node:ekr.20201130090918.94: *5* rectangle-clear
2520 def test_rectangle_clear(self):
2521 """Test case for rectangle-clear"""
2522 before_b = """\
2523 before
2524 aaaxxxbbb
2525 aaaxxxbbb
2526 aaaxxxbbb
2527 aaaxxxbbb
2528 after
2529 """
2530 after_b = """\
2531 before
2532 aaa bbb
2533 aaa bbb
2534 aaa bbb
2535 aaa bbb
2536 after
2537 """
2538 self.run_test(
2539 before_b=before_b,
2540 after_b=after_b,
2541 before_sel=("2.3", "5.6"),
2542 after_sel=("2.3", "5.6"),
2543 command_name="rectangle-clear",
2544 )
2545 #@+node:ekr.20201130090918.95: *5* rectangle-close
2546 def test_rectangle_close(self):
2547 """Test case for rectangle-close"""
2548 before_b = """\
2549 before
2550 aaa bbb
2551 aaa bbb
2552 aaa bbb
2553 aaa bbb
2554 after
2555 """
2556 after_b = """\
2557 before
2558 aaabbb
2559 aaabbb
2560 aaabbb
2561 aaabbb
2562 after
2563 """
2564 self.run_test(
2565 before_b=before_b,
2566 after_b=after_b,
2567 before_sel=("2.3", "5.6"),
2568 after_sel=("2.3", "5.3"),
2569 command_name="rectangle-close",
2570 )
2571 #@+node:ekr.20201130090918.96: *5* rectangle-delete
2572 def test_rectangle_delete(self):
2573 """Test case for rectangle-delete"""
2574 before_b = """\
2575 before
2576 aaaxxxbbb
2577 aaaxxxbbb
2578 aaaxxxbbb
2579 aaaxxxbbb
2580 after
2581 """
2582 after_b = """\
2583 before
2584 aaabbb
2585 aaabbb
2586 aaabbb
2587 aaabbb
2588 after
2589 """
2590 self.run_test(
2591 before_b=before_b,
2592 after_b=after_b,
2593 before_sel=("2.3", "5.6"),
2594 after_sel=("2.3", "5.3"),
2595 command_name="rectangle-delete",
2596 )
2597 #@+node:ekr.20201130090918.97: *5* rectangle-kill
2598 def test_rectangle_kill(self):
2599 """Test case for rectangle-kill"""
2600 before_b = """\
2601 before
2602 aaaxxxbbb
2603 aaaxxxbbb
2604 aaaxxxbbb
2605 aaaxxxbbb
2606 after
2607 """
2608 after_b = """\
2609 before
2610 aaabbb
2611 aaabbb
2612 aaabbb
2613 aaabbb
2614 after
2615 """
2616 self.run_test(
2617 before_b=before_b,
2618 after_b=after_b,
2619 before_sel=("2.3", "5.6"),
2620 after_sel=("5.3", "5.3"),
2621 command_name="rectangle-kill",
2622 )
2623 #@+node:ekr.20201130090918.98: *5* rectangle-open
2624 def test_rectangle_open(self):
2625 """Test case for rectangle-open"""
2626 before_b = """\
2627 before
2628 aaaxxxbbb
2629 aaaxxxbbb
2630 aaaxxxbbb
2631 aaaxxxbbb
2632 after
2633 """
2634 after_b = """\
2635 before
2636 aaa xxxbbb
2637 aaa xxxbbb
2638 aaa xxxbbb
2639 aaa xxxbbb
2640 after
2641 """
2642 self.run_test(
2643 before_b=before_b,
2644 after_b=after_b,
2645 before_sel=("2.3", "5.6"),
2646 after_sel=("2.3", "5.6"),
2647 command_name="rectangle-open",
2648 )
2649 #@+node:ekr.20201130090918.99: *5* test_rectangle-string
2650 def test_rectangle_string(self):
2651 """Test case for rectangle-string"""
2652 before_b = textwrap.dedent("""\
2653 before
2654 aaaxxxbbb
2655 aaaxxxbbb
2656 aaaxxxbbb
2657 aaaxxxbbb
2658 after
2659 """)
2660 after_b = textwrap.dedent("""\
2661 before
2662 aaas...sbbb
2663 aaas...sbbb
2664 aaas...sbbb
2665 aaas...sbbb
2666 after
2667 """)
2668 # A hack. The command tests for g.unitTesting!
2669 self.run_test(
2670 before_b=before_b,
2671 after_b=after_b,
2672 before_sel=("2.3", "5.6"),
2673 after_sel=("2.3", "5.8"),
2674 command_name="rectangle-string",
2675 )
2676 #@+node:ekr.20201130090918.100: *5* test_rectangle-yank
2677 def test_rectangle_yank(self):
2678 """Test case for rectangle-yank"""
2679 before_b = textwrap.dedent("""\
2680 before
2681 aaaxxxbbb
2682 aaaxxxbbb
2683 aaaxxxbbb
2684 aaaxxxbbb
2685 after
2686 """)
2687 after_b = textwrap.dedent("""\
2688 before
2689 aaaY1Ybbb
2690 aaaY2Ybbb
2691 aaaY3Ybbb
2692 aaaY4Ybbb
2693 after
2694 """)
2695 # A hack. The command tests for g.unitTesting!
2696 self.run_test(
2697 before_b=before_b,
2698 after_b=after_b,
2699 before_sel=("2.3", "5.6"),
2700 after_sel=("2.3", "5.6"),
2701 command_name="rectangle-yank",
2702 )
2704 #@+node:ekr.20201130090918.122: *5* reformat-paragraph list 1 of 5
2705 def test_reformat_paragraph_list_1_of_5(self):
2706 """Test case for reformat-paragraph list 1 of 5"""
2707 before_b = """\
2708 This paragraph leads of this test. It is the "lead"
2709 paragraph.
2711 1. This is item
2712 number 1. It is the first item in the list.
2714 2. This is item
2715 number 2. It is the second item in the list.
2717 3. This is item
2718 number 3. It is the third item in the list.
2720 This paragraph ends the test. It is the "final"
2721 paragraph.
2722 """
2723 after_b = """\
2724 This paragraph leads of this test. It is
2725 the "lead" paragraph.
2727 1. This is item
2728 number 1. It is the first item in the list.
2730 2. This is item
2731 number 2. It is the second item in the list.
2733 3. This is item
2734 number 3. It is the third item in the list.
2736 This paragraph ends the test. It is the "final"
2737 paragraph.
2738 """
2739 self.run_test(
2740 before_b=before_b,
2741 after_b=after_b,
2742 before_sel=("1.0", "1.0"),
2743 after_sel=("4.0", "4.0"),
2744 command_name="reformat-paragraph",
2745 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2746 )
2747 #@+node:ekr.20201130090918.123: *5* reformat-paragraph list 2 of 5
2748 def test_reformat_paragraph_list_2_of_5(self):
2749 """Test case for reformat-paragraph list 2 of 5"""
2750 before_b = """\
2751 This paragraph leads of this test. It is
2752 the "lead" paragraph.
2754 1. This is item number 1. It is the
2755 first item in the list.
2757 2. This is item
2758 number 2. It is the second item in the list.
2760 3. This is item
2761 number 3. It is the third item in the list.
2763 This paragraph ends the test. It is the "final"
2764 paragraph.
2765 """
2766 after_b = """\
2767 This paragraph leads of this test. It is
2768 the "lead" paragraph.
2770 1. This is item number 1. It is the
2771 first item in the list.
2773 2. This is item
2774 number 2. It is the second item in the list.
2776 3. This is item
2777 number 3. It is the third item in the list.
2779 This paragraph ends the test. It is the "final"
2780 paragraph.
2781 """
2782 self.run_test(
2783 before_b=before_b,
2784 after_b=after_b,
2785 before_sel=("4.0", "4.0"),
2786 after_sel=("7.0", "7.0"),
2787 command_name="reformat-paragraph",
2788 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2789 )
2790 #@+node:ekr.20201130090918.124: *5* reformat-paragraph list 3 of 5
2791 def test_reformat_paragraph_list_3_of_5(self):
2792 """Test case for reformat-paragraph list 3 of 5"""
2793 before_b = """\
2794 This paragraph leads of this test. It is
2795 the "lead" paragraph.
2797 1. This is item number 1. It is the
2798 first item in the list.
2800 2. This is item
2801 number 2. It is the second item in the list.
2803 3. This is item
2804 number 3. It is the third item in the list.
2806 This paragraph ends the test. It is the "final"
2807 paragraph.
2808 """
2809 after_b = """\
2810 This paragraph leads of this test. It is
2811 the "lead" paragraph.
2813 1. This is item number 1. It is the
2814 first item in the list.
2816 2. This is item number 2. It is the
2817 second item in the list.
2819 3. This is item
2820 number 3. It is the third item in the list.
2822 This paragraph ends the test. It is the "final"
2823 paragraph.
2824 """
2825 self.run_test(
2826 before_b=before_b,
2827 after_b=after_b,
2828 before_sel=("7.0", "7.0"),
2829 after_sel=("10.0", "10.0"),
2830 command_name="reformat-paragraph",
2831 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2832 )
2833 #@+node:ekr.20201130090918.125: *5* reformat-paragraph list 4 of 5
2834 def test_reformat_paragraph_list_4_of_5(self):
2835 """Test case for reformat-paragraph list 4 of 5"""
2836 before_b = """\
2837 This paragraph leads of this test. It is
2838 the "lead" paragraph.
2840 1. This is item number 1. It is the
2841 first item in the list.
2843 2. This is item number 2. It is the
2844 second item in the list.
2846 3. This is item
2847 number 3. It is the third item in the list.
2849 This paragraph ends the test. It is the "final"
2850 paragraph.
2851 """
2852 after_b = """\
2853 This paragraph leads of this test. It is
2854 the "lead" paragraph.
2856 1. This is item number 1. It is the
2857 first item in the list.
2859 2. This is item number 2. It is the
2860 second item in the list.
2862 3. This is item number 3. It is the
2863 third item in the list.
2865 This paragraph ends the test. It is the "final"
2866 paragraph.
2867 """
2868 self.run_test(
2869 before_b=before_b,
2870 after_b=after_b,
2871 before_sel=("10.0", "10.0"),
2872 after_sel=("13.0", "13.0"),
2873 command_name="reformat-paragraph",
2874 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2875 )
2876 #@+node:ekr.20201130090918.126: *5* reformat-paragraph list 5 of 5
2877 def test_reformat_paragraph_list_5_of_5(self):
2878 """Test case for reformat-paragraph list 5 of 5"""
2879 before_b = """\
2880 This paragraph leads of this test. It is
2881 the "lead" paragraph.
2883 1. This is item number 1. It is the
2884 first item in the list.
2886 2. This is item number 2. It is the
2887 second item in the list.
2889 3. This is item number 3. It is the
2890 third item in the list.
2892 This paragraph ends the test. It is the "final"
2893 paragraph.
2894 """
2895 after_b = """\
2896 This paragraph leads of this test. It is
2897 the "lead" paragraph.
2899 1. This is item number 1. It is the
2900 first item in the list.
2902 2. This is item number 2. It is the
2903 second item in the list.
2905 3. This is item number 3. It is the
2906 third item in the list.
2908 This paragraph ends the test. It is the
2909 "final" paragraph.
2910 """
2911 self.run_test(
2912 before_b=before_b,
2913 after_b=after_b,
2914 before_sel=("13.0", "13.0"),
2915 after_sel=("15.1", "15.1"),
2916 command_name="reformat-paragraph",
2917 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2918 )
2919 #@+node:ekr.20201130090918.127: *5* reformat-paragraph new code 1 of 8
2920 def test_reformat_paragraph_new_code_1_of_8(self):
2921 """Test case for reformat-paragraph new code 1 of 8"""
2922 before_b = """\
2923 #@@pagewidth 40
2924 '''
2925 docstring.
2926 '''
2927 """
2928 after_b = """\
2929 #@@pagewidth 40
2930 '''
2931 docstring.
2932 '''
2933 """
2934 self.run_test(
2935 before_b=before_b,
2936 after_b=after_b,
2937 before_sel=("1.0", "1.0"),
2938 after_sel=("2.0", "2.0"),
2939 command_name="reformat-paragraph",
2940 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2941 )
2942 #@+node:ekr.20201130090918.128: *5* reformat-paragraph new code 2 of 8
2943 def test_reformat_paragraph_new_code_2_of_8(self):
2944 """Test case for reformat-paragraph new code 2 of 8"""
2945 before_b = """\
2946 #@@pagewidth 40
2947 '''
2948 docstring.
2949 '''
2950 """
2951 after_b = """\
2952 #@@pagewidth 40
2953 '''
2954 docstring.
2955 '''
2956 """
2957 self.run_test(
2958 before_b=before_b,
2959 after_b=after_b,
2960 before_sel=("2.0", "2.0"),
2961 after_sel=("3.0", "3.0"),
2962 command_name="reformat-paragraph",
2963 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2964 )
2965 #@+node:ekr.20201130090918.129: *5* reformat-paragraph new code 3 of 8
2966 def test_reformat_paragraph_new_code_3_of_8(self):
2967 """Test case for reformat-paragraph new code 3 of 8"""
2968 before_b = """\
2969 #@@pagewidth 40
2970 '''
2971 docstring.
2972 more docstring.
2973 '''
2974 """
2975 after_b = """\
2976 #@@pagewidth 40
2977 '''
2978 docstring. more docstring.
2979 '''
2980 """
2981 self.run_test(
2982 before_b=before_b,
2983 after_b=after_b,
2984 before_sel=("3.1", "4.1"),
2985 after_sel=("4.0", "4.0"),
2986 command_name="reformat-paragraph",
2987 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
2988 )
2989 #@+node:ekr.20201130090918.130: *5* reformat-paragraph new code 4 of 8
2990 def test_reformat_paragraph_new_code_4_of_8(self):
2991 """Test case for reformat-paragraph new code 4 of 8"""
2992 before_b = """\
2993 - Point 1. xxxxxxxxxxxxxxxxxxxxxxxxxxxx
2994 Line 11.
2995 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx
2996 """
2997 after_b = """\
2998 - Point 1. xxxxxxxxxxxxxxxxxxxxxxxxxxxx
2999 Line 11.
3000 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3001 """
3002 self.run_test(
3003 before_b=before_b,
3004 after_b=after_b,
3005 before_sel=("1.0", "1.0"),
3006 after_sel=("3.0", "3.0"),
3007 command_name="reformat-paragraph",
3008 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3009 )
3010 #@+node:ekr.20201130090918.131: *5* reformat-paragraph new code 5 of 8
3011 def test_reformat_paragraph_new_code_5_of_8(self):
3012 """Test case for reformat-paragraph new code 5 of 8"""
3013 before_b = """\
3014 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3015 Line 22.
3016 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3017 """
3018 after_b = """\
3019 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3020 Line 22.
3021 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3022 """
3023 self.run_test(
3024 before_b=before_b,
3025 after_b=after_b,
3026 before_sel=("1.0", "2.0"),
3027 after_sel=("3.0", "3.0"),
3028 command_name="reformat-paragraph",
3029 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3030 )
3031 #@+node:ekr.20201130090918.132: *5* reformat-paragraph new code 6 of 8
3032 def test_reformat_paragraph_new_code_6_of_8(self):
3033 """Test case for reformat-paragraph new code 6 of 8"""
3034 before_b = """\
3035 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3036 Line 32.
3038 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx
3039 """
3040 after_b = """\
3041 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3042 Line 32.
3044 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx
3045 """
3046 self.run_test(
3047 before_b=before_b,
3048 after_b=after_b,
3049 before_sel=("1.0", "1.0"),
3050 after_sel=("4.0", "4.0"),
3051 command_name="reformat-paragraph",
3052 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3053 )
3054 #@+node:ekr.20201130090918.133: *5* reformat-paragraph new code 7 of 8
3055 def test_reformat_paragraph_new_code_7_of_8(self):
3056 """Test case for reformat-paragraph new code 7 of 8"""
3057 before_b = """\
3058 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3059 Line 32.
3061 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx
3062 Line 41.
3063 """
3064 after_b = """\
3065 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx
3066 Line 32.
3068 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx
3069 Line 41.
3070 """
3071 self.run_test(
3072 before_b=before_b,
3073 after_b=after_b,
3074 before_sel=("2.11", "2.11"),
3075 after_sel=("3.1", "3.1"),
3076 command_name="reformat-paragraph",
3077 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3078 )
3079 #@+node:ekr.20201130090918.134: *5* reformat-paragraph new code 8 of 8
3080 def test_reformat_paragraph_new_code_8_of_8(self):
3081 """Test case for reformat-paragraph new code 8 of 8"""
3082 before_b = """\
3083 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx
3084 Line 41.
3085 """
3086 after_b = """\
3087 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx
3088 Line 41.
3089 """
3090 self.run_test(
3091 before_b=before_b,
3092 after_b=after_b,
3093 before_sel=("1.0", "1.0"),
3094 after_sel=("3.0", "3.0"),
3095 command_name="reformat-paragraph",
3096 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3097 )
3098 #@+node:ekr.20201130090918.135: *5* reformat-paragraph paragraph 1 of 3
3099 def test_reformat_paragraph_paragraph_1_of_3(self):
3100 """Test case for reformat-paragraph paragraph 1 of 3"""
3101 before_b = """\
3102 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
3104 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
3106 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
3108 Last paragraph.
3109 """
3110 after_b = """\
3111 Americans live in the most severe
3112 weather-prone country on Earth. Each
3113 year, Americans cope with an average of
3114 10,000 thunderstorms, 2,500 floods,
3115 1,000 tornadoes, as well as an average
3116 of 6 deadly hurricanes. Potentially
3117 deadly weather impacts every American.
3118 Communities can now rely on the National
3119 Weather Service’s StormReady program to
3120 help them guard against the ravages of
3121 Mother Nature.
3123 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
3125 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
3127 Last paragraph.
3128 """
3129 self.run_test(
3130 before_b=before_b,
3131 after_b=after_b,
3132 before_sel=("1.0", "1.0"),
3133 after_sel=("13.0", "13.0"),
3134 command_name="reformat-paragraph",
3135 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3136 )
3137 #@+node:ekr.20201130090918.136: *5* reformat-paragraph paragraph 2 of 3
3138 def test_reformat_paragraph_paragraph_2_of_3(self):
3139 """Test case for reformat-paragraph paragraph 2 of 3"""
3140 before_b = """\
3141 Americans live in the most severe
3142 weather-prone country on Earth. Each
3143 year, Americans cope with an average of
3144 10,000 thunderstorms, 2,500 floods,
3145 1,000 tornadoes, as well as an average
3146 of 6 deadly hurricanes. Potentially
3147 deadly weather impacts every American.
3148 Communities can now rely on the National
3149 Weather Service’s StormReady program to
3150 help them guard against the ravages of
3151 Mother Nature.
3153 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
3155 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
3157 Last paragraph.
3158 """
3159 after_b = """\
3160 Americans live in the most severe
3161 weather-prone country on Earth. Each
3162 year, Americans cope with an average of
3163 10,000 thunderstorms, 2,500 floods,
3164 1,000 tornadoes, as well as an average
3165 of 6 deadly hurricanes. Potentially
3166 deadly weather impacts every American.
3167 Communities can now rely on the National
3168 Weather Service’s StormReady program to
3169 help them guard against the ravages of
3170 Mother Nature.
3172 Some 90% of all presidentially declared
3173 disasters are weather related, leading
3174 to around 500 deaths per year and nearly
3175 $14 billion in damage. StormReady, a
3176 program started in 1999 in Tulsa, OK,
3177 helps arm America's communities with the
3178 communication and safety skills needed
3179 to save lives and property– before and
3180 during the event. StormReady helps
3181 community leaders and emergency managers
3182 strengthen local safety programs.
3184 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
3186 Last paragraph.
3187 """
3188 self.run_test(
3189 before_b=before_b,
3190 after_b=after_b,
3191 before_sel=("13.0", "13.0"),
3192 after_sel=("25.0", "25.0"),
3193 command_name="reformat-paragraph",
3194 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3195 )
3196 #@+node:ekr.20201130090918.137: *5* reformat-paragraph paragraph 3 of 3
3197 def test_reformat_paragraph_paragraph_3_of_3(self):
3198 """Test case for reformat-paragraph paragraph 3 of 3"""
3199 before_b = """\
3200 Americans live in the most severe
3201 weather-prone country on Earth. Each
3202 year, Americans cope with an average of
3203 10,000 thunderstorms, 2,500 floods,
3204 1,000 tornadoes, as well as an average
3205 of 6 deadly hurricanes. Potentially
3206 deadly weather impacts every American.
3207 Communities can now rely on the National
3208 Weather Service’s StormReady program to
3209 help them guard against the ravages of
3210 Mother Nature.
3212 Some 90% of all presidentially declared
3213 disasters are weather related, leading
3214 to around 500 deaths per year and nearly
3215 $14 billion in damage. StormReady, a
3216 program started in 1999 in Tulsa, OK,
3217 helps arm America's communities with the
3218 communication and safety skills needed
3219 to save lives and property– before and
3220 during the event. StormReady helps
3221 community leaders and emergency managers
3222 strengthen local safety programs.
3224 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
3226 Last paragraph.
3227 """
3228 after_b = """\
3229 Americans live in the most severe
3230 weather-prone country on Earth. Each
3231 year, Americans cope with an average of
3232 10,000 thunderstorms, 2,500 floods,
3233 1,000 tornadoes, as well as an average
3234 of 6 deadly hurricanes. Potentially
3235 deadly weather impacts every American.
3236 Communities can now rely on the National
3237 Weather Service’s StormReady program to
3238 help them guard against the ravages of
3239 Mother Nature.
3241 Some 90% of all presidentially declared
3242 disasters are weather related, leading
3243 to around 500 deaths per year and nearly
3244 $14 billion in damage. StormReady, a
3245 program started in 1999 in Tulsa, OK,
3246 helps arm America's communities with the
3247 communication and safety skills needed
3248 to save lives and property– before and
3249 during the event. StormReady helps
3250 community leaders and emergency managers
3251 strengthen local safety programs.
3253 StormReady communities are better
3254 prepared to save lives from the
3255 onslaught of severe weather through
3256 better planning, education, and
3257 awareness. No community is storm proof,
3258 but StormReady can help communities save
3259 lives. Does StormReady make a
3260 difference?
3262 Last paragraph.
3263 """
3264 self.run_test(
3265 before_b=before_b,
3266 after_b=after_b,
3267 before_sel=("25.10", "25.10"),
3268 after_sel=("34.0", "34.0"),
3269 command_name="reformat-paragraph",
3270 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3271 )
3272 #@+node:ekr.20201130090918.138: *5* reformat-paragraph simple hanging indent
3273 def test_reformat_paragraph_simple_hanging_indent(self):
3274 """Test case for reformat-paragraph simple hanging indent"""
3275 before_b = """\
3276 Honor this line that has a hanging indentation, please. Hanging
3277 indentation is valuable for lists of all kinds. But it is tricky to get right.
3279 Next paragraph.
3280 """
3281 after_b = """\
3282 Honor this line that has a hanging
3283 indentation, please. Hanging
3284 indentation is valuable for lists of
3285 all kinds. But it is tricky to get
3286 right.
3288 Next paragraph.
3289 """
3290 self.run_test(
3291 before_b=before_b,
3292 after_b=after_b,
3293 before_sel=("1.0", "1.0"),
3294 after_sel=("7.0", "7.0"),
3295 command_name="reformat-paragraph",
3296 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3297 )
3298 #@+node:ekr.20201130090918.139: *5* reformat-paragraph simple hanging indent 2
3299 def test_reformat_paragraph_simple_hanging_indent_2(self):
3300 """Test case for reformat-paragraph simple hanging indent 2"""
3301 before_b = """\
3302 Honor this line that has
3303 a hanging indentation, please. Hanging
3304 indentation is valuable for lists of all kinds. But it is tricky to get right.
3306 Next paragraph.
3307 """
3308 after_b = """\
3309 Honor this line that has a hanging
3310 indentation, please. Hanging
3311 indentation is valuable for lists of
3312 all kinds. But it is tricky to get
3313 right.
3315 Next paragraph.
3316 """
3317 self.run_test(
3318 before_b=before_b,
3319 after_b=after_b,
3320 before_sel=("2.0", "2.0"),
3321 after_sel=("7.0", "7.0"),
3322 command_name="reformat-paragraph",
3323 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3324 )
3325 #@+node:ekr.20201130090918.140: *5* reformat-paragraph simple hanging indent 3
3326 def test_reformat_paragraph_simple_hanging_indent_3(self):
3327 """Test case for reformat-paragraph simple hanging indent 3"""
3328 before_b = """\
3329 Honor this line that
3330 has a hanging indentation,
3331 please. Hanging
3332 indentation is valuable
3333 for lists of all kinds. But
3334 it is tricky to get right.
3336 Next Paragraph.
3337 """
3338 after_b = """\
3339 Honor this line that has a hanging
3340 indentation, please. Hanging
3341 indentation is valuable for lists of
3342 all kinds. But it is tricky to get
3343 right.
3345 Next Paragraph.
3346 """
3347 self.run_test(
3348 before_b=before_b,
3349 after_b=after_b,
3350 before_sel=("1.0", "1.0"),
3351 after_sel=("7.0", "7.0"),
3352 command_name="reformat-paragraph",
3353 directives="@language plain\n@pagewidth 40\n@tabwidth 8",
3354 )
3355 #@+node:ekr.20201130090918.101: *5* remove-blank-lines
3356 def test_remove_blank_lines(self):
3357 """Test case for remove-blank-lines"""
3358 before_b = """\
3359 first line
3361 line 1
3362 line a
3363 line b
3365 line c
3366 last line
3367 """
3368 after_b = """\
3369 first line
3370 line 1
3371 line a
3372 line b
3373 line c
3374 last line
3375 """
3376 self.run_test(
3377 before_b=before_b,
3378 after_b=after_b,
3379 before_sel=("1.0", "9.0"),
3380 after_sel=("1.0", "6.9"),
3381 command_name="remove-blank-lines",
3382 )
3383 #@+node:ekr.20201130090918.102: *5* remove-space-from-lines
3384 def test_remove_space_from_lines(self):
3385 """Test case for remove-space-from-lines"""
3386 before_b = """\
3387 first line
3389 line 1
3390 line a
3391 line b
3393 line c
3394 last line
3395 """
3396 after_b = """\
3397 first line
3399 line 1
3400 line a
3401 line b
3403 line c
3404 last line
3405 """
3406 self.run_test(
3407 before_b=before_b,
3408 after_b=after_b,
3409 before_sel=("1.0", "9.0"),
3410 after_sel=("1.0", "9.0"),
3411 command_name="remove-space-from-lines",
3412 )
3413 #@+node:ekr.20201130090918.103: *5* remove-tab-from-lines
3414 def test_remove_tab_from_lines(self):
3415 """Test case for remove-tab-from-lines"""
3416 before_b = """\
3417 first line
3418 line 1
3419 line a
3420 line b
3421 line c
3422 last line
3423 """
3424 after_b = """\
3425 first line
3426 line 1
3427 line a
3428 line b
3429 line c
3430 last line
3431 """
3432 self.run_test(
3433 before_b=before_b,
3434 after_b=after_b,
3435 before_sel=("1.0", "7.0"),
3436 after_sel=("1.0", "7.0"),
3437 command_name="remove-tab-from-lines",
3438 )
3439 #@+node:ekr.20201130090918.104: *5* reverse-region
3440 def test_reverse_region(self):
3441 """Test case for reverse-region"""
3442 before_b = """\
3443 first line
3444 line 1
3445 line a
3446 line b
3447 line c
3448 last line
3449 """
3450 after_b = """\
3452 last line
3453 line c
3454 line b
3455 line a
3456 line 1
3457 first line
3458 """
3459 self.run_test(
3460 before_b=before_b,
3461 after_b=after_b,
3462 before_sel=("1.0", "7.0"),
3463 after_sel=("7.10", "7.10"),
3464 command_name="reverse-region",
3465 )
3466 #@+node:ekr.20201130090918.105: *5* reverse-sort-lines
3467 def test_reverse_sort_lines(self):
3468 """Test case for reverse-sort-lines"""
3469 before_b = """\
3470 a
3471 d
3472 e
3473 z
3474 x
3475 """
3476 after_b = """\
3477 z
3478 x
3479 e
3480 d
3481 a
3482 """
3483 self.run_test(
3484 before_b=before_b,
3485 after_b=after_b,
3486 before_sel=("1.0", "5.1"),
3487 after_sel=("1.0", "5.1"),
3488 command_name="reverse-sort-lines",
3489 )
3490 #@+node:ekr.20201130090918.106: *5* reverse-sort-lines-ignoring-case
3491 def test_reverse_sort_lines_ignoring_case(self):
3492 """Test case for reverse-sort-lines-ignoring-case"""
3493 before_b = """\
3494 c
3495 A
3496 z
3497 X
3498 Y
3499 b
3500 """
3501 after_b = """\
3502 z
3503 Y
3504 X
3505 c
3506 b
3507 A
3508 """
3509 self.run_test(
3510 before_b=before_b,
3511 after_b=after_b,
3512 before_sel=("1.0", "6.1"),
3513 after_sel=("1.0", "6.1"),
3514 command_name="reverse-sort-lines-ignoring-case",
3515 )
3516 #@+node:ekr.20210829062731.1: *4* Commands S-Z
3517 #@+node:ekr.20201130090918.107: *5* sort-columns
3518 def test_sort_columns(self):
3519 """Test case for sort-columns"""
3520 before_b = """\
3521 first line
3522 line 1
3523 line a
3524 line b
3525 line c
3526 last line
3527 """
3528 after_b = """\
3529 line b
3530 line a
3531 first line
3532 last line
3533 line 1
3534 line c
3535 """
3536 self.run_test(
3537 before_b=before_b,
3538 after_b=after_b,
3539 before_sel=("1.0", "6.2"),
3540 after_sel=("1.0", "7.0"),
3541 command_name="sort-columns",
3542 )
3543 #@+node:ekr.20201130090918.108: *5* sort-lines
3544 def test_sort_lines(self):
3545 """Test case for sort-lines"""
3546 before_b = """\
3547 first line
3548 line 1
3549 line a
3550 line b
3551 line c
3552 last line
3553 """
3554 after_b = """\
3555 first line
3556 line b
3557 line a
3558 line 1
3559 line c
3560 last line
3561 """
3562 self.run_test(
3563 before_b=before_b,
3564 after_b=after_b,
3565 before_sel=("2.0", "5.6"),
3566 after_sel=("2.0", "5.6"),
3567 command_name="sort-lines",
3568 )
3569 #@+node:ekr.20201130090918.109: *5* sort-lines-ignoring-case
3570 def test_sort_lines_ignoring_case(self):
3571 """Test case for sort-lines-ignoring-case"""
3572 before_b = """\
3573 x
3574 z
3575 A
3576 c
3577 B
3578 """
3579 after_b = """\
3580 A
3581 B
3582 c
3583 x
3584 z
3585 """
3586 self.run_test(
3587 before_b=before_b,
3588 after_b=after_b,
3589 before_sel=("1.0", "5.1"),
3590 after_sel=("1.0", "5.1"),
3591 command_name="sort-lines-ignoring-case",
3592 )
3593 #@+node:ekr.20201130090918.110: *5* split-line
3594 def test_split_line(self):
3595 """Test case for split-line"""
3596 before_b = """\
3597 first line
3598 line 1
3599 line a
3600 line b
3601 line c
3602 last line
3603 """
3604 after_b = """\
3605 first
3606 line
3607 line 1
3608 line a
3609 line b
3610 line c
3611 last line
3612 """
3613 self.run_test(
3614 before_b=before_b,
3615 after_b=after_b,
3616 before_sel=("1.5", "1.5"),
3617 after_sel=("2.0", "2.0"),
3618 command_name="split-line",
3619 )
3620 #@+node:ekr.20201130090918.111: *5* start-of-line
3621 def test_start_of_line(self):
3622 """Test case for start-of-line"""
3623 before_b = """\
3624 first line
3625 line 1
3626 line a
3627 line b
3628 line c
3629 last line
3630 """
3631 after_b = """\
3632 first line
3633 line 1
3634 line a
3635 line b
3636 line c
3637 last line
3638 """
3639 self.run_test(
3640 before_b=before_b,
3641 after_b=after_b,
3642 before_sel=("3.10", "3.10"),
3643 after_sel=("3.4", "3.4"),
3644 command_name="start-of-line",
3645 )
3646 #@+node:ekr.20201130090918.112: *5* start-of-line (2)
3647 def test_start_of_line_2(self):
3648 """Test case for start-of-line (2)"""
3649 before_b = """\
3650 first line
3651 line 1
3652 line a
3653 line b
3654 line c
3655 last line
3656 """
3657 after_b = """\
3658 first line
3659 line 1
3660 line a
3661 line b
3662 line c
3663 last line
3664 """
3665 self.run_test(
3666 before_b=before_b,
3667 after_b=after_b,
3668 before_sel=("3.1", "3.1"),
3669 after_sel=("3.4", "3.4"),
3670 command_name="start-of-line",
3671 )
3672 #@+node:ekr.20201130090918.113: *5* start-of-line-extend-selection
3673 def test_start_of_line_extend_selection(self):
3674 """Test case for start-of-line-extend-selection"""
3675 before_b = """\
3676 first line
3677 line 1
3678 line a
3679 line b
3680 line c
3681 last line
3682 """
3683 after_b = """\
3684 first line
3685 line 1
3686 line a
3687 line b
3688 line c
3689 last line
3690 """
3691 self.run_test(
3692 before_b=before_b,
3693 after_b=after_b,
3694 before_sel=("3.10", "3.10"),
3695 after_sel=("3.4", "3.10"),
3696 command_name="start-of-line-extend-selection",
3697 )
3698 #@+node:ekr.20201130090918.114: *5* start-of-line-extend-selection (2)
3699 def test_start_of_line_extend_selection_2(self):
3700 """Test case for start-of-line-extend-selection (2)"""
3701 before_b = """\
3702 first line
3703 line 1
3704 line a
3705 line b
3706 line c
3707 last line
3708 """
3709 after_b = """\
3710 first line
3711 line 1
3712 line a
3713 line b
3714 line c
3715 last line
3716 """
3717 self.run_test(
3718 before_b=before_b,
3719 after_b=after_b,
3720 before_sel=("3.1", "3.1"),
3721 after_sel=("3.1", "3.4"),
3722 command_name="start-of-line-extend-selection",
3723 )
3724 #@+node:ekr.20201130090918.115: *5* tabify
3725 def test_tabify(self):
3726 """Test case for tabify"""
3727 before_b = """\
3728 first line
3729 line 1
3730 line a
3731 line b
3732 line c
3733 last line
3734 """
3735 after_b = """\
3736 first line
3737 line 1
3738 line a
3739 line b
3740 line c
3741 last line
3742 """
3743 self.run_test(
3744 before_b=before_b,
3745 after_b=after_b,
3746 before_sel=("1.0", "7.0"),
3747 after_sel=("7.0", "7.0"),
3748 command_name="tabify",
3749 )
3750 #@+node:ekr.20201130090918.116: *5* transpose-chars
3751 def test_transpose_chars(self):
3752 """Test case for transpose-chars"""
3753 before_b = """\
3754 first line
3755 line 1
3756 line a
3757 line b
3758 line c
3759 last line
3760 """
3761 after_b = """\
3762 frist line
3763 line 1
3764 line a
3765 line b
3766 line c
3767 last line
3768 """
3769 self.run_test(
3770 before_b=before_b,
3771 after_b=after_b,
3772 before_sel=("1.2", "1.2"),
3773 after_sel=("1.2", "1.2"),
3774 command_name="transpose-chars",
3775 )
3776 #@+node:ekr.20201130090918.117: *5* transpose-lines
3777 def test_transpose_lines(self):
3778 """Test case for transpose-lines"""
3779 before_b = """\
3780 first line
3781 line 1
3782 line a
3783 line b
3784 line c
3785 last line
3786 """
3787 after_b = """\
3788 line 1
3789 first line
3790 line a
3791 line b
3792 line c
3793 last line
3794 """
3795 self.run_test(
3796 before_b=before_b,
3797 after_b=after_b,
3798 before_sel=("2.2", "2.2"),
3799 after_sel=("2.10", "2.10"),
3800 command_name="transpose-lines",
3801 )
3802 #@+node:ekr.20201130090918.118: *5* transpose-words
3803 def test_transpose_words(self):
3804 """Test case for transpose-words"""
3805 before_b = """\
3806 first line
3807 before bar2 += foo after
3808 last line
3809 """
3810 after_b = """\
3811 first line
3812 before foo += bar2 after
3813 last line
3814 """
3815 self.run_test(
3816 before_b=before_b,
3817 after_b=after_b,
3818 before_sel=("2.9", "2.9"),
3819 after_sel=("2.11", "2.11"),
3820 command_name="transpose-words",
3821 )
3822 #@+node:ekr.20201130090918.119: *5* untabify
3823 def test_untabify(self):
3824 """Test case for untabify"""
3825 before_b = """\
3826 first line
3827 line 1
3828 line a
3829 line b
3830 line c
3831 last line
3832 """
3833 after_b = """\
3834 first line
3835 line 1
3836 line a
3837 line b
3838 line c
3839 last line
3840 """
3841 self.run_test(
3842 before_b=before_b,
3843 after_b=after_b,
3844 before_sel=("1.0", "7.0"),
3845 after_sel=("7.0", "7.0"),
3846 command_name="untabify",
3847 )
3848 #@+node:ekr.20201130090918.120: *5* upcase-region
3849 def test_upcase_region(self):
3850 """Test case for upcase-region"""
3851 before_b = """\
3852 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
3854 Some 90% of all presidentially declared disasters are weather related, leading to around 500 deaths per year and nearly $14 billion in damage. StormReady, a program started in 1999 in Tulsa, OK, helps arm America's communities with the communication and safety skills needed to save lives and property– before and during the event. StormReady helps community leaders and emergency managers strengthen local safety programs.
3856 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
3857 """
3858 after_b = """\
3859 Americans live in the most severe weather-prone country on Earth. Each year, Americans cope with an average of 10,000 thunderstorms, 2,500 floods, 1,000 tornadoes, as well as an average of 6 deadly hurricanes. Potentially deadly weather impacts every American. Communities can now rely on the National Weather Service’s StormReady program to help them guard against the ravages of Mother Nature.
3861 SOME 90% OF ALL PRESIDENTIALLY DECLARED DISASTERS ARE WEATHER RELATED, LEADING TO AROUND 500 DEATHS PER YEAR AND NEARLY $14 BILLION IN DAMAGE. STORMREADY, A PROGRAM STARTED IN 1999 IN TULSA, OK, HELPS ARM AMERICA'S COMMUNITIES WITH THE COMMUNICATION AND SAFETY SKILLS NEEDED TO SAVE LIVES AND PROPERTY– BEFORE AND DURING THE EVENT. STORMREADY HELPS COMMUNITY LEADERS AND EMERGENCY MANAGERS STRENGTHEN LOCAL SAFETY PROGRAMS.
3863 StormReady communities are better prepared to save lives from the onslaught of severe weather through better planning, education, and awareness. No community is storm proof, but StormReady can help communities save lives. Does StormReady make a difference?
3864 """
3865 self.run_test(
3866 before_b=before_b,
3867 after_b=after_b,
3868 before_sel=("3.0", "4.0"),
3869 after_sel=("3.0", "4.0"),
3870 command_name="upcase-region",
3871 )
3872 #@+node:ekr.20201130090918.121: *5* upcase-word
3873 def test_upcase_word(self):
3874 """Test case for upcase-word"""
3875 before_b = """\
3876 first line
3877 line 1
3878 line a
3879 line b
3880 line c
3881 last line
3882 """
3883 after_b = """\
3884 first line
3885 line 1
3886 LINE a
3887 line b
3888 line c
3889 last line
3890 """
3891 self.run_test(
3892 before_b=before_b,
3893 after_b=after_b,
3894 before_sel=("3.7", "3.7"),
3895 after_sel=("3.7", "3.7"),
3896 command_name="upcase-word",
3897 )
3898 #@+node:ekr.20210905064816.1: *3* TestEditCommands: Others
3899 #@+node:ekr.20210905064816.2: *4* TestEditCommands.test_abbrevCommands_next_place
3900 def test_abbrevCommands_next_place(self):
3901 c = self.c
3902 p = c.p
3903 ac = c.abbrevCommands
3904 assert ac
3905 # pylint: disable=no-member
3906 if c.abbrev_place_start is None or c.abbrev_place_end is None:
3907 self.skipTest('no abbreviation settings') # #1345.
3908 child = g.findNodeInTree(c, p, 'child')
3909 assert child
3910 i, j = 0, 0
3911 # ac.make_script_substitutions(i,j,val)
3912 # ac.find_place_holder(child,True)
3913 new_s, i, j = ac.next_place(child.b, offset=0)
3914 self.assertEqual(p.b, new_s)
3915 self.assertEqual(i, 34)
3916 self.assertEqual(j, 40)
3917 new_s2, i, j = ac.next_place(new_s, offset=40)
3918 self.assertEqual(i, 54)
3919 self.assertEqual(j, 58)
3921 #@+node:ekr.20210905064816.3: *4* TestEditCommands.test_addAbbrevHelper
3922 def test_addAbbrevHelper(self):
3923 c = self.c
3924 f = c.abbrevCommands.addAbbrevHelper
3925 d = c.abbrevCommands.abbrevs
3927 # New in Leo 4.10: whitespace (blank,tab,newline) *is* significant in definitions.
3928 table = (
3929 ('ut1', 'ut1=aa', 'aa'),
3930 # ('ut2','ut2 =bb','bb'),
3931 ('ut3', 'ut3=cc=dd', 'cc=dd'),
3932 ('ut4', 'ut4= ee', ' ee'),
3933 ('ut5', 'ut5= ff = gg', ' ff = gg'),
3934 ('ut6', 'ut6= hh==ii', ' hh==ii'),
3935 ('ut7', 'ut7=j=k', 'j=k'),
3936 ('ut8', 'ut8=l==m', 'l==m'),
3937 ('@ut1', '@ut1=@a', '@a'),
3938 )
3939 for name, s, expected in table:
3940 for s2, kind in ((s, '(no nl)'), (s + '\n', '(nl)')):
3941 f(s2, tag='unit-test')
3942 result, tag = d.get(name, (None, None),)
3943 self.assertEqual(result, expected, msg=kind)
3944 #@+node:ekr.20210905064816.4: *4* TestEditCommands.test_capitalizeHelper
3945 def test_capitalizeHelper(self):
3946 c, w = self.c, self.c.frame.body.wrapper
3947 w.setAllText('# TARGETWORD\n')
3948 table = (
3949 ('cap', 'Targetword'),
3950 ('low', 'targetword'),
3951 ('up', 'TARGETWORD'),
3952 )
3953 for (which, result) in table:
3954 w.setInsertPoint(5) # Must be inside the target.
3955 c.editCommands.capitalizeHelper(event=None, which=which, undoType='X')
3956 s = w.getAllText()
3957 word = s[2:12]
3958 self.assertEqual(word, result, msg=which)
3959 i = w.getInsertPoint()
3960 self.assertEqual(i, 5, msg=which)
3961 #@+node:ekr.20210905064816.16: *4* TestEditCommands.test_delete_key_sticks_in_body
3962 def test_delete_key_sticks_in_body(self):
3963 c = self.c
3964 w = c.frame.body.wrapper
3965 h = 'Test headline abc'
3966 p = c.rootPosition().insertAfter()
3967 p.h = h
3968 c.selectPosition(p)
3969 s = 'ABC'
3970 c.setBodyString(p, s)
3971 c.bodyWantsFocus()
3972 w.setInsertPoint(2)
3973 c.outerUpdate() # This fixed the problem.
3974 c.k.simulateCommand('delete-char')
3975 self.assertEqual(p.b, s[:-1])
3976 c.selectPosition(p.threadBack())
3977 c.selectPosition(p)
3978 self.assertEqual(p.b, s[:-1])
3979 #@+node:ekr.20210905064816.17: *4* TestEditCommands.test_delete_key_sticks_in_headline
3980 def test_delete_key_sticks_in_headline(self):
3981 c = self.c
3982 h = 'Test headline abc'
3983 p = c.rootPosition().insertAfter()
3984 p.h = h
3985 c.selectPosition(p)
3986 c.redraw(p) # To make node visible
3987 c.frame.tree.editLabel(p)
3988 w = c.edit_widget(p)
3989 try:
3990 assert w
3991 w.setSelectionRange('end', 'end')
3992 finally:
3993 if 1:
3994 c.setHeadString(p, h) # Essential
3995 c.redraw(p)
3996 #@+node:ekr.20210905064816.5: *4* TestEditCommands.test_dynamicExpandHelper
3997 def test_dynamicExpandHelper(self):
3998 c = self.c
3999 # A totally wimpy test.
4000 # And it somehow prints a newline to the console.
4001 if 0:
4002 c.abbrevCommands.dynamicExpandHelper(event=None, prefix='', aList=[], w=None)
4003 #@+node:ekr.20210905064816.6: *4* TestEditCommands.test_extendHelper
4004 def test_extendHelper(self):
4005 c = self.c
4006 ec = c.editCommands
4007 w = c.frame.body.wrapper
4008 for i, j, python in (
4009 # ('1.0','4.5',False),
4010 (5, 50, True),
4011 ):
4012 extend = True
4013 ec.moveSpot = None # It's hard to init this properly.
4014 ec.extendHelper(w, extend, j)
4015 i2, j2 = w.getSelectionRange()
4016 #@+node:ekr.20210905064816.7: *4* TestEditCommands.test_findWord
4017 def test_findWord(self):
4018 c = self.c
4019 e, k, w = c.editCommands, c.k, c.frame.body.wrapper
4020 w.setAllText('start\ntargetWord\n')
4021 w.setInsertPoint(0)
4022 k.arg = 't' # 'targetWord'
4023 e.w = w
4024 e.oneLineFlag = False
4025 e.findWord1(event=None)
4026 i, j = w.getSelectionRange()
4027 self.assertEqual(i, 6)
4028 #@+node:ekr.20210905064816.8: *4* TestEditCommands.test_findWordInLine
4029 def test_findWordInLine(self):
4030 c = self.c
4031 e, k, w = c.editCommands, c.k, c.frame.body.wrapper
4032 w.setAllText('abc\ntargetWord\n')
4033 k.arg = 't' # 'targetWord'
4034 w.setInsertPoint(0)
4035 e.w = w
4036 e.oneLineFlag = False
4037 e.findWord1(event=None)
4038 i, j = w.getSelectionRange()
4039 self.assertEqual(i, 4)
4040 #@+node:ekr.20210905064816.9: *4* TestEditCommands.test_helpForMinibuffer
4041 def test_helpForMinibuffer(self):
4042 c = self.c
4043 vr = c.helpCommands.helpForMinibuffer()
4044 if not vr:
4045 self.skipTest('no vr plugin')
4046 #@+node:ekr.20210914154830.1: *4* TestEditCommands.test_helpForPython
4047 def test_helpForPthon(self):
4048 c, k = self.c, self.c.k
4049 k.arg = 'os'
4050 s = c.helpCommands.pythonHelp1(event=None)
4051 self.assertTrue('Help on module os' in s)
4052 #@+node:ekr.20210905064816.19: *4* TestEditCommands.test_insert_node_before_node_can_be_undone_and_redone
4053 def test_insert_node_before_node_can_be_undone_and_redone(self):
4054 c = self.c
4055 u = c.undoer
4056 assert u
4057 # pylint: disable=no-member
4058 c.insertHeadlineBefore()
4059 self.assertEqual(u.undoMenuLabel, 'Undo Insert Node Before')
4060 c.undoer.undo()
4061 self.assertEqual(u.redoMenuLabel, 'Redo Insert Node Before')
4062 #@+node:ekr.20210905064816.18: *4* TestEditCommands.test_insert_node_can_be_undone_and_redone
4063 def test_insert_node_can_be_undone_and_redone(self):
4064 c = self.c
4065 u = c.undoer
4066 assert u
4067 # pylint: disable=no-member
4068 c.insertHeadline()
4069 self.assertEqual(u.undoMenuLabel, 'Undo Insert Node')
4070 c.undoer.undo()
4071 self.assertEqual(u.redoMenuLabel, 'Redo Insert Node')
4072 #@+node:ekr.20210905064816.20: *4* TestEditCommands.test_inserting_a_new_node_draws_the_screen_exactly_once
4073 def test_inserting_a_new_node_draws_the_screen_exactly_once(self):
4074 c = self.c
4075 n = c.frame.tree.redrawCount
4076 # pylint: disable=no-member
4077 c.insertHeadline()
4078 c.outerUpdate() # Not actually needed, but should not matter.
4079 n2 = c.frame.tree.redrawCount
4080 self.assertEqual(n2, n + 1)
4082 #@+node:ekr.20210905064816.15: *4* TestEditCommands.test_most_toggle_commands
4083 def test_most_toggle_commands(self):
4084 c, k = self.c, self.c.k
4085 ed = c.editCommands
4086 # These don't set ivars
4087 # 'toggle-active-pane'),
4088 # 'toggle-angle-brackets',
4089 # 'toggle-input-state'),
4090 # 'toggle-mini-buffer'),
4091 # 'toggle-split-direction'),
4092 table = [
4093 (k, 'abbrevOn', 'toggle-abbrev-mode'),
4094 (ed, 'extendMode', 'toggle-extend-mode'),
4095 ]
4096 for obj, ivar, command in table:
4097 val1 = getattr(obj, ivar)
4098 k.simulateCommand(command)
4099 val2 = getattr(obj, ivar)
4100 self.assertEqual(val2, not val1, msg=command)
4101 k.simulateCommand(command)
4102 val3 = getattr(obj, ivar)
4103 self.assertEqual(val3, val1, msg=command)
4104 #@+node:ekr.20210905064816.10: *4* TestEditCommands.test_moveToHelper
4105 def test_moveToHelper(self):
4106 c = self.c
4107 ec = c.editCommands
4108 w = c.frame.body.wrapper
4109 for i, j, python in (
4110 #('1.0','4.5',False),
4111 (5, 50, True),
4112 ):
4113 event = None
4114 extend = True
4115 ec.moveSpot = None
4116 w.setInsertPoint(i)
4117 ec.moveToHelper(event, j, extend)
4118 i2, j2 = w.getSelectionRange()
4119 self.assertEqual(i, i2)
4120 self.assertEqual(j, j2)
4121 w.setSelectionRange(0, 0, insert=None)
4122 #@+node:ekr.20210905064816.11: *4* TestEditCommands.test_moveUpOrDownHelper
4123 def test_moveUpOrDownHelper(self):
4124 c = self.c
4125 ec = c.editCommands
4126 w = c.frame.body.wrapper
4127 for i, result, direction in (('5.8', '4.8', 'up'), ('5.8', '6.8', 'down')):
4128 w.setInsertPoint(i)
4129 ec.moveUpOrDownHelper(event=None, direction=direction, extend=False)
4130 w.getSelectionRange()
4132 #@+node:ekr.20210905064816.21: *4* TestEditCommands.test_paste_and_undo_in_headline__at_end
4133 def test_paste_and_undo_in_headline__at_end(self):
4134 c = self.c
4135 k = c.keyHandler
4136 h = 'Test headline abc'
4137 p = c.rootPosition().insertAfter()
4138 p.h = h
4139 c.selectPosition(p)
4140 c.redrawAndEdit(p) # To make node visible
4141 w = c.edit_widget(p)
4142 assert w
4143 w.setSelectionRange('end', 'end')
4144 paste = 'ABC'
4145 g.app.gui.replaceClipboardWith(paste)
4146 w.setSelectionRange('end', 'end')
4147 if g.app.gui.guiName() == 'curses':
4148 c.frame.pasteText(event=g.Bunch(widget=w))
4149 else:
4150 stroke = k.getStrokeForCommandName('paste-text')
4151 if stroke is None:
4152 self.skipTest('no binding for paste-text') # #1345
4153 k.manufactureKeyPressForCommandName(w, 'paste-text')
4154 g.app.gui.event_generate(c, '\n', 'Return', w)
4155 self.assertEqual(p.h, h + paste)
4156 k.manufactureKeyPressForCommandName(w, 'undo')
4157 self.assertEqual(p.h, h)
4158 #@+node:ekr.20210905064816.22: *4* TestEditCommands.test_paste_and_undo_in_headline__with_selection
4159 def test_paste_and_undo_in_headline__with_selection(self):
4160 c = self.c
4161 k = c.keyHandler
4162 frame = c.frame
4163 tree = frame.tree
4164 h = 'Test headline abc'
4165 p = c.rootPosition().insertAfter()
4166 p.h = h
4167 c.selectPosition(p)
4168 c.redraw(p) # To make node visible
4169 tree.editLabel(p)
4170 w = c.edit_widget(p)
4171 assert w
4172 paste = 'ABC'
4173 g.app.gui.replaceClipboardWith(paste)
4174 w.setSelectionRange('1.1', '1.2')
4175 if g.app.gui.guiName() == 'curses':
4176 c.frame.pasteText(event=g.Bunch(widget=w))
4177 else:
4178 stroke = k.getStrokeForCommandName('paste-text')
4179 if stroke is None:
4180 self.skipTest('no binding for paste-text') # #1345
4181 k.manufactureKeyPressForCommandName(w, 'paste-text')
4182 g.app.gui.event_generate(c, '\n', 'Return', w)
4183 self.assertEqual(p.h, h[0] + paste + h[2:])
4184 k.manufactureKeyPressForCommandName(w, 'undo')
4185 self.assertEqual(p.h, h)
4187 #@+node:ekr.20210905064816.23: *4* TestEditCommands.test_paste_at_end_of_headline
4188 def test_paste_at_end_of_headline(self):
4189 c = self.c
4190 k = c.keyHandler
4191 h = 'Test headline abc'
4192 p = c.rootPosition().insertAfter()
4193 p.h = h
4194 c.selectPosition(p)
4195 c.redrawAndEdit(p) # To make node visible
4196 w = c.edit_widget(p)
4197 g.app.gui.set_focus(c, w)
4198 assert w
4199 paste = 'ABC'
4200 g.app.gui.replaceClipboardWith(paste)
4201 g.app.gui.set_focus(c, w)
4202 w.setSelectionRange('end', 'end')
4203 if g.app.gui.guiName() == 'curses':
4204 c.frame.pasteText(event=g.Bunch(widget=w))
4205 else:
4206 stroke = k.getStrokeForCommandName('paste-text')
4207 if stroke is None:
4208 self.skipTest('no binding for paste-text') # #1345
4209 k.manufactureKeyPressForCommandName(w, 'paste-text')
4210 g.app.gui.event_generate(c, '\n', 'Return', w)
4211 self.assertEqual(p.h, h + paste)
4212 #@+node:ekr.20210905064816.24: *4* TestEditCommands.test_paste_from_menu_into_headline_sticks
4213 def test_paste_from_menu_into_headline_sticks(self):
4214 c = self.c
4215 h = 'Test headline abc'
4216 p = c.rootPosition().insertAfter()
4217 p.h = h
4218 c.selectPosition(p)
4219 c.selectPosition(p)
4220 c.frame.tree.editLabel(p)
4221 w = c.edit_widget(p)
4222 w.setSelectionRange('end', 'end', insert='end')
4223 paste = 'ABC'
4224 g.app.gui.replaceClipboardWith(paste)
4225 event = g.app.gui.create_key_event(c, w=w)
4226 c.frame.pasteText(event)
4227 # Move around and and make sure it doesn't change.
4228 try:
4229 # g.trace('before select',w,w.getAllText())
4230 c.selectPosition(p.threadBack())
4231 self.assertEqual(p.h, h + paste)
4232 c.selectPosition(p)
4233 self.assertEqual(p.h, h + paste)
4234 finally:
4235 if 1:
4236 c.setHeadString(p, h) # Essential
4237 c.redraw(p)
4238 #@+node:ekr.20210905064816.25: *4* TestEditCommands.test_return_ends_editing_of_headline
4239 def test_return_ends_editing_of_headline(self):
4240 c = self.c
4241 h = '@test return ends editing of headline'
4242 p = c.rootPosition().insertAfter()
4243 p.h = h
4244 c.selectPosition(p)
4245 c.redraw(p) # To make node visible
4246 c.frame.tree.editLabel(p)
4247 w = c.edit_widget(p)
4248 wName = g.app.gui.widget_name(w)
4249 assert wName.startswith('head'), 'w.name:%s' % wName
4250 g.app.gui.event_generate(c, '\n', 'Return', w)
4251 c.outerUpdate()
4252 assert w != c.get_focus(), 'oops2: focus in headline'
4253 #@+node:ekr.20210905064816.12: *4* TestEditCommands.test_scrollHelper
4254 def test_scrollHelper(self):
4255 c = self.c
4256 ec = c.editCommands
4257 w = c.frame.body.wrapper
4259 for direction in ('up', 'down'):
4260 for distance in ('line', 'page', 'half-page'):
4261 event = g.app.gui.create_key_event(c, w=w)
4262 ec.scrollHelper(event, direction, distance)
4263 #@+node:ekr.20210905064816.26: *4* TestEditCommands.test_selecting_new_node_retains_paste_in_headline
4264 def test_selecting_new_node_retains_paste_in_headline(self):
4265 c, k = self.c, self.c.k
4266 h = 'Test headline abc'
4267 p = c.rootPosition().insertAfter()
4268 p.h = h
4269 c.selectPosition(p)
4270 c.redraw(p) # To make node visible
4271 c.frame.tree.editLabel(p)
4272 w = c.edit_widget(p)
4273 w.setSelectionRange('end', 'end')
4274 paste = 'ABC'
4275 g.app.gui.replaceClipboardWith(paste)
4276 w.setSelectionRange('end', 'end')
4277 k.manufactureKeyPressForCommandName(w, 'paste-text')
4278 c.selectPosition(p.visBack(c))
4279 self.assertEqual(p.h, h + paste)
4280 c.undoer.undo()
4281 self.assertEqual(p.h, h)
4282 #@+node:ekr.20210905064816.27: *4* TestEditCommands.test_selecting_new_node_retains_typing_in_headline
4283 def test_selecting_new_node_retains_typing_in_headline(self):
4284 c = self.c
4285 k = c.k
4286 if k.defaultUnboundKeyAction != 'insert':
4287 return
4288 tree = c.frame.tree
4289 h = 'Test headline abc'
4290 p = c.rootPosition().insertAfter()
4291 p.h = h
4292 c.selectPosition(p)
4293 c.redraw(p) # To make node visible
4294 tree.editLabel(p)
4295 w = c.edit_widget(p)
4296 w.setSelectionRange('end', 'end')
4297 # char, shortcut.
4298 g.app.gui.event_generate(c, 'X', 'Shift+X', w)
4299 g.app.gui.event_generate(c, 'Y', 'Shift+Y', w)
4300 g.app.gui.event_generate(c, 'Z', 'Shift+Z', w)
4301 g.app.gui.event_generate(c, '\n', 'Return', w)
4302 expected = h + 'XYZ'
4303 self.assertEqual(p.h, expected)
4304 k.manufactureKeyPressForCommandName(w, 'undo')
4305 self.assertEqual(p.h, h)
4306 #@+node:ekr.20210905064816.13: *4* TestEditCommands.test_setMoveCol
4307 def test_setMoveCol(self):
4308 c = self.c
4309 ec, w = c.editCommands, c.frame.body.wrapper
4310 table = (
4311 ('1.0', 0),
4312 (5, 5),
4313 )
4314 w.setAllText('1234567890')
4315 for spot, result in table:
4316 ec.setMoveCol(w, spot)
4317 self.assertEqual(ec.moveSpot, result)
4318 self.assertEqual(ec.moveCol, result)
4319 #@+node:ekr.20210905064816.14: *4* TestEditCommands.test_toggle_extend_mode
4320 def test_toggle_extend_mode(self):
4321 c = self.c
4322 # backward-find-character and find-character
4323 # can't be tested this way because they prompt for input.
4324 #@+<< define table >>
4325 #@+node:ekr.20210905065002.1: *5* << define table >>
4326 # Cursor movement commands affected by extend mode.
4327 # The x-extend-selection commands are not so affected.
4328 table = (
4329 'back-to-indentation',
4330 'back-to-home',
4331 'back-char',
4332 'back-page',
4333 'back-paragraph',
4334 'back-sentence',
4335 'back-word',
4336 'beginning-of-buffer',
4337 'beginning-of-line',
4338 'end-of-buffer',
4339 'end-of-line',
4340 'forward-char',
4341 'forward-page',
4342 'forward-paragraph',
4343 'forward-sentence',
4344 'forward-end-word',
4345 'forward-word',
4346 'move-past-close',
4347 'next-line',
4348 'previous-line',
4349 )
4350 #@-<< define table >>
4351 w = c.frame.body.wrapper
4352 s = textwrap.dedent("""\
4353 Paragraph 1.
4354 line 2.
4356 Paragraph 2.
4357 line 2, paragraph 2
4358 """)
4359 w.setAllText(s)
4360 child = c.rootPosition().insertAfter()
4361 c.selectPosition(child)
4362 for commandName in table:
4363 # Put the cursor in the middle of the middle line
4364 # so all cursor moves will actually do something.
4365 w.setInsertPoint(15)
4366 c.editCommands.extendMode = True
4367 c.keyHandler.simulateCommand(commandName)
4368 # i, j = w.getSelectionRange()
4369 # self.assertNotEqual(i, j, msg=commandName)
4370 #@+node:ekr.20210905064816.28: *4* TestEditCommands.test_typing_and_undo_in_headline__at_end
4371 def test_typing_and_undo_in_headline__at_end(self):
4372 c, k = self.c, self.c.k
4373 if k.defaultUnboundKeyAction != 'insert':
4374 self.skipTest('defaultUnboundKeyAction != insert')
4375 if not k.getStrokeForCommandName('undo'):
4376 self.skipTest('no settings')
4377 h = 'Test headline abc'
4378 p = c.rootPosition().insertAfter()
4379 p.h = h
4380 c.redrawAndEdit(p) # To make the node visible.
4381 w = c.edit_widget(p)
4382 assert w
4383 wName = g.app.gui.widget_name(w)
4384 self.assertTrue(wName.startswith('head'))
4385 w.setSelectionRange('end', 'end')
4386 g.app.gui.event_generate(c, 'X', 'Shift+X', w)
4387 g.app.gui.event_generate(c, 'Y', 'Shift+Y', w)
4388 g.app.gui.event_generate(c, 'Z', 'Shift+Z', w)
4389 g.app.gui.event_generate(c, '\n', 'Return', w)
4390 self.assertEqual(p.h, h + 'XYZ')
4391 if g.app.gui.guiName() != 'nullGui':
4392 self.assertEqual(c.undoer.undoMenuLabel, 'Undo Typing')
4393 k.manufactureKeyPressForCommandName(w, 'undo')
4394 if g.app.gui.guiName() != 'nullGui':
4395 self.assertEqual(c.undoer.redoMenuLabel, 'Redo Typing')
4396 self.assertEqual(p.h, h)
4397 #@+node:ekr.20210905064816.29: *4* TestEditCommands.test_typing_in_non_empty_body_text_does_not_redraw_the_screen
4398 def test_typing_in_non_empty_body_text_does_not_redraw_the_screen(self):
4399 c = self.c
4400 w = c.frame.body.wrapper
4401 h = 'Test headline abc'
4402 p = c.rootPosition().insertAfter()
4403 p.h = h
4404 c.setBodyString(p, 'a')
4405 p.v.iconVal = p.computeIcon() # To suppress redraw!
4406 c.redraw(p) # To make node visible
4407 c.bodyWantsFocus()
4408 n = c.frame.tree.redrawCount
4409 g.app.gui.event_generate(c, 'a', 'a', w)
4410 n2 = c.frame.tree.redrawCount
4411 self.assertEqual(n2, n)
4413 #@+node:ekr.20210905064816.30: *4* TestEditCommands.test_undoing_insert_node_restores_previous_node_s_body_text
4414 def test_undoing_insert_node_restores_previous_node_s_body_text(self):
4415 c = self.c
4416 h = 'Test headline abc'
4417 p = c.rootPosition().insertAfter()
4418 p.h = h
4419 c.selectPosition(p)
4420 body = 'This is a test'
4421 c.setBodyString(p, body)
4422 # pylint: disable=no-member
4423 self.assertEqual(p.b, body)
4424 c.insertHeadline()
4425 c.undoer.undo()
4426 self.assertEqual(p.b, body)
4427 #@-others
4428#@-others
4429#@-leo