Coverage for commands\test_editCommands.py: 95%

1050 statements  

« prev     ^ index     » next       coverage.py v6.4, created at 2022-05-24 10:21 -0500

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) 

69 

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. 

186 

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. 

193 

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. 

206 

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. 

213 

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. 

236 

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. 

243 

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. 

256 

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. 

263 

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. 

281 

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. 

283 

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. 

288 

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. 

290 

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. 

305 

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. 

307 

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. 

312 

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. 

314 

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. 

409 

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. 

411 

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. 

416 

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. 

418 

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. 

433 

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. 

435 

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. 

440 

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. 

442 

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. 

556 

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. 

563 

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. 

581 

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. 

638 

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. 

640 

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. 

645 

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. 

647 

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. 

662 

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. 

664 

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. 

669 

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. 

671 

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. 

765 

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. 

772 

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. 

777 

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. 

784 

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. 

826 

827 a = 2 

828 

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. 

1000 

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. 

1002 

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. 

1007 

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. 

1009 

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 

1154 

1155 line 1 

1156 line a 

1157 line b 

1158 line c 

1159 last line 

1160 """ 

1161 after_b = """\ 

1162 first line 

1163 

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 

1187 

1188 """ 

1189 after_b = """\ 

1190 first line 

1191 line 1 

1192 line a 

1193 line b 

1194 line c 

1195 last non-blank line 

1196 

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. 

1345 

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. 

1352 

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. 

1365 

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. 

1372 

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. 

1390 

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. 

1392 

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. 

1397 

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. 

1399 

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. 

1441 

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. 

1454 

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. 

1459 

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. 

1466 

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. 

1612 

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. 

1614 

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. 

1619 

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. 

1621 

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. 

1636 

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. 

1638 

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. 

1643 

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. 

1645 

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. 

1660 

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. 

1662 

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. 

1667 

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. 

1669 

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. 

1689 

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. 

1696 

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. 

1709 

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. 

1716 

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. 

1739 

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. 

1746 

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. 

1759 

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. 

1766 

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. 

1784 

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. 

1786 

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. 

1791 

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. 

1793 

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. 

1808 

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. 

1810 

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. 

1815 

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. 

1817 

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. 

1832 

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. 

1834 

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. 

1839 

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. 

1841 

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. 

1856 

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. 

1858 

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. 

1863 

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. 

1865 

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 TABline 1 

1915 TAB line a 

1916 TAB line b 

1917 TABline c 

1918 last line 

1919 """.replace('TAB', '\t') 

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 

1989 

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 

2055 

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 

2070 

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 

2097 

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. 

2117 

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. 

2124 

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. 

2137 

2138 

2139 

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 

2256 

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 

2283 

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.20220517064432.1: *5* merge-node-with-next-node 

2315 def test_merge_node_with_next_node(self): 

2316 c, u = self.c, self.c.undoer 

2317 prev_b = textwrap.dedent("""\ 

2318 def spam(): 

2319 pass 

2320 """) 

2321 next_b = textwrap.dedent("""\ 

2322 spam2 = spam 

2323 """) 

2324 result_b = textwrap.dedent("""\ 

2325 def spam(): 

2326 pass 

2327 

2328 spam2 = spam 

2329 """) 

2330 self.before_p.b = prev_b 

2331 self.after_p.b = next_b 

2332 c.selectPosition(self.before_p) 

2333 # Delete 'before', select 'after' 

2334 c.k.simulateCommand('merge-node-with-next-node') 

2335 self.assertEqual(c.p.h, 'after') 

2336 self.assertEqual(c.p.b, result_b) 

2337 self.assertFalse(c.p.next()) 

2338 # Restore 'before', select, 'before'. 

2339 u.undo() 

2340 self.assertEqual(c.p.h, 'before') 

2341 self.assertEqual(c.p.b, prev_b) 

2342 self.assertEqual(c.p.next().h, 'after') 

2343 self.assertEqual(c.p.next().b, next_b) 

2344 u.redo() 

2345 self.assertEqual(c.p.h, 'after') 

2346 self.assertEqual(c.p.b, result_b) 

2347 self.assertFalse(c.p.next()) 

2348 #@+node:ekr.20220517064507.1: *5* merge-node-with-prev-node 

2349 def test_merge_node_with_prev_node(self): 

2350 c, u = self.c, self.c.undoer 

2351 prev_b = textwrap.dedent("""\ 

2352 def spam(): 

2353 pass 

2354 """) 

2355 next_b = textwrap.dedent("""\ 

2356 spam2 = spam 

2357 """) 

2358 result_b = textwrap.dedent("""\ 

2359 def spam(): 

2360 pass 

2361 

2362 spam2 = spam 

2363 """) 

2364 self.before_p.b = prev_b 

2365 self.after_p.b = next_b 

2366 c.selectPosition(self.after_p) 

2367 # Delete 'after', select 'before' 

2368 c.k.simulateCommand('merge-node-with-prev-node') 

2369 self.assertEqual(c.p.h, 'before') 

2370 self.assertEqual(c.p.b, result_b) 

2371 self.assertFalse(c.p.next()) 

2372 # Restore 'after', select, 'after'. 

2373 u.undo() 

2374 self.assertEqual(c.p.h, 'after') 

2375 self.assertEqual(c.p.b, next_b) 

2376 self.assertEqual(c.p.back().h, 'before') 

2377 self.assertEqual(c.p.back().b, prev_b) 

2378 u.redo() 

2379 self.assertEqual(c.p.h, 'before') 

2380 self.assertEqual(c.p.b, result_b) 

2381 self.assertFalse(c.p.next()) 

2382 #@+node:ekr.20201130090918.86: *5* move-lines-down 

2383 def test_move_lines_down(self): 

2384 """Test case for move-lines-down""" 

2385 before_b = """\ 

2386 first line 

2387 line 1 

2388 line a 

2389 line b 

2390 line c 

2391 last line 

2392 """ 

2393 after_b = """\ 

2394 first line 

2395 line 1 

2396 line c 

2397 line a 

2398 line b 

2399 last line 

2400 """ 

2401 self.run_test( 

2402 before_b=before_b, 

2403 after_b=after_b, 

2404 before_sel=("3.3", "4.3"), 

2405 after_sel=("4.3", "5.3"), 

2406 command_name="move-lines-down", 

2407 ) 

2408 #@+node:ekr.20201130090918.87: *5* move-lines-up 

2409 def test_move_lines_up(self): 

2410 """Test case for move-lines-up""" 

2411 before_b = """\ 

2412 first line 

2413 line 1 

2414 line a 

2415 line b 

2416 line c 

2417 last line 

2418 """ 

2419 after_b = """\ 

2420 line 1 

2421 first line 

2422 line a 

2423 line b 

2424 line c 

2425 last line 

2426 """ 

2427 self.run_test( 

2428 before_b=before_b, 

2429 after_b=after_b, 

2430 before_sel=("2.2", "2.2"), 

2431 after_sel=("1.2", "1.2"), 

2432 command_name="move-lines-up", 

2433 ) 

2434 #@+node:ekr.20201130090918.88: *5* move-lines-up (into docstring) 

2435 def test_move_lines_up_into_docstring(self): 

2436 """Test case for move-lines-up (into docstring)""" 

2437 before_b = '''\ 

2438 #@@language python 

2439 def test(): 

2440 """ a 

2441 b 

2442 c 

2443 """ 

2444 print 1 

2445 

2446 print 2 

2447 ''' 

2448 after_b = '''\ 

2449 #@@language python 

2450 def test(): 

2451 """ a 

2452 b 

2453 c 

2454 print 1 

2455 """ 

2456 

2457 print 2 

2458 ''' 

2459 self.run_test( 

2460 before_b=before_b, 

2461 after_b=after_b, 

2462 before_sel=("7.1", "7.1"), 

2463 after_sel=("6.1", "6.1"), 

2464 command_name="move-lines-up", 

2465 ) 

2466 #@+node:ekr.20201130090918.89: *5* move-past-close 

2467 def test_move_past_close(self): 

2468 """Test case for move-past-close""" 

2469 before_b = """\ 

2470 first (line) 

2471 line 1 

2472 line a 

2473 line b 

2474 line c 

2475 last line 

2476 """ 

2477 after_b = """\ 

2478 first (line) 

2479 line 1 

2480 line a 

2481 line b 

2482 line c 

2483 last line 

2484 """ 

2485 self.run_test( 

2486 before_b=before_b, 

2487 after_b=after_b, 

2488 before_sel=("1.10", "1.10"), 

2489 after_sel=("1.12", "1.12"), 

2490 command_name="move-past-close", 

2491 ) 

2492 #@+node:ekr.20201130090918.90: *5* move-past-close-extend-selection 

2493 def test_move_past_close_extend_selection(self): 

2494 """Test case for move-past-close-extend-selection""" 

2495 before_b = """\ 

2496 first line 

2497 line 1 

2498 (line )a 

2499 line b 

2500 line c 

2501 last line 

2502 """ 

2503 after_b = """\ 

2504 first line 

2505 line 1 

2506 (line )a 

2507 line b 

2508 line c 

2509 last line 

2510 """ 

2511 self.run_test( 

2512 before_b=before_b, 

2513 after_b=after_b, 

2514 before_sel=("3.7", "3.7"), 

2515 after_sel=("3.7", "3.11"), 

2516 command_name="move-past-close-extend-selection", 

2517 ) 

2518 #@+node:ekr.20201130090918.91: *5* newline-and-indent 

2519 def test_newline_and_indent(self): 

2520 """Test case for newline-and-indent""" 

2521 before_b = textwrap.dedent("""\ 

2522 first line 

2523 line 1 

2524 line a 

2525 line b 

2526 line c 

2527 last line 

2528 """) 

2529 # docstrings strip blank lines, so we can't use a doctring here! 

2530 after_b = ''.join([ 

2531 'first line\n' 

2532 'line 1\n' 

2533 ' \n', # Would be stripped in a docstring! 

2534 ' line a\n' 

2535 ' line b\n' 

2536 'line c\n' 

2537 'last line\n' 

2538 ]) 

2539 self.run_test( 

2540 before_b=before_b, 

2541 after_b=after_b, 

2542 before_sel=("2.6", "2.6"), 

2543 after_sel=("3.4", "3.4"), 

2544 command_name="newline-and-indent", 

2545 dedent=False 

2546 ) 

2547 #@+node:ekr.20201130090918.92: *5* next-line 

2548 def test_next_line(self): 

2549 """Test case for next-line""" 

2550 before_b = """\ 

