Debian Codegraph @

tools/editors/emacs/tests/movement.el

raw
1 ;; Tests for various movement commands -*- lexical-binding: t -*-
2
3 (add-to-list 'load-path ".")
4 (load "init" nil t)
5 (init-rst-ert t)
6
7 (ert-deftest movement-asserts ()
8 "Check some assertions."
9 (should (equal ert-Buf-point-char "\^@"))
10 (should (equal ert-Buf-mark-char "\^?"))
11 )
12
13 (defun fwd-para ()
14 "Wrapper to call `forward-paragraph'."
15 (rst-mode)
16 (forward-paragraph))
17
18 (ert-deftest forward-paragraph ()
19 "Tests for `forward-paragraph'."
20 (should (ert-equal-buffer-return
21 '(fwd-para)
22 "
23 :Field: Content
24 \^@
25 More content
26 over several
27
28 * An item
29 with multi
30 "
31 "
32 :Field: Content
33
34 More content
35 over several
36 \^@
37 * An item
38 with multi
39 "
40 0
41 ))
42
43
44 (should (ert-equal-buffer-return
45 '(fwd-para)
46 "\^@
47 This is
48 a short
49 para"
50 "
51 This is
52 a short
53 para\^@"
54 0
55 ))
56 (should (ert-equal-buffer-return
57 '(fwd-para)
58 "\^@
59 This is
60 a short
61 para
62 "
63 "
64 This is
65 a short
66 para
67 \^@"
68 0
69 ))
70 (should (ert-equal-buffer-return
71 '(fwd-para)
72 "\^@
73 This is
74 a short
75 para
76
77 "
78 "
79 This is
80 a short
81 para
82 \^@
83 "
84 0
85 ))
86 (should (ert-equal-buffer-return
87 '(fwd-para)
88 "\^@
89 This is
90 a short
91 para
92
93
94 "
95 "
96 This is
97 a short
98 para
99 \^@
100
101 "
102 0
103 ))
104 (should (ert-equal-buffer-return
105 '(fwd-para)
106 "
107 \^@This is
108 a short
109 para
110
111 "
112 "
113 This is
114 a short
115 para
116 \^@
117 "
118 0
119 ))
120 (should (ert-equal-buffer-return
121 '(fwd-para)
122 "
123 This is
124 a short
125 \^@para
126
127 "
128 "
129 This is
130 a short
131 para
132 \^@
133 "
134 0
135 ))
136 (should (ert-equal-buffer-return
137 '(fwd-para)
138 "
139 This is
140 a short
141 \^@para
142
143 "
144 "
145 This is
146 a short
147 para
148 \^@
149 "
150 0
151 ))
152 (should (ert-equal-buffer-return
153 '(fwd-para)
154 "
155 This is
156 \^@a short
157 para
158
159 "
160 "
161 This is
162 a short
163 para
164 \^@
165 "
166 0
167 ))
168 (should (ert-equal-buffer-return
169 '(fwd-para)
170 "
171 This is
172 a short
173 \^@para
174
175 This is
176 a short
177 para
178
179 "
180 "
181 This is
182 a short
183 para
184 \^@
185 This is
186 a short
187 para
188
189 "
190 0
191 ))
192 (should (ert-equal-buffer-return
193 '(fwd-para)
194 "
195 \^@* An item
196
197 * Another item
198 "
199 "
200 * An item
201 \^@
202 * Another item
203 "
204 0
205 ))
206 (should (ert-equal-buffer-return
207 '(fwd-para)
208 "
209 \^@* An item
210 * Another item
211 "
212 "
213 * An item
214 \^@* Another item
215 "
216 0
217 ))
218 (should (ert-equal-buffer-return
219 '(fwd-para)
220 "
221 \^@:Field: Content
222
223 More content
224 over several
225
226 * An item
227 with multi
228 "
229 "
230 :Field: Content
231 \^@
232 More content
233 over several
234
235 * An item
236 with multi
237 "
238 0
239 ))
240 (should (ert-equal-buffer-return
241 '(fwd-para)
242 "
243 :Field: Content
244 \^@
245 More content
246 over several
247
248 * An item
249 with multi
250 "
251 "
252 :Field: Content
253
254 More content
255 over several
256 \^@
257 * An item
258 with multi
259 "
260 0
261 ))
262 (should (ert-equal-buffer-return
263 '(fwd-para)
264 "
265 :Field: Content
266
267 More content
268 over several
269 \^@
270 * An item
271 with multi
272 "
273 "
274 :Field: Content
275
276 More content
277 over several
278
279 * An item
280 with multi
281 \^@"
282 0
283 ))
284 (should (ert-equal-buffer-return
285 '(fwd-para)
286 "\^@
287 .. |s| d::
288 :F: Content
289
290 More content
291 over several
292 * An item
293 with multi
294 "
295 "
296 .. |s| d::
297 \^@ :F: Content
298
299 More content
300 over several
301 * An item
302 with multi
303 "
304 0
305 ))
306 (should (ert-equal-buffer-return
307 '(fwd-para)
308 "
309 .. |s| d::
310 \^@ :F: Content
311
312 More content
313 over several
314 * An item
315 with multi
316 "
317 "
318 .. |s| d::
319 :F: Content
320 \^@
321 More content
322 over several
323 * An item
324 with multi
325 "
326 0
327 ))
328 (should (ert-equal-buffer-return
329 '(fwd-para)
330 "
331 .. |s| d::
332 :F: Content
333 \^@
334 More content
335 over several
336 * An item
337 with multi
338 "
339 "
340 .. |s| d::
341 :F: Content
342
343 More content
344 over several
345 \^@ * An item
346 with multi
347 "
348 0
349 ))
350 (should (ert-equal-buffer-return
351 '(fwd-para)
352 "
353 .. |s| d::
354 :F: Content
355
356 More content
357 over several
358 \^@ * An item
359 with multi
360 "
361 "
362 .. |s| d::
363 :F: Content
364
365 More content
366 over several
367 * An item
368 with multi
369 \^@"
370 0
371 ))
372 )
373
374 (ert-deftest rst-forward-section ()
375 "Tests for `rst-forward-section'."
376 (should (ert-equal-buffer
377 '(rst-forward-section -1)
378 "
379 ========
380 \^@Header 1
381 ========
382
383 Some text
384
385 Header 2
386 ========
387 "
388 "\^@
389 ========
390 Header 1
391 ========
392
393 Some text
394
395 Header 2
396 ========
397 "
398 ))
399 (should (ert-equal-buffer
400 '(rst-forward-section 1)
401 "\^@"
402 "\^@"))
403 (should (ert-equal-buffer
404 '(rst-forward-section 1)
405 "
406 Some text\^@
407
408 More text
409 "
410 "
411 Some text
412
413 More text
414 \^@"
415 ))
416 (should (ert-equal-buffer
417 '(rst-forward-section 1)
418 "
419 Some text
420
421 More text
422 \^@"
423 "
424 Some text
425
426 More text
427 \^@"
428 ))
429 (should (ert-equal-buffer
430 '(rst-forward-section -1)
431 "
432 Some text
433
434 More text
435 \^@"
436 "\^@
437 Some text
438
439 More text
440 "
441 ))
442 (should (ert-equal-buffer
443 '(rst-forward-section 1)
444 "
445 \^@Header 1
446 ========
447
448 Some text
449 "
450 "
451 Header 1
452 ========
453
454 Some text
455 \^@"
456 ))
457 (should (ert-equal-buffer
458 '(rst-forward-section 1)
459 "
460 Header 1\^@
461 ========
462
463 Some text
464 "
465 "
466 Header 1
467 ========
468
469 Some text
470 \^@"
471 ))
472 (should (ert-equal-buffer
473 '(rst-forward-section 1)
474 "
475 Header 1
476 ===\^@=====
477
478 Some text
479 "
480 "
481 Header 1
482 ========
483
484 Some text
485 \^@"
486 ))
487 (should (ert-equal-buffer
488 '(rst-forward-section 1)
489 "
490 Header 1\^@
491 ========
492
493 Some text
494
495 Header 2
496 ========
497 "
498 "
499 Header 1
500 ========
501
502 Some text
503
504 \^@Header 2
505 ========
506 "
507 ))
508 (should (ert-equal-buffer
509 '(rst-forward-section 1)
510 "
511 Header 1
512 ========
513
514 \^@Some text
515
516 Header 2
517 ========
518 "
519 "
520 Header 1
521 ========
522
523 Some text
524
525 \^@Header 2
526 ========
527 "
528 ))
529 (should (ert-equal-buffer
530 '(rst-forward-section 1)
531 "
532 Header 1
533 ========\^@
534
535 Some text
536
537 Header 2
538 ========
539 "
540 "
541 Header 1
542 ========
543
544 Some text
545
546 \^@Header 2
547 ========
548 "
549 ))
550 (should (ert-equal-buffer
551 '(rst-forward-section 1)
552 "
553 ========
554 \^@Header 1
555 ========
556
557 Some text
558
559 Header 2
560 ========
561 "
562 "
563 ========
564 Header 1
565 ========
566
567 Some text
568
569 \^@Header 2
570 ========
571 "
572 ))
573 (should (ert-equal-buffer
574 '(rst-forward-section 1)
575 "
576 \^@========
577 Header 1
578 ========
579
580 Some text
581
582 Header 2
583 ========
584 "
585 "
586 ========
587 Header 1
588 ========
589
590 Some text
591
592 \^@Header 2
593 ========
594 "
595 ))
596 (should (ert-equal-buffer
597 '(rst-forward-section -1)
598 "
599 ========
600 Header 1
601 ========
602
603 Some text
604
605 \^@Header 2
606 ========
607 "
608 "
609 ========
610 \^@Header 1
611 ========
612
613 Some text
614
615 Header 2
616 ========
617 "
618 ))
619
620 ; ****
621
622 (should (ert-equal-buffer
623 '(rst-forward-section 2)
624 "\^@
625 ========
626 Header 1
627 ========
628
629 Some text
630
631 Header 2
632 ========
633 "
634 "
635 ========
636 Header 1
637 ========
638
639 Some text
640
641 \^@Header 2
642 ========
643 "
644 ))
645 (should (ert-equal-buffer
646 '(rst-forward-section 3)
647 "
648 ========
649 \^@Header 1
650 ========
651
652 Some text
653
654 Header 2
655 ========
656
657 Header 3
658 ========
659
660 Header 4
661 ========
662 "
663 "
664 ========
665 Header 1
666 ========
667
668 Some text
669
670 Header 2
671 ========
672
673 Header 3
674 ========
675
676 \^@Header 4
677 ========
678 "
679 ))
680 (should (ert-equal-buffer
681 '(rst-forward-section 3)
682 "\^@
683 ========
684 Header 1
685 ========
686
687 Some text
688
689 Header 2
690 ========
691 "
692 "
693 ========
694 Header 1
695 ========
696
697 Some text
698
699 Header 2
700 ========
701 \^@"
702 ))
703 (should (ert-equal-buffer
704 '(rst-forward-section 0)
705 "
706 ========
707 Header 1\^@
708 ========
709
710 Some text
711
712 Header 2
713 ========
714 "
715 "
716 ========
717 \^@Header 1
718 ========
719
720 Some text
721
722 Header 2
723 ========
724 "
725 ))
726 (should (ert-equal-buffer
727 '(rst-forward-section 0)
728 "
729 ========\^@
730 Header 1
731 ========
732
733 Some text
734
735 Header 2
736 ========
737 "
738 "
739 ========
740 \^@Header 1
741 ========
742
743 Some text
744
745 Header 2
746 ========
747 "
748 ))
749 (should (ert-equal-buffer
750 '(rst-forward-section 0)
751 "
752 ========
753 Header 1
754 ========\^@
755
756 Some text
757
758 Header 2
759 ========
760 "
761 "
762 ========
763 \^@Header 1
764 ========
765
766 Some text
767
768 Header 2
769 ========
770 "
771 ))
772 (should (ert-equal-buffer
773 '(rst-forward-section 0)
774 "
775 ========
776 Header 1
777 ========
778
779 Some text\^@
780
781 Header 2
782 ========
783 "
784 "
785 ========
786 Header 1
787 ========
788
789 Some text\^@
790
791 Header 2
792 ========
793 "
794 ))
795 (should (ert-equal-buffer
796 '(rst-forward-section -)
797 "
798 ========
799 Header 1
800 ========
801
802 Some text
803
804 \^@Header 2
805 ========
806 "
807 "
808 ========
809 \^@Header 1
810 ========
811
812 Some text
813
814 Header 2
815 ========
816 "
817 t))
818 (should (ert-equal-buffer
819 '(rst-forward-section nil)
820 "
821 ========
822 \^@Header 1
823 ========
824
825 Some text
826
827 Header 2
828 ========
829 "
830 "
831 ========
832 Header 1
833 ========
834
835 Some text
836
837 \^@Header 2
838 ========
839 "
840 t
841 ))
842 (should (ert-equal-buffer
843 '(rst-forward-section (4))
844 "\^@
845 ========
846 Header 1
847 ========
848
849 Some text
850
851 Header 2
852 ========
853 "
854 "
855 ========
856 Header 1
857 ========
858
859 Some text
860
861 Header 2
862 ========
863 \^@"
864 t))
865 (should (ert-equal-buffer
866 '(rst-backward-section nil)
867 "
868 ========
869 Header 1
870 ========
871
872 Some text
873
874 \^@Header 2
875 ========
876 "
877 "
878 ========
879 \^@Header 1
880 ========
881
882 Some text
883
884 Header 2
885 ========
886 "
887 t))
888 )