2551 a 

2552 

2553 b 

2554 """ 

2555 after_b = """\ 

2556 a 

2557 

2558 b 

2559 """ 

2560 self.run_test( 

2561 before_b=before_b, 

2562 after_b=after_b, 

2563 before_sel=("1.1", "1.1"), 

2564 after_sel=("2.0", "2.0"), 

2565 command_name="next-line", 

2566 ) 

2567 #@+node:ekr.20201130090918.93: *5* previous-line 

2568 def test_previous_line(self): 

2569 """Test case for previous-line""" 

2570 before_b = """\ 

2571 a 

2572 

2573 b 

2574 """ 

2575 after_b = """\ 

2576 a 

2577 

2578 b 

2579 """ 

2580 self.run_test( 

2581 before_b=before_b, 

2582 after_b=after_b, 

2583 before_sel=("3.0", "3.0"), 

2584 after_sel=("2.0", "2.0"), 

2585 command_name="previous-line", 

2586 ) 

2587 #@+node:ekr.20201130090918.94: *5* rectangle-clear 

2588 def test_rectangle_clear(self): 

2589 """Test case for rectangle-clear""" 

2590 before_b = """\ 

2591 before 

2592 aaaxxxbbb 

2593 aaaxxxbbb 

2594 aaaxxxbbb 

2595 aaaxxxbbb 

2596 after 

2597 """ 

2598 after_b = """\ 

2599 before 

2600 aaa bbb 

2601 aaa bbb 

2602 aaa bbb 

2603 aaa bbb 

2604 after 

2605 """ 

2606 self.run_test( 

2607 before_b=before_b, 

2608 after_b=after_b, 

2609 before_sel=("2.3", "5.6"), 

2610 after_sel=("2.3", "5.6"), 

2611 command_name="rectangle-clear", 

2612 ) 

2613 #@+node:ekr.20201130090918.95: *5* rectangle-close 

2614 def test_rectangle_close(self): 

2615 """Test case for rectangle-close""" 

2616 before_b = """\ 

2617 before 

2618 aaa bbb 

2619 aaa bbb 

2620 aaa bbb 

2621 aaa bbb 

2622 after 

2623 """ 

2624 after_b = """\ 

2625 before 

2626 aaabbb 

2627 aaabbb 

2628 aaabbb 

2629 aaabbb 

2630 after 

2631 """ 

2632 self.run_test( 

2633 before_b=before_b, 

2634 after_b=after_b, 

2635 before_sel=("2.3", "5.6"), 

2636 after_sel=("2.3", "5.3"), 

2637 command_name="rectangle-close", 

2638 ) 

2639 #@+node:ekr.20201130090918.96: *5* rectangle-delete 

2640 def test_rectangle_delete(self): 

2641 """Test case for rectangle-delete""" 

2642 before_b = """\ 

2643 before 

2644 aaaxxxbbb 

2645 aaaxxxbbb 

2646 aaaxxxbbb 

2647 aaaxxxbbb 

2648 after 

2649 """ 

2650 after_b = """\ 

2651 before 

2652 aaabbb 

2653 aaabbb 

2654 aaabbb 

2655 aaabbb 

2656 after 

2657 """ 

2658 self.run_test( 

2659 before_b=before_b, 

2660 after_b=after_b, 

2661 before_sel=("2.3", "5.6"), 

2662 after_sel=("2.3", "5.3"), 

2663 command_name="rectangle-delete", 

2664 ) 

2665 #@+node:ekr.20201130090918.97: *5* rectangle-kill 

2666 def test_rectangle_kill(self): 

2667 """Test case for rectangle-kill""" 

2668 before_b = """\ 

2669 before 

2670 aaaxxxbbb 

2671 aaaxxxbbb 

2672 aaaxxxbbb 

2673 aaaxxxbbb 

2674 after 

2675 """ 

2676 after_b = """\ 

2677 before 

2678 aaabbb 

2679 aaabbb 

2680 aaabbb 

2681 aaabbb 

2682 after 

2683 """ 

2684 self.run_test( 

2685 before_b=before_b, 

2686 after_b=after_b, 

2687 before_sel=("2.3", "5.6"), 

2688 after_sel=("5.3", "5.3"), 

2689 command_name="rectangle-kill", 

2690 ) 

2691 #@+node:ekr.20201130090918.98: *5* rectangle-open 

2692 def test_rectangle_open(self): 

2693 """Test case for rectangle-open""" 

2694 before_b = """\ 

2695 before 

2696 aaaxxxbbb 

2697 aaaxxxbbb 

2698 aaaxxxbbb 

2699 aaaxxxbbb 

2700 after 

2701 """ 

2702 after_b = """\ 

2703 before 

2704 aaa xxxbbb 

2705 aaa xxxbbb 

2706 aaa xxxbbb 

2707 aaa xxxbbb 

2708 after 

2709 """ 

2710 self.run_test( 

2711 before_b=before_b, 

2712 after_b=after_b, 

2713 before_sel=("2.3", "5.6"), 

2714 after_sel=("2.3", "5.6"), 

2715 command_name="rectangle-open", 

2716 ) 

2717 #@+node:ekr.20201130090918.99: *5* test_rectangle-string 

2718 def test_rectangle_string(self): 

2719 """Test case for rectangle-string""" 

2720 before_b = textwrap.dedent("""\ 

2721 before 

2722 aaaxxxbbb 

2723 aaaxxxbbb 

2724 aaaxxxbbb 

2725 aaaxxxbbb 

2726 after 

2727 """) 

2728 after_b = textwrap.dedent("""\ 

2729 before 

2730 aaas...sbbb 

2731 aaas...sbbb 

2732 aaas...sbbb 

2733 aaas...sbbb 

2734 after 

2735 """) 

2736 # A hack. The command tests for g.unitTesting! 

2737 self.run_test( 

2738 before_b=before_b, 

2739 after_b=after_b, 

2740 before_sel=("2.3", "5.6"), 

2741 after_sel=("2.3", "5.8"), 

2742 command_name="rectangle-string", 

2743 ) 

2744 #@+node:ekr.20201130090918.100: *5* test_rectangle-yank 

2745 def test_rectangle_yank(self): 

2746 """Test case for rectangle-yank""" 

2747 before_b = textwrap.dedent("""\ 

2748 before 

2749 aaaxxxbbb 

2750 aaaxxxbbb 

2751 aaaxxxbbb 

2752 aaaxxxbbb 

2753 after 

2754 """) 

2755 after_b = textwrap.dedent("""\ 

2756 before 

2757 aaaY1Ybbb 

2758 aaaY2Ybbb 

2759 aaaY3Ybbb 

2760 aaaY4Ybbb 

2761 after 

2762 """) 

2763 # A hack. The command tests for g.unitTesting! 

2764 self.run_test( 

2765 before_b=before_b, 

2766 after_b=after_b, 

2767 before_sel=("2.3", "5.6"), 

2768 after_sel=("2.3", "5.6"), 

2769 command_name="rectangle-yank", 

2770 ) 

2771 

2772 #@+node:ekr.20201130090918.122: *5* reformat-paragraph list 1 of 5 

2773 def test_reformat_paragraph_list_1_of_5(self): 

2774 """Test case for reformat-paragraph list 1 of 5""" 

2775 before_b = """\ 

2776 This paragraph leads of this test. It is the "lead" 

2777 paragraph. 

2778 

2779 1. This is item 

2780 number 1. It is the first item in the list. 

2781 

2782 2. This is item 

2783 number 2. It is the second item in the list. 

2784 

2785 3. This is item 

2786 number 3. It is the third item in the list. 

2787 

2788 This paragraph ends the test. It is the "final" 

2789 paragraph. 

2790 """ 

2791 after_b = """\ 

2792 This paragraph leads of this test. It is 

2793 the "lead" paragraph. 

2794 

2795 1. This is item 

2796 number 1. It is the first item in the list. 

2797 

2798 2. This is item 

2799 number 2. It is the second item in the list. 

2800 

2801 3. This is item 

2802 number 3. It is the third item in the list. 

2803 

2804 This paragraph ends the test. It is the "final" 

2805 paragraph. 

2806 """ 

2807 self.run_test( 

2808 before_b=before_b, 

2809 after_b=after_b, 

2810 before_sel=("1.0", "1.0"), 

2811 after_sel=("4.0", "4.0"), 

2812 command_name="reformat-paragraph", 

2813 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

2814 ) 

2815 #@+node:ekr.20201130090918.123: *5* reformat-paragraph list 2 of 5 

2816 def test_reformat_paragraph_list_2_of_5(self): 

2817 """Test case for reformat-paragraph list 2 of 5""" 

2818 before_b = """\ 

2819 This paragraph leads of this test. It is 

2820 the "lead" paragraph. 

2821 

2822 1. This is item number 1. It is the 

2823 first item in the list. 

2824 

2825 2. This is item 

2826 number 2. It is the second item in the list. 

2827 

2828 3. This is item 

2829 number 3. It is the third item in the list. 

2830 

2831 This paragraph ends the test. It is the "final" 

2832 paragraph. 

2833 """ 

2834 after_b = """\ 

2835 This paragraph leads of this test. It is 

2836 the "lead" paragraph. 

2837 

2838 1. This is item number 1. It is the 

2839 first item in the list. 

2840 

2841 2. This is item 

2842 number 2. It is the second item in the list. 

2843 

2844 3. This is item 

2845 number 3. It is the third item in the list. 

2846 

2847 This paragraph ends the test. It is the "final" 

2848 paragraph. 

2849 """ 

2850 self.run_test( 

2851 before_b=before_b, 

2852 after_b=after_b, 

2853 before_sel=("4.0", "4.0"), 

2854 after_sel=("7.0", "7.0"), 

2855 command_name="reformat-paragraph", 

2856 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

2857 ) 

2858 #@+node:ekr.20201130090918.124: *5* reformat-paragraph list 3 of 5 

2859 def test_reformat_paragraph_list_3_of_5(self): 

2860 """Test case for reformat-paragraph list 3 of 5""" 

2861 before_b = """\ 

2862 This paragraph leads of this test. It is 

2863 the "lead" paragraph. 

2864 

2865 1. This is item number 1. It is the 

2866 first item in the list. 

2867 

2868 2. This is item 

2869 number 2. It is the second item in the list. 

2870 

2871 3. This is item 

2872 number 3. It is the third item in the list. 

2873 

2874 This paragraph ends the test. It is the "final" 

2875 paragraph. 

2876 """ 

2877 after_b = """\ 

2878 This paragraph leads of this test. It is 

2879 the "lead" paragraph. 

2880 

2881 1. This is item number 1. It is the 

2882 first item in the list. 

2883 

2884 2. This is item number 2. It is the 

2885 second item in the list. 

2886 

2887 3. This is item 

2888 number 3. It is the third item in the list. 

2889 

2890 This paragraph ends the test. It is the "final" 

2891 paragraph. 

2892 """ 

2893 self.run_test( 

2894 before_b=before_b, 

2895 after_b=after_b, 

2896 before_sel=("7.0", "7.0"), 

2897 after_sel=("10.0", "10.0"), 

2898 command_name="reformat-paragraph", 

2899 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

2900 ) 

2901 #@+node:ekr.20201130090918.125: *5* reformat-paragraph list 4 of 5 

2902 def test_reformat_paragraph_list_4_of_5(self): 

2903 """Test case for reformat-paragraph list 4 of 5""" 

2904 before_b = """\ 

2905 This paragraph leads of this test. It is 

2906 the "lead" paragraph. 

2907 

2908 1. This is item number 1. It is the 

2909 first item in the list. 

2910 

2911 2. This is item number 2. It is the 

2912 second item in the list. 

2913 

2914 3. This is item 

2915 number 3. It is the third item in the list. 

2916 

2917 This paragraph ends the test. It is the "final" 

2918 paragraph. 

2919 """ 

2920 after_b = """\ 

2921 This paragraph leads of this test. It is 

2922 the "lead" paragraph. 

2923 

2924 1. This is item number 1. It is the 

2925 first item in the list. 

2926 

2927 2. This is item number 2. It is the 

2928 second item in the list. 

2929 

2930 3. This is item number 3. It is the 

2931 third item in the list. 

2932 

2933 This paragraph ends the test. It is the "final" 

2934 paragraph. 

2935 """ 

2936 self.run_test( 

2937 before_b=before_b, 

2938 after_b=after_b, 

2939 before_sel=("10.0", "10.0"), 

2940 after_sel=("13.0", "13.0"), 

2941 command_name="reformat-paragraph", 

2942 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

2943 ) 

2944 #@+node:ekr.20201130090918.126: *5* reformat-paragraph list 5 of 5 

2945 def test_reformat_paragraph_list_5_of_5(self): 

2946 """Test case for reformat-paragraph list 5 of 5""" 

2947 before_b = """\ 

2948 This paragraph leads of this test. It is 

2949 the "lead" paragraph. 

2950 

2951 1. This is item number 1. It is the 

2952 first item in the list. 

2953 

2954 2. This is item number 2. It is the 

2955 second item in the list. 

2956 

2957 3. This is item number 3. It is the 

2958 third item in the list. 

2959 

2960 This paragraph ends the test. It is the "final" 

2961 paragraph. 

2962 """ 

2963 after_b = """\ 

2964 This paragraph leads of this test. It is 

2965 the "lead" paragraph. 

2966 

2967 1. This is item number 1. It is the 

2968 first item in the list. 

2969 

2970 2. This is item number 2. It is the 

2971 second item in the list. 

2972 

2973 3. This is item number 3. It is the 

2974 third item in the list. 

2975 

2976 This paragraph ends the test. It is the 

2977 "final" paragraph. 

2978 """ 

2979 self.run_test( 

2980 before_b=before_b, 

2981 after_b=after_b, 

2982 before_sel=("13.0", "13.0"), 

2983 after_sel=("15.1", "15.1"), 

2984 command_name="reformat-paragraph", 

2985 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

2986 ) 

2987 #@+node:ekr.20201130090918.127: *5* reformat-paragraph new code 1 of 8 

2988 def test_reformat_paragraph_new_code_1_of_8(self): 

2989 """Test case for reformat-paragraph new code 1 of 8""" 

2990 before_b = """\ 

2991 #@@pagewidth 40 

2992 ''' 

2993 docstring. 

2994 ''' 

2995 """ 

2996 after_b = """\ 

2997 #@@pagewidth 40 

2998 ''' 

2999 docstring. 

3000 ''' 

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=("2.0", "2.0"), 

3007 command_name="reformat-paragraph", 

3008 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3009 ) 

3010 #@+node:ekr.20201130090918.128: *5* reformat-paragraph new code 2 of 8 

3011 def test_reformat_paragraph_new_code_2_of_8(self): 

3012 """Test case for reformat-paragraph new code 2 of 8""" 

3013 before_b = """\ 

3014 #@@pagewidth 40 

3015 ''' 

3016 docstring. 

3017 ''' 

3018 """ 

3019 after_b = """\ 

3020 #@@pagewidth 40 

3021 ''' 

3022 docstring. 

3023 ''' 

3024 """ 

3025 self.run_test( 

3026 before_b=before_b, 

3027 after_b=after_b, 

3028 before_sel=("2.0", "2.0"), 

3029 after_sel=("3.0", "3.0"), 

3030 command_name="reformat-paragraph", 

3031 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3032 ) 

3033 #@+node:ekr.20201130090918.129: *5* reformat-paragraph new code 3 of 8 

3034 def test_reformat_paragraph_new_code_3_of_8(self): 

3035 """Test case for reformat-paragraph new code 3 of 8""" 

3036 before_b = """\ 

3037 #@@pagewidth 40 

3038 ''' 

3039 docstring. 

3040 more docstring. 

3041 ''' 

3042 """ 

3043 after_b = """\ 

3044 #@@pagewidth 40 

3045 ''' 

3046 docstring. more docstring. 

3047 ''' 

3048 """ 

3049 self.run_test( 

3050 before_b=before_b, 

3051 after_b=after_b, 

3052 before_sel=("3.1", "4.1"), 

3053 after_sel=("4.0", "4.0"), 

3054 command_name="reformat-paragraph", 

3055 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3056 ) 

3057 #@+node:ekr.20201130090918.130: *5* reformat-paragraph new code 4 of 8 

3058 def test_reformat_paragraph_new_code_4_of_8(self): 

3059 """Test case for reformat-paragraph new code 4 of 8""" 

3060 before_b = """\ 

3061 - Point 1. xxxxxxxxxxxxxxxxxxxxxxxxxxxx 

3062 Line 11. 

3063 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3064 """ 

3065 after_b = """\ 

3066 - Point 1. xxxxxxxxxxxxxxxxxxxxxxxxxxxx 

3067 Line 11. 

3068 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3069 """ 

3070 self.run_test( 

3071 before_b=before_b, 

3072 after_b=after_b, 

3073 before_sel=("1.0", "1.0"), 

3074 after_sel=("3.0", "3.0"), 

3075 command_name="reformat-paragraph", 

3076 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3077 ) 

3078 #@+node:ekr.20201130090918.131: *5* reformat-paragraph new code 5 of 8 

3079 def test_reformat_paragraph_new_code_5_of_8(self): 

3080 """Test case for reformat-paragraph new code 5 of 8""" 

3081 before_b = """\ 

3082 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3083 Line 22. 

3084 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3085 """ 

3086 after_b = """\ 

3087 A. Point 2. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3088 Line 22. 

3089 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3090 """ 

3091 self.run_test( 

3092 before_b=before_b, 

3093 after_b=after_b, 

3094 before_sel=("1.0", "2.0"), 

3095 after_sel=("3.0", "3.0"), 

3096 command_name="reformat-paragraph", 

3097 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3098 ) 

3099 #@+node:ekr.20201130090918.132: *5* reformat-paragraph new code 6 of 8 

3100 def test_reformat_paragraph_new_code_6_of_8(self): 

3101 """Test case for reformat-paragraph new code 6 of 8""" 

3102 before_b = """\ 

3103 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3104 Line 32. 

3105 

3106 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3107 """ 

3108 after_b = """\ 

3109 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3110 Line 32. 

3111 

3112 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3113 """ 

3114 self.run_test( 

3115 before_b=before_b, 

3116 after_b=after_b, 

3117 before_sel=("1.0", "1.0"), 

3118 after_sel=("4.0", "4.0"), 

3119 command_name="reformat-paragraph", 

3120 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3121 ) 

3122 #@+node:ekr.20201130090918.133: *5* reformat-paragraph new code 7 of 8 

3123 def test_reformat_paragraph_new_code_7_of_8(self): 

3124 """Test case for reformat-paragraph new code 7 of 8""" 

3125 before_b = """\ 

3126 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3127 Line 32. 

3128 

3129 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3130 Line 41. 

3131 """ 

3132 after_b = """\ 

3133 1. Point 3. xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3134 Line 32. 

3135 

3136 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3137 Line 41. 

3138 """ 

3139 self.run_test( 

3140 before_b=before_b, 

3141 after_b=after_b, 

3142 before_sel=("2.11", "2.11"), 

3143 after_sel=("3.1", "3.1"), 

3144 command_name="reformat-paragraph", 

3145 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3146 ) 

3147 #@+node:ekr.20201130090918.134: *5* reformat-paragraph new code 8 of 8 

3148 def test_reformat_paragraph_new_code_8_of_8(self): 

3149 """Test case for reformat-paragraph new code 8 of 8""" 

3150 before_b = """\ 

3151 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3152 Line 41. 

3153 """ 

3154 after_b = """\ 

3155 2. Point 4 xxxxxxxxxxxxxxxxxxxxxxxxxxx 

3156 Line 41. 

3157 """ 

3158 self.run_test( 

3159 before_b=before_b, 

3160 after_b=after_b, 

3161 before_sel=("1.0", "1.0"), 

3162 after_sel=("3.0", "3.0"), 

3163 command_name="reformat-paragraph", 

3164 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3165 ) 

3166 #@+node:ekr.20201130090918.135: *5* reformat-paragraph paragraph 1 of 3 

3167 def test_reformat_paragraph_paragraph_1_of_3(self): 

3168 """Test case for reformat-paragraph paragraph 1 of 3""" 

3169 before_b = """\ 

3170 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. 

3171 

3172 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. 

3173 

3174 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? 

3175 

3176 Last paragraph. 

3177 """ 

3178 after_b = """\ 

3179 Americans live in the most severe 

3180 weather-prone country on Earth. Each 

3181 year, Americans cope with an average of 

3182 10,000 thunderstorms, 2,500 floods, 

3183 1,000 tornadoes, as well as an average 

3184 of 6 deadly hurricanes. Potentially 

3185 deadly weather impacts every American. 

3186 Communities can now rely on the National 

3187 Weather Service’s StormReady program to 

3188 help them guard against the ravages of 

3189 Mother Nature. 

3190 

3191 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. 

3192 

3193 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? 

3194 

3195 Last paragraph. 

3196 """ 

3197 self.run_test( 

3198 before_b=before_b, 

3199 after_b=after_b, 

3200 before_sel=("1.0", "1.0"), 

3201 after_sel=("13.0", "13.0"), 

3202 command_name="reformat-paragraph", 

3203 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3204 ) 

3205 #@+node:ekr.20201130090918.136: *5* reformat-paragraph paragraph 2 of 3 

3206 def test_reformat_paragraph_paragraph_2_of_3(self): 

3207 """Test case for reformat-paragraph paragraph 2 of 3""" 

3208 before_b = """\ 

3209 Americans live in the most severe 

3210 weather-prone country on Earth. Each 

3211 year, Americans cope with an average of 

3212 10,000 thunderstorms, 2,500 floods, 

3213 1,000 tornadoes, as well as an average 

3214 of 6 deadly hurricanes. Potentially 

3215 deadly weather impacts every American. 

3216 Communities can now rely on the National 

3217 Weather Service’s StormReady program to 

3218 help them guard against the ravages of 

3219 Mother Nature. 

3220 

3221 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. 

3222 

3223 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? 

3224 

3225 Last paragraph. 

3226 """ 

3227 after_b = """\ 

3228 Americans live in the most severe 

3229 weather-prone country on Earth. Each 

3230 year, Americans cope with an average of 

3231 10,000 thunderstorms, 2,500 floods, 

3232 1,000 tornadoes, as well as an average 

3233 of 6 deadly hurricanes. Potentially 

3234 deadly weather impacts every American. 

3235 Communities can now rely on the National 

3236 Weather Service’s StormReady program to 

3237 help them guard against the ravages of 

3238 Mother Nature. 

3239 

3240 Some 90% of all presidentially declared 

3241 disasters are weather related, leading 

3242 to around 500 deaths per year and nearly 

3243 $14 billion in damage. StormReady, a 

3244 program started in 1999 in Tulsa, OK, 

3245 helps arm America's communities with the 

3246 communication and safety skills needed 

3247 to save lives and property– before and 

3248 during the event. StormReady helps 

3249 community leaders and emergency managers 

3250 strengthen local safety programs. 

3251 

3252 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? 

3253 

3254 Last paragraph. 

3255 """ 

3256 self.run_test( 

3257 before_b=before_b, 

3258 after_b=after_b, 

3259 before_sel=("13.0", "13.0"), 

3260 after_sel=("25.0", "25.0"), 

3261 command_name="reformat-paragraph", 

3262 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3263 ) 

3264 #@+node:ekr.20201130090918.137: *5* reformat-paragraph paragraph 3 of 3 

3265 def test_reformat_paragraph_paragraph_3_of_3(self): 

3266 """Test case for reformat-paragraph paragraph 3 of 3""" 

3267 before_b = """\ 

3268 Americans live in the most severe 

3269 weather-prone country on Earth. Each 

3270 year, Americans cope with an average of 

3271 10,000 thunderstorms, 2,500 floods, 

3272 1,000 tornadoes, as well as an average 

3273 of 6 deadly hurricanes. Potentially 

3274 deadly weather impacts every American. 

3275 Communities can now rely on the National 

3276 Weather Service’s StormReady program to 

3277 help them guard against the ravages of 

3278 Mother Nature. 

3279 

3280 Some 90% of all presidentially declared 

3281 disasters are weather related, leading 

3282 to around 500 deaths per year and nearly 

3283 $14 billion in damage. StormReady, a 

3284 program started in 1999 in Tulsa, OK, 

3285 helps arm America's communities with the 

3286 communication and safety skills needed 

3287 to save lives and property– before and 

3288 during the event. StormReady helps 

3289 community leaders and emergency managers 

3290 strengthen local safety programs. 

3291 

3292 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? 

3293 

3294 Last paragraph. 

3295 """ 

3296 after_b = """\ 

3297 Americans live in the most severe 

3298 weather-prone country on Earth. Each 

3299 year, Americans cope with an average of 

3300 10,000 thunderstorms, 2,500 floods, 

3301 1,000 tornadoes, as well as an average 

3302 of 6 deadly hurricanes. Potentially 

3303 deadly weather impacts every American. 

3304 Communities can now rely on the National 

3305 Weather Service’s StormReady program to 

3306 help them guard against the ravages of 

3307 Mother Nature. 

3308 

3309 Some 90% of all presidentially declared 

3310 disasters are weather related, leading 

3311 to around 500 deaths per year and nearly 

3312 $14 billion in damage. StormReady, a 

3313 program started in 1999 in Tulsa, OK, 

3314 helps arm America's communities with the 

3315 communication and safety skills needed 

3316 to save lives and property– before and 

3317 during the event. StormReady helps 

3318 community leaders and emergency managers 

3319 strengthen local safety programs. 

3320 

3321 StormReady communities are better 

3322 prepared to save lives from the 

3323 onslaught of severe weather through 

3324 better planning, education, and 

3325 awareness. No community is storm proof, 

3326 but StormReady can help communities save 

3327 lives. Does StormReady make a 

3328 difference? 

3329 

3330 Last paragraph. 

3331 """ 

3332 self.run_test( 

3333 before_b=before_b, 

3334 after_b=after_b, 

3335 before_sel=("25.10", "25.10"), 

3336 after_sel=("34.0", "34.0"), 

3337 command_name="reformat-paragraph", 

3338 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3339 ) 

3340 #@+node:ekr.20201130090918.138: *5* reformat-paragraph simple hanging indent 

3341 def test_reformat_paragraph_simple_hanging_indent(self): 

3342 """Test case for reformat-paragraph simple hanging indent""" 

3343 before_b = """\ 

3344 Honor this line that has a hanging indentation, please. Hanging 

3345 indentation is valuable for lists of all kinds. But it is tricky to get right. 

3346 

3347 Next paragraph. 

3348 """ 

3349 after_b = """\ 

3350 Honor this line that has a hanging 

3351 indentation, please. Hanging 

3352 indentation is valuable for lists of 

3353 all kinds. But it is tricky to get 

3354 right. 

3355 

3356 Next paragraph. 

3357 """ 

3358 self.run_test( 

3359 before_b=before_b, 

3360 after_b=after_b, 

3361 before_sel=("1.0", "1.0"), 

3362 after_sel=("7.0", "7.0"), 

3363 command_name="reformat-paragraph", 

3364 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3365 ) 

3366 #@+node:ekr.20201130090918.139: *5* reformat-paragraph simple hanging indent 2 

3367 def test_reformat_paragraph_simple_hanging_indent_2(self): 

3368 """Test case for reformat-paragraph simple hanging indent 2""" 

3369 before_b = """\ 

3370 Honor this line that has 

3371 a hanging indentation, please. Hanging 

3372 indentation is valuable for lists of all kinds. But it is tricky to get right. 

3373 

3374 Next paragraph. 

3375 """ 

3376 after_b = """\ 

3377 Honor this line that has a hanging 

3378 indentation, please. Hanging 

3379 indentation is valuable for lists of 

3380 all kinds. But it is tricky to get 

3381 right. 

3382 

3383 Next paragraph. 

3384 """ 

3385 self.run_test( 

3386 before_b=before_b, 

3387 after_b=after_b, 

3388 before_sel=("2.0", "2.0"), 

3389 after_sel=("7.0", "7.0"), 

3390 command_name="reformat-paragraph", 

3391 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3392 ) 

3393 #@+node:ekr.20201130090918.140: *5* reformat-paragraph simple hanging indent 3 

3394 def test_reformat_paragraph_simple_hanging_indent_3(self): 

3395 """Test case for reformat-paragraph simple hanging indent 3""" 

3396 before_b = """\ 

3397 Honor this line that 

3398 has a hanging indentation, 

3399 please. Hanging 

3400 indentation is valuable 

3401 for lists of all kinds. But 

3402 it is tricky to get right. 

3403 

3404 Next Paragraph. 

3405 """ 

3406 after_b = """\ 

3407 Honor this line that has a hanging 

3408 indentation, please. Hanging 

3409 indentation is valuable for lists of 

3410 all kinds. But it is tricky to get 

3411 right. 

3412 

3413 Next Paragraph. 

3414 """ 

3415 self.run_test( 

3416 before_b=before_b, 

3417 after_b=after_b, 

3418 before_sel=("1.0", "1.0"), 

3419 after_sel=("7.0", "7.0"), 

3420 command_name="reformat-paragraph", 

3421 directives="@language plain\n@pagewidth 40\n@tabwidth 8", 

3422 ) 

3423 #@+node:ekr.20201130090918.101: *5* remove-blank-lines 

3424 def test_remove_blank_lines(self): 

3425 """Test case for remove-blank-lines""" 

3426 before_b = """\ 

3427 first line 

3428 

3429 line 1 

3430 line a 

3431 line b 

3432 

3433 line c 

3434 last line 

3435 """ 

3436 after_b = """\ 

3437 first line 

3438 line 1 

3439 line a 

3440 line b 

3441 line c 

3442 last line 

3443 """ 

3444 self.run_test( 

3445 before_b=before_b, 

3446 after_b=after_b, 

3447 before_sel=("1.0", "9.0"), 

3448 after_sel=("1.0", "6.9"), 

3449 command_name="remove-blank-lines", 

3450 ) 

3451 #@+node:ekr.20201130090918.102: *5* remove-space-from-lines 

3452 def test_remove_space_from_lines(self): 

3453 """Test case for remove-space-from-lines""" 

3454 before_b = """\ 

3455 first line 

3456 

3457 line 1 

3458 line a 

3459 line b 

3460 

3461 line c 

3462 last line 

3463 """ 

3464 after_b = """\ 

3465 first line 

3466 

3467 line 1 

3468 line a 

3469 line b 

3470 

3471 line c 

3472 last line 

3473 """ 

3474 self.run_test( 

3475 before_b=before_b, 

3476 after_b=after_b, 

3477 before_sel=("1.0", "9.0"), 

3478 after_sel=("1.0", "9.0"), 

3479 command_name="remove-space-from-lines", 

3480 ) 

3481 #@+node:ekr.20201130090918.103: *5* remove-tab-from-lines 

3482 def test_remove_tab_from_lines(self): 

3483 """Test case for remove-tab-from-lines""" 

3484 before_b = """\ 

3485 first line 

3486 line 1 

3487 line a 

3488 line b 

3489 line c 

3490 last line 

3491 """ 

3492 after_b = """\ 

3493 first line 

3494 line 1 

3495 line a 

3496 line b 

3497 line c 

3498 last line 

3499 """ 

3500 self.run_test( 

3501 before_b=before_b, 

3502 after_b=after_b, 

3503 before_sel=("1.0", "7.0"), 

3504 after_sel=("1.0", "7.0"), 

3505 command_name="remove-tab-from-lines", 

3506 ) 

3507 #@+node:ekr.20201130090918.104: *5* reverse-region 

3508 def test_reverse_region(self): 

3509 """Test case for reverse-region""" 

3510 before_b = """\ 

3511 first line 

3512 line 1 

3513 line a 

3514 line b 

3515 line c 

3516 last line 

3517 """ 

3518 after_b = """\ 

3519 

3520 last line 

3521 line c 

3522 line b 

3523 line a 

3524 line 1 

3525 first line 

3526 """ 

3527 self.run_test( 

3528 before_b=before_b, 

3529 after_b=after_b, 

3530 before_sel=("1.0", "7.0"), 

3531 after_sel=("7.10", "7.10"), 

3532 command_name="reverse-region", 

3533 ) 

3534 #@+node:ekr.20201130090918.105: *5* reverse-sort-lines 

3535 def test_reverse_sort_lines(self): 

3536 """Test case for reverse-sort-lines""" 

3537 before_b = """\ 

3538 a 

3539 d 

3540 e 

3541 z 

3542 x 

3543 """ 

3544 after_b = """\ 

3545 z 

3546 x 

3547 e 

3548 d 

3549 a 

3550 """ 

3551 self.run_test( 

3552 before_b=before_b, 

3553 after_b=after_b, 

3554 before_sel=("1.0", "5.1"), 

3555 after_sel=("1.0", "5.1"), 

3556 command_name="reverse-sort-lines", 

3557 ) 

3558 #@+node:ekr.20201130090918.106: *5* reverse-sort-lines-ignoring-case 

3559 def test_reverse_sort_lines_ignoring_case(self): 

3560 """Test case for reverse-sort-lines-ignoring-case""" 

3561 before_b = """\ 

3562 c 

3563 A 

3564 z 

3565 X 

3566 Y 

3567 b 

3568 """ 

3569 after_b = """\ 

3570 z 

3571 Y 

3572 X 

3573 c 

3574 b 

3575 A 

3576 """ 

3577 self.run_test( 

3578 before_b=before_b, 

3579 after_b=after_b, 

3580 before_sel=("1.0", "6.1"), 

3581 after_sel=("1.0", "6.1"), 

3582 command_name="reverse-sort-lines-ignoring-case", 

3583 ) 

3584 #@+node:ekr.20210829062731.1: *4* Commands S-Z 

3585 #@+node:ekr.20201130090918.107: *5* sort-columns 

3586 def test_sort_columns(self): 

3587 """Test case for sort-columns""" 

3588 before_b = """\ 

3589 first line 

3590 line 1 

3591 line a 

3592 line b 

3593 line c 

3594 last line 

3595 """ 

3596 after_b = """\ 

3597 line b 

3598 line a 

3599 first line 

3600 last line 

3601 line 1 

3602 line c 

3603 """ 

3604 self.run_test( 

3605 before_b=before_b, 

3606 after_b=after_b, 

3607 before_sel=("1.0", "6.2"), 

3608 after_sel=("1.0", "7.0"), 

3609 command_name="sort-columns", 

3610 ) 

3611 #@+node:ekr.20201130090918.108: *5* sort-lines 

3612 def test_sort_lines(self): 

3613 """Test case for sort-lines""" 

3614 before_b = """\ 

3615 first line 

3616 line 1 

3617 line a 

3618 line b 

3619 line c 

3620 last line 

3621 """ 

3622 after_b = """\ 

3623 first line 

3624 line b 

3625 line a 

3626 line 1 

3627 line c 

3628 last line 

3629 """ 

3630 self.run_test( 

3631 before_b=before_b, 

3632 after_b=after_b, 

3633 before_sel=("2.0", "5.6"), 

3634 after_sel=("2.0", "5.6"), 

3635 command_name="sort-lines", 

3636 ) 

3637 #@+node:ekr.20201130090918.109: *5* sort-lines-ignoring-case 

3638 def test_sort_lines_ignoring_case(self): 

3639 """Test case for sort-lines-ignoring-case""" 

3640 before_b = """\ 

3641 x 

3642 z 

3643 A 

3644 c 

3645 B 

3646 """ 

3647 after_b = """\ 

3648 A 

3649 B 

3650 c 

3651 x 

3652 z 

3653 """ 

3654 self.run_test( 

3655 before_b=before_b, 

3656 after_b=after_b, 

3657 before_sel=("1.0", "5.1"), 

3658 after_sel=("1.0", "5.1"), 

3659 command_name="sort-lines-ignoring-case", 

3660 ) 

3661 #@+node:ekr.20201130090918.110: *5* split-line 

3662 def test_split_line(self): 

3663 """Test case for split-line""" 

3664 before_b = """\ 

3665 first line 

3666 line 1 

3667 line a 

3668 line b 

3669 line c 

3670 last line 

3671 """ 

3672 after_b = """\ 

3673 first 

3674 line 

3675 line 1 

3676 line a 

3677 line b 

3678 line c 

3679 last line 

3680 """ 

3681 self.run_test( 

3682 before_b=before_b, 

3683 after_b=after_b, 

3684 before_sel=("1.5", "1.5"), 

3685 after_sel=("2.0", "2.0"), 

3686 command_name="split-line", 

3687 ) 

3688 #@+node:ekr.20201130090918.111: *5* start-of-line 

3689 def test_start_of_line(self): 

3690 """Test case for start-of-line""" 

3691 before_b = """\ 

3692 first line 

3693 line 1 

3694 line a 

3695 line b 

3696 line c 

3697 last line 

3698 """ 

3699 after_b = """\ 

3700 first line 

3701 line 1 

3702 line a 

3703 line b 

3704 line c 

3705 last line 

3706 """ 

3707 self.run_test( 

3708 before_b=before_b, 

3709 after_b=after_b, 

3710 before_sel=("3.10", "3.10"), 

3711 after_sel=("3.4", "3.4"), 

3712 command_name="start-of-line", 

3713 ) 

3714 #@+node:ekr.20201130090918.112: *5* start-of-line (2) 

3715 def test_start_of_line_2(self): 

3716 """Test case for start-of-line (2)""" 

3717 before_b = """\ 

3718 first line 

3719 line 1 

3720 line a 

3721 line b 

3722 line c 

3723 last line 

3724 """ 

3725 after_b = """\ 

3726 first line 

3727 line 1 

3728 line a 

3729 line b 

3730 line c 

3731 last line 

3732 """ 

3733 self.run_test( 

3734 before_b=before_b, 

3735 after_b=after_b, 

3736 before_sel=("3.1", "3.1"), 

3737 after_sel=("3.4", "3.4"), 

3738 command_name="start-of-line", 

3739 ) 

3740 #@+node:ekr.20201130090918.113: *5* start-of-line-extend-selection 

3741 def test_start_of_line_extend_selection(self): 

3742 """Test case for start-of-line-extend-selection""" 

3743 before_b = """\ 

3744 first line 

3745 line 1 

3746 line a 

3747 line b 

3748 line c 

3749 last line 

3750 """ 

3751 after_b = """\ 

3752 first line 

3753 line 1 

3754 line a 

3755 line b 

3756 line c 

3757 last line 

3758 """ 

3759 self.run_test( 

3760 before_b=before_b, 

3761 after_b=after_b, 

3762 before_sel=("3.10", "3.10"), 

3763 after_sel=("3.4", "3.10"), 

3764 command_name="start-of-line-extend-selection", 

3765 ) 

3766 #@+node:ekr.20201130090918.114: *5* start-of-line-extend-selection (2) 

3767 def test_start_of_line_extend_selection_2(self): 

3768 """Test case for start-of-line-extend-selection (2)""" 

3769 before_b = """\ 

3770 first line 

3771 line 1 

3772 line a 

3773 line b 

3774 line c 

3775 last line 

3776 """ 

3777 after_b = """\ 

3778 first line 

3779 line 1 

3780 line a 

3781 line b 

3782 line c 

3783 last line 

3784 """ 

3785 self.run_test( 

3786 before_b=before_b, 

3787 after_b=after_b, 

3788 before_sel=("3.1", "3.1"), 

3789 after_sel=("3.1", "3.4"), 

3790 command_name="start-of-line-extend-selection", 

3791 ) 

3792 #@+node:ekr.20201130090918.115: *5* tabify 

3793 def test_tabify(self): 

3794 """Test case for tabify""" 

3795 before_b = """\ 

3796 first line 

3797 line 1 

3798 line a 

3799 line b 

3800 line c 

3801 last line 

3802 """ 

3803 after_b = """\ 

3804 first line 

3805 line 1 

3806 TABline a 

3807 TABTABline b 

3808 line c 

3809 last line 

3810 """.replace('TAB', '\t') 

3811 self.run_test( 

3812 before_b=before_b, 

3813 after_b=after_b, 

3814 before_sel=("1.0", "7.0"), 

3815 after_sel=("7.0", "7.0"), 

3816 command_name="tabify", 

3817 ) 

3818 #@+node:ekr.20201130090918.116: *5* transpose-chars 

3819 def test_transpose_chars(self): 

3820 """Test case for transpose-chars""" 

3821 before_b = """\ 

3822 first line 

3823 line 1 

3824 line a 

3825 line b 

3826 line c 

3827 last line 

3828 """ 

3829 after_b = """\ 

3830 frist line 

3831 line 1 

3832 line a 

3833 line b 

3834 line c 

3835 last line 

3836 """ 

3837 self.run_test( 

3838 before_b=before_b, 

3839 after_b=after_b, 

3840 before_sel=("1.2", "1.2"), 

3841 after_sel=("1.2", "1.2"), 

3842 command_name="transpose-chars", 

3843 ) 

3844 #@+node:ekr.20201130090918.117: *5* transpose-lines 

3845 def test_transpose_lines(self): 

3846 """Test case for transpose-lines""" 

3847 before_b = """\ 

3848 first line 

3849 line 1 

3850 line a 

3851 line b 

3852 line c 

3853 last line 

3854 """ 

3855 after_b = """\ 

3856 line 1 

3857 first line 

3858 line a 

3859 line b 

3860 line c 

3861 last line 

3862 """ 

3863 self.run_test( 

3864 before_b=before_b, 

3865 after_b=after_b, 

3866 before_sel=("2.2", "2.2"), 

3867 after_sel=("2.10", "2.10"), 

3868 command_name="transpose-lines", 

3869 ) 

3870 #@+node:ekr.20201130090918.118: *5* transpose-words 

3871 def test_transpose_words(self): 

3872 """Test case for transpose-words""" 

3873 before_b = """\ 

3874 first line 

3875 before bar2 += foo after 

3876 last line 

3877 """ 

3878 after_b = """\ 

3879 first line 

3880 before foo += bar2 after 

3881 last line 

3882 """ 

3883 self.run_test( 

3884 before_b=before_b, 

3885 after_b=after_b, 

3886 before_sel=("2.9", "2.9"), 

3887 after_sel=("2.11", "2.11"), 

3888 command_name="transpose-words", 

3889 ) 

3890 #@+node:ekr.20201130090918.119: *5* untabify 

3891 def test_untabify(self): 

3892 """Test case for untabify""" 

3893 before_b = """\ 

3894 first line 

3895 line 1 

3896 TABline a 

3897 TABTABline b 

3898 line c 

3899 last line 

3900 """.replace('TAB', '\t') 

3901 after_b = """\ 

3902 first line 

3903 line 1 

3904 line a 

3905 line b 

3906 line c 

3907 last line 

3908 """.replace('TAB', '\t') 

3909 self.run_test( 

3910 before_b=before_b, 

3911 after_b=after_b, 

3912 before_sel=("1.0", "7.0"), 

3913 after_sel=("7.0", "7.0"), 

3914 command_name="untabify", 

3915 ) 

3916 #@+node:ekr.20201130090918.120: *5* upcase-region 

3917 def test_upcase_region(self): 

3918 """Test case for upcase-region""" 

3919 before_b = """\ 

3920 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. 

3921 

3922 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. 

3923 

3924 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? 

3925 """ 

3926 after_b = """\ 

3927 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. 

3928 

3929 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. 

3930 

3931 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? 

3932 """ 

3933 self.run_test( 

3934 before_b=before_b, 

3935 after_b=after_b, 

3936 before_sel=("3.0", "4.0"), 

3937 after_sel=("3.0", "4.0"), 

3938 command_name="upcase-region", 

3939 ) 

3940 #@+node:ekr.20201130090918.121: *5* upcase-word 

3941 def test_upcase_word(self): 

3942 """Test case for upcase-word""" 

3943 before_b = """\ 

3944 first line 

3945 line 1 

3946 line a 

3947 line b 

3948 line c 

3949 last line 

3950 """ 

3951 after_b = """\ 

3952 first line 

3953 line 1 

3954 LINE a 

3955 line b 

3956 line c 

3957 last line 

3958 """ 

3959 self.run_test( 

3960 before_b=before_b, 

3961 after_b=after_b, 

3962 before_sel=("3.7", "3.7"), 

3963 after_sel=("3.7", "3.7"), 

3964 command_name="upcase-word", 

3965 ) 

3966 #@+node:ekr.20210905064816.1: *3* TestEditCommands: Others 

3967 #@+node:ekr.20210905064816.2: *4* TestEditCommands.test_abbrevCommands_next_place 

3968 def test_abbrevCommands_next_place(self): 

3969 c = self.c 

3970 p = c.p 

3971 ac = c.abbrevCommands 

3972 assert ac 

3973 # pylint: disable=no-member 

3974 if c.abbrev_place_start is None or c.abbrev_place_end is None: 

3975 self.skipTest('no abbreviation settings') # #1345. 

3976 child = g.findNodeInTree(c, p, 'child') 

3977 assert child 

3978 i, j = 0, 0 

3979 # ac.make_script_substitutions(i,j,val) 

3980 # ac.find_place_holder(child,True) 

3981 new_s, i, j = ac.next_place(child.b, offset=0) 

3982 self.assertEqual(p.b, new_s) 

3983 self.assertEqual(i, 34) 

3984 self.assertEqual(j, 40) 

3985 new_s2, i, j = ac.next_place(new_s, offset=40) 

3986 self.assertEqual(i, 54) 

3987 self.assertEqual(j, 58) 

3988 

3989 #@+node:ekr.20210905064816.3: *4* TestEditCommands.test_addAbbrevHelper 

3990 def test_addAbbrevHelper(self): 

3991 c = self.c 

3992 f = c.abbrevCommands.addAbbrevHelper 

3993 d = c.abbrevCommands.abbrevs 

3994 

3995 # New in Leo 4.10: whitespace (blank,tab,newline) *is* significant in definitions. 

3996 table = ( 

3997 ('ut1', 'ut1=aa', 'aa'), 

3998 # ('ut2','ut2 =bb','bb'), 

3999 ('ut3', 'ut3=cc=dd', 'cc=dd'), 

4000 ('ut4', 'ut4= ee', ' ee'), 

4001 ('ut5', 'ut5= ff = gg', ' ff = gg'), 

4002 ('ut6', 'ut6= hh==ii', ' hh==ii'), 

4003 ('ut7', 'ut7=j=k', 'j=k'), 

4004 ('ut8', 'ut8=l==m', 'l==m'), 

4005 ('@ut1', '@ut1=@a', '@a'), 

4006 ) 

4007 for name, s, expected in table: 

4008 for s2, kind in ((s, '(no nl)'), (s + '\n', '(nl)')): 

4009 f(s2, tag='unit-test') 

4010 result, tag = d.get(name, (None, None),) 

4011 self.assertEqual(result, expected, msg=kind) 

4012 #@+node:ekr.20210905064816.4: *4* TestEditCommands.test_capitalizeHelper 

4013 def test_capitalizeHelper(self): 

4014 c, w = self.c, self.c.frame.body.wrapper 

4015 w.setAllText('# TARGETWORD\n') 

4016 table = ( 

4017 ('cap', 'Targetword'), 

4018 ('low', 'targetword'), 

4019 ('up', 'TARGETWORD'), 

4020 ) 

4021 for (which, result) in table: 

4022 w.setInsertPoint(5) # Must be inside the target. 

4023 c.editCommands.capitalizeHelper(event=None, which=which, undoType='X') 

4024 s = w.getAllText() 

4025 word = s[2:12] 

4026 self.assertEqual(word, result, msg=which) 

4027 i = w.getInsertPoint() 

4028 self.assertEqual(i, 5, msg=which) 

4029 #@+node:ekr.20210905064816.16: *4* TestEditCommands.test_delete_key_sticks_in_body 

4030 def test_delete_key_sticks_in_body(self): 

4031 c = self.c 

4032 w = c.frame.body.wrapper 

4033 h = 'Test headline abc' 

4034 p = c.rootPosition().insertAfter() 

4035 p.h = h 

4036 c.selectPosition(p) 

4037 s = 'ABC' 

4038 c.setBodyString(p, s) 

4039 c.bodyWantsFocus() 

4040 w.setInsertPoint(2) 

4041 c.outerUpdate() # This fixed the problem. 

4042 c.k.simulateCommand('delete-char') 

4043 self.assertEqual(p.b, s[:-1]) 

4044 c.selectPosition(p.threadBack()) 

4045 c.selectPosition(p) 

4046 self.assertEqual(p.b, s[:-1]) 

4047 #@+node:ekr.20210905064816.17: *4* TestEditCommands.test_delete_key_sticks_in_headline 

4048 def test_delete_key_sticks_in_headline(self): 

4049 c = self.c 

4050 h = 'Test headline abc' 

4051 p = c.rootPosition().insertAfter() 

4052 p.h = h 

4053 c.selectPosition(p) 

4054 c.redraw(p) # To make node visible 

4055 c.frame.tree.editLabel(p) 

4056 w = c.edit_widget(p) 

4057 try: 

4058 assert w 

4059 w.setSelectionRange('end', 'end') 

4060 finally: 

4061 if 1: 

4062 c.setHeadString(p, h) # Essential 

4063 c.redraw(p) 

4064 #@+node:ekr.20210905064816.5: *4* TestEditCommands.test_dynamicExpandHelper 

4065 def test_dynamicExpandHelper(self): 

4066 c = self.c 

4067 # A totally wimpy test. 

4068 # And it somehow prints a newline to the console. 

4069 if 0: 

4070 c.abbrevCommands.dynamicExpandHelper(event=None, prefix='', aList=[], w=None) 

4071 #@+node:ekr.20210905064816.6: *4* TestEditCommands.test_extendHelper 

4072 def test_extendHelper(self): 

4073 c = self.c 

4074 ec = c.editCommands 

4075 w = c.frame.body.wrapper 

4076 for i, j, python in ( 

4077 # ('1.0','4.5',False), 

4078 (5, 50, True), 

4079 ): 

4080 extend = True 

4081 ec.moveSpot = None # It's hard to init this properly. 

4082 ec.extendHelper(w, extend, j) 

4083 i2, j2 = w.getSelectionRange() 

4084 #@+node:ekr.20210905064816.7: *4* TestEditCommands.test_findWord 

4085 def test_findWord(self): 

4086 c = self.c 

4087 e, k, w = c.editCommands, c.k, c.frame.body.wrapper 

4088 w.setAllText('start\ntargetWord\n') 

4089 w.setInsertPoint(0) 

4090 k.arg = 't' # 'targetWord' 

4091 e.w = w 

4092 e.oneLineFlag = False 

4093 e.findWord1(event=None) 

4094 i, j = w.getSelectionRange() 

4095 self.assertEqual(i, 6) 

4096 #@+node:ekr.20210905064816.8: *4* TestEditCommands.test_findWordInLine 

4097 def test_findWordInLine(self): 

4098 c = self.c 

4099 e, k, w = c.editCommands, c.k, c.frame.body.wrapper 

4100 w.setAllText('abc\ntargetWord\n') 

4101 k.arg = 't' # 'targetWord' 

4102 w.setInsertPoint(0) 

4103 e.w = w 

4104 e.oneLineFlag = False 

4105 e.findWord1(event=None) 

4106 i, j = w.getSelectionRange() 

4107 self.assertEqual(i, 4) 

4108 #@+node:ekr.20210905064816.9: *4* TestEditCommands.test_helpForMinibuffer 

4109 def test_helpForMinibuffer(self): 

4110 c = self.c 

4111 vr = c.helpCommands.helpForMinibuffer() 

4112 if not vr: 

4113 self.skipTest('no vr plugin') 

4114 #@+node:ekr.20210914154830.1: *4* TestEditCommands.test_helpForPython 

4115 def test_helpForPthon(self): 

4116 c, k = self.c, self.c.k 

4117 k.arg = 'os' 

4118 s = c.helpCommands.pythonHelp1(event=None) 

4119 self.assertTrue('Help on module os' in s) 

4120 #@+node:ekr.20210905064816.19: *4* TestEditCommands.test_insert_node_before_node_can_be_undone_and_redone 

4121 def test_insert_node_before_node_can_be_undone_and_redone(self): 

4122 c = self.c 

4123 u = c.undoer 

4124 assert u 

4125 # pylint: disable=no-member 

4126 c.insertHeadlineBefore() 

4127 self.assertEqual(u.undoMenuLabel, 'Undo Insert Node Before') 

4128 c.undoer.undo() 

4129 self.assertEqual(u.redoMenuLabel, 'Redo Insert Node Before') 

4130 #@+node:ekr.20210905064816.18: *4* TestEditCommands.test_insert_node_can_be_undone_and_redone 

4131 def test_insert_node_can_be_undone_and_redone(self): 

4132 c = self.c 

4133 u = c.undoer 

4134 assert u 

4135 # pylint: disable=no-member 

4136 c.insertHeadline() 

4137 self.assertEqual(u.undoMenuLabel, 'Undo Insert Node') 

4138 c.undoer.undo() 

4139 self.assertEqual(u.redoMenuLabel, 'Redo Insert Node') 

4140 #@+node:ekr.20210905064816.20: *4* TestEditCommands.test_inserting_a_new_node_draws_the_screen_exactly_once 

4141 def test_inserting_a_new_node_draws_the_screen_exactly_once(self): 

4142 c = self.c 

4143 n = c.frame.tree.redrawCount 

4144 # pylint: disable=no-member 

4145 c.insertHeadline() 

4146 c.outerUpdate() # Not actually needed, but should not matter. 

4147 n2 = c.frame.tree.redrawCount 

4148 self.assertEqual(n2, n + 1) 

4149 

4150 #@+node:ekr.20210905064816.15: *4* TestEditCommands.test_most_toggle_commands 

4151 def test_most_toggle_commands(self): 

4152 c, k = self.c, self.c.k 

4153 ed = c.editCommands 

4154 # These don't set ivars 

4155 # 'toggle-active-pane'), 

4156 # 'toggle-angle-brackets', 

4157 # 'toggle-input-state'), 

4158 # 'toggle-mini-buffer'), 

4159 # 'toggle-split-direction'), 

4160 table = [ 

4161 (k, 'abbrevOn', 'toggle-abbrev-mode'), 

4162 (ed, 'extendMode', 'toggle-extend-mode'), 

4163 ] 

4164 for obj, ivar, command in table: 

4165 val1 = getattr(obj, ivar) 

4166 k.simulateCommand(command) 

4167 val2 = getattr(obj, ivar) 

4168 self.assertEqual(val2, not val1, msg=command) 

4169 k.simulateCommand(command) 

4170 val3 = getattr(obj, ivar) 

4171 self.assertEqual(val3, val1, msg=command) 

4172 #@+node:ekr.20210905064816.10: *4* TestEditCommands.test_moveToHelper 

4173 def test_moveToHelper(self): 

4174 c = self.c 

4175 ec = c.editCommands 

4176 w = c.frame.body.wrapper 

4177 for i, j, python in ( 

4178 #('1.0','4.5',False), 

4179 (5, 50, True), 

4180 ): 

4181 event = None 

4182 extend = True 

4183 ec.moveSpot = None 

4184 w.setInsertPoint(i) 

4185 ec.moveToHelper(event, j, extend) 

4186 i2, j2 = w.getSelectionRange() 

4187 self.assertEqual(i, i2) 

4188 self.assertEqual(j, j2) 

4189 w.setSelectionRange(0, 0, insert=None) 

4190 #@+node:ekr.20210905064816.11: *4* TestEditCommands.test_moveUpOrDownHelper 

4191 def test_moveUpOrDownHelper(self): 

4192 c = self.c 

4193 ec = c.editCommands 

4194 w = c.frame.body.wrapper 

4195 for i, result, direction in (('5.8', '4.8', 'up'), ('5.8', '6.8', 'down')): 

4196 w.setInsertPoint(i) 

4197 ec.moveUpOrDownHelper(event=None, direction=direction, extend=False) 

4198 w.getSelectionRange() 

4199 

4200 #@+node:ekr.20210905064816.21: *4* TestEditCommands.test_paste_and_undo_in_headline__at_end 

4201 def test_paste_and_undo_in_headline__at_end(self): 

4202 c = self.c 

4203 k = c.keyHandler 

4204 h = 'Test headline abc' 

4205 p = c.rootPosition().insertAfter() 

4206 p.h = h 

4207 c.selectPosition(p) 

4208 c.redrawAndEdit(p) # To make node visible 

4209 w = c.edit_widget(p) 

4210 assert w 

4211 w.setSelectionRange('end', 'end') 

4212 paste = 'ABC' 

4213 g.app.gui.replaceClipboardWith(paste) 

4214 w.setSelectionRange('end', 'end') 

4215 if g.app.gui.guiName() == 'curses': 

4216 c.frame.pasteText(event=g.Bunch(widget=w)) 

4217 else: 

4218 stroke = k.getStrokeForCommandName('paste-text') 

4219 if stroke is None: 

4220 self.skipTest('no binding for paste-text') # #1345 

4221 k.manufactureKeyPressForCommandName(w, 'paste-text') 

4222 g.app.gui.event_generate(c, '\n', 'Return', w) 

4223 self.assertEqual(p.h, h + paste) 

4224 k.manufactureKeyPressForCommandName(w, 'undo') 

4225 self.assertEqual(p.h, h) 

4226 #@+node:ekr.20210905064816.22: *4* TestEditCommands.test_paste_and_undo_in_headline__with_selection 

4227 def test_paste_and_undo_in_headline__with_selection(self): 

4228 c = self.c 

4229 k = c.keyHandler 

4230 frame = c.frame 

4231 tree = frame.tree 

4232 h = 'Test headline abc' 

4233 p = c.rootPosition().insertAfter() 

4234 p.h = h 

4235 c.selectPosition(p) 

4236 c.redraw(p) # To make node visible 

4237 tree.editLabel(p) 

4238 w = c.edit_widget(p) 

4239 assert w 

4240 paste = 'ABC' 

4241 g.app.gui.replaceClipboardWith(paste) 

4242 w.setSelectionRange('1.1', '1.2') 

4243 if g.app.gui.guiName() == 'curses': 

4244 c.frame.pasteText(event=g.Bunch(widget=w)) 

4245 else: 

4246 stroke = k.getStrokeForCommandName('paste-text') 

4247 if stroke is None: 

4248 self.skipTest('no binding for paste-text') # #1345 

4249 k.manufactureKeyPressForCommandName(w, 'paste-text') 

4250 g.app.gui.event_generate(c, '\n', 'Return', w) 

4251 self.assertEqual(p.h, h[0] + paste + h[2:]) 

4252 k.manufactureKeyPressForCommandName(w, 'undo') 

4253 self.assertEqual(p.h, h) 

4254 

4255 #@+node:ekr.20210905064816.23: *4* TestEditCommands.test_paste_at_end_of_headline 

4256 def test_paste_at_end_of_headline(self): 

4257 c = self.c 

4258 k = c.keyHandler 

4259 h = 'Test headline abc' 

4260 p = c.rootPosition().insertAfter() 

4261 p.h = h 

4262 c.selectPosition(p) 

4263 c.redrawAndEdit(p) # To make node visible 

4264 w = c.edit_widget(p) 

4265 g.app.gui.set_focus(c, w) 

4266 assert w 

4267 paste = 'ABC' 

4268 g.app.gui.replaceClipboardWith(paste) 

4269 g.app.gui.set_focus(c, w) 

4270 w.setSelectionRange('end', 'end') 

4271 if g.app.gui.guiName() == 'curses': 

4272 c.frame.pasteText(event=g.Bunch(widget=w)) 

4273 else: 

4274 stroke = k.getStrokeForCommandName('paste-text') 

4275 if stroke is None: 

4276 self.skipTest('no binding for paste-text') # #1345 

4277 k.manufactureKeyPressForCommandName(w, 'paste-text') 

4278 g.app.gui.event_generate(c, '\n', 'Return', w) 

4279 self.assertEqual(p.h, h + paste) 

4280 #@+node:ekr.20210905064816.24: *4* TestEditCommands.test_paste_from_menu_into_headline_sticks 

4281 def test_paste_from_menu_into_headline_sticks(self): 

4282 c = self.c 

4283 h = 'Test headline abc' 

4284 p = c.rootPosition().insertAfter() 

4285 p.h = h 

4286 c.selectPosition(p) 

4287 c.selectPosition(p) 

4288 c.frame.tree.editLabel(p) 

4289 w = c.edit_widget(p) 

4290 w.setSelectionRange('end', 'end', insert='end') 

4291 paste = 'ABC' 

4292 g.app.gui.replaceClipboardWith(paste) 

4293 event = g.app.gui.create_key_event(c, w=w) 

4294 c.frame.pasteText(event) 

4295 # Move around and and make sure it doesn't change. 

4296 try: 

4297 # g.trace('before select',w,w.getAllText()) 

4298 c.selectPosition(p.threadBack()) 

4299 self.assertEqual(p.h, h + paste) 

4300 c.selectPosition(p) 

4301 self.assertEqual(p.h, h + paste) 

4302 finally: 

4303 if 1: 

4304 c.setHeadString(p, h) # Essential 

4305 c.redraw(p) 

4306 #@+node:ekr.20210905064816.25: *4* TestEditCommands.test_return_ends_editing_of_headline 

4307 def test_return_ends_editing_of_headline(self): 

4308 c = self.c 

4309 h = '@test return ends editing of headline' 

4310 p = c.rootPosition().insertAfter() 

4311 p.h = h 

4312 c.selectPosition(p) 

4313 c.redraw(p) # To make node visible 

4314 c.frame.tree.editLabel(p) 

4315 w = c.edit_widget(p) 

4316 wName = g.app.gui.widget_name(w) 

4317 assert wName.startswith('head'), 'w.name:%s' % wName 

4318 g.app.gui.event_generate(c, '\n', 'Return', w) 

4319 c.outerUpdate() 

4320 assert w != c.get_focus(), 'oops2: focus in headline' 

4321 #@+node:ekr.20210905064816.12: *4* TestEditCommands.test_scrollHelper 

4322 def test_scrollHelper(self): 

4323 c = self.c 

4324 ec = c.editCommands 

4325 w = c.frame.body.wrapper 

4326 

4327 for direction in ('up', 'down'): 

4328 for distance in ('line', 'page', 'half-page'): 

4329 event = g.app.gui.create_key_event(c, w=w) 

4330 ec.scrollHelper(event, direction, distance) 

4331 #@+node:ekr.20210905064816.26: *4* TestEditCommands.test_selecting_new_node_retains_paste_in_headline 

4332 def test_selecting_new_node_retains_paste_in_headline(self): 

4333 c, k = self.c, self.c.k 

4334 h = 'Test headline abc' 

4335 p = c.rootPosition().insertAfter() 

4336 p.h = h 

4337 c.selectPosition(p) 

4338 c.redraw(p) # To make node visible 

4339 c.frame.tree.editLabel(p) 

4340 w = c.edit_widget(p) 

4341 w.setSelectionRange('end', 'end') 

4342 paste = 'ABC' 

4343 g.app.gui.replaceClipboardWith(paste) 

4344 w.setSelectionRange('end', 'end') 

4345 k.manufactureKeyPressForCommandName(w, 'paste-text') 

4346 c.selectPosition(p.visBack(c)) 

4347 self.assertEqual(p.h, h + paste) 

4348 c.undoer.undo() 

4349 self.assertEqual(p.h, h) 

4350 #@+node:ekr.20210905064816.27: *4* TestEditCommands.test_selecting_new_node_retains_typing_in_headline 

4351 def test_selecting_new_node_retains_typing_in_headline(self): 

4352 c = self.c 

4353 k = c.k 

4354 if k.defaultUnboundKeyAction != 'insert': 

4355 return 

4356 tree = c.frame.tree 

4357 h = 'Test headline abc' 

4358 p = c.rootPosition().insertAfter() 

4359 p.h = h 

4360 c.selectPosition(p) 

4361 c.redraw(p) # To make node visible 

4362 tree.editLabel(p) 

4363 w = c.edit_widget(p) 

4364 w.setSelectionRange('end', 'end') 

4365 # char, shortcut. 

4366 g.app.gui.event_generate(c, 'X', 'Shift+X', w) 

4367 g.app.gui.event_generate(c, 'Y', 'Shift+Y', w) 

4368 g.app.gui.event_generate(c, 'Z', 'Shift+Z', w) 

4369 g.app.gui.event_generate(c, '\n', 'Return', w) 

4370 expected = h + 'XYZ' 

4371 self.assertEqual(p.h, expected) 

4372 k.manufactureKeyPressForCommandName(w, 'undo') 

4373 self.assertEqual(p.h, h) 

4374 #@+node:ekr.20210905064816.13: *4* TestEditCommands.test_setMoveCol 

4375 def test_setMoveCol(self): 

4376 c = self.c 

4377 ec, w = c.editCommands, c.frame.body.wrapper 

4378 table = ( 

4379 ('1.0', 0), 

4380 (5, 5), 

4381 ) 

4382 w.setAllText('1234567890') 

4383 for spot, result in table: 

4384 ec.setMoveCol(w, spot) 

4385 self.assertEqual(ec.moveSpot, result) 

4386 self.assertEqual(ec.moveCol, result) 

4387 #@+node:ekr.20210905064816.14: *4* TestEditCommands.test_toggle_extend_mode 

4388 def test_toggle_extend_mode(self): 

4389 c = self.c 

4390 # backward-find-character and find-character 

4391 # can't be tested this way because they prompt for input. 

4392 #@+<< define table >> 

4393 #@+node:ekr.20210905065002.1: *5* << define table >> 

4394 # Cursor movement commands affected by extend mode. 

4395 # The x-extend-selection commands are not so affected. 

4396 table = ( 

4397 'back-to-indentation', 

4398 'back-to-home', 

4399 'back-char', 

4400 'back-page', 

4401 'back-paragraph', 

4402 'back-sentence', 

4403 'back-word', 

4404 'beginning-of-buffer', 

4405 'beginning-of-line', 

4406 'end-of-buffer', 

4407 'end-of-line', 

4408 'forward-char', 

4409 'forward-page', 

4410 'forward-paragraph', 

4411 'forward-sentence', 

4412 'forward-end-word', 

4413 'forward-word', 

4414 'move-past-close', 

4415 'next-line', 

4416 'previous-line', 

4417 ) 

4418 #@-<< define table >> 

4419 w = c.frame.body.wrapper 

4420 s = textwrap.dedent("""\ 

4421 Paragraph 1. 

4422 line 2. 

4423 

4424 Paragraph 2. 

4425 line 2, paragraph 2 

4426 """) 

4427 w.setAllText(s) 

4428 child = c.rootPosition().insertAfter() 

4429 c.selectPosition(child) 

4430 for commandName in table: 

4431 # Put the cursor in the middle of the middle line 

4432 # so all cursor moves will actually do something. 

4433 w.setInsertPoint(15) 

4434 c.editCommands.extendMode = True 

4435 c.keyHandler.simulateCommand(commandName) 

4436 # i, j = w.getSelectionRange() 

4437 # self.assertNotEqual(i, j, msg=commandName) 

4438 #@+node:ekr.20210905064816.28: *4* TestEditCommands.test_typing_and_undo_in_headline__at_end 

4439 def test_typing_and_undo_in_headline__at_end(self): 

4440 c, k = self.c, self.c.k 

4441 if k.defaultUnboundKeyAction != 'insert': 

4442 self.skipTest('defaultUnboundKeyAction != insert') 

4443 if not k.getStrokeForCommandName('undo'): 

4444 self.skipTest('no settings') 

4445 h = 'Test headline abc' 

4446 p = c.rootPosition().insertAfter() 

4447 p.h = h 

4448 c.redrawAndEdit(p) # To make the node visible. 

4449 w = c.edit_widget(p) 

4450 assert w 

4451 wName = g.app.gui.widget_name(w) 

4452 self.assertTrue(wName.startswith('head')) 

4453 w.setSelectionRange('end', 'end') 

4454 g.app.gui.event_generate(c, 'X', 'Shift+X', w) 

4455 g.app.gui.event_generate(c, 'Y', 'Shift+Y', w) 

4456 g.app.gui.event_generate(c, 'Z', 'Shift+Z', w) 

4457 g.app.gui.event_generate(c, '\n', 'Return', w) 

4458 self.assertEqual(p.h, h + 'XYZ') 

4459 if g.app.gui.guiName() != 'nullGui': 

4460 self.assertEqual(c.undoer.undoMenuLabel, 'Undo Typing') 

4461 k.manufactureKeyPressForCommandName(w, 'undo') 

4462 if g.app.gui.guiName() != 'nullGui': 

4463 self.assertEqual(c.undoer.redoMenuLabel, 'Redo Typing') 

4464 self.assertEqual(p.h, h) 

4465 #@+node:ekr.20210905064816.29: *4* TestEditCommands.test_typing_in_non_empty_body_text_does_not_redraw_the_screen 

4466 def test_typing_in_non_empty_body_text_does_not_redraw_the_screen(self): 

4467 c = self.c 

4468 w = c.frame.body.wrapper 

4469 h = 'Test headline abc' 

4470 p = c.rootPosition().insertAfter() 

4471 p.h = h 

4472 c.setBodyString(p, 'a') 

4473 p.v.iconVal = p.computeIcon() # To suppress redraw! 

4474 c.redraw(p) # To make node visible 

4475 c.bodyWantsFocus() 

4476 n = c.frame.tree.redrawCount 

4477 g.app.gui.event_generate(c, 'a', 'a', w) 

4478 n2 = c.frame.tree.redrawCount 

4479 self.assertEqual(n2, n) 

4480 

4481 #@+node:ekr.20210905064816.30: *4* TestEditCommands.test_undoing_insert_node_restores_previous_node_s_body_text 

4482 def test_undoing_insert_node_restores_previous_node_s_body_text(self): 

4483 c = self.c 

4484 h = 'Test headline abc' 

4485 p = c.rootPosition().insertAfter() 

4486 p.h = h 

4487 c.selectPosition(p) 

4488 body = 'This is a test' 

4489 c.setBodyString(p, body) 

4490 # pylint: disable=no-member 

4491 self.assertEqual(p.b, body) 

4492 c.insertHeadline() 

4493 c.undoer.undo() 

4494 self.assertEqual(p.b, body) 

4495 #@-others 

4496#@-others 

4497#@-leo