Update tutorial.
[docutils.git] / docutils / tools / editors / emacs / tests / fill.el
blobaa1655f5079760341a8ab9540768cc179e74bc67
1 ;; Tests for functions around filling
3 (add-to-list 'load-path ".")
4 (load "init" nil t)
5 (init-rst-ert t)
7 (ert-deftest fill-asserts ()
8 "Check some assertions."
9 (should (equal ert-Buf-point-char "\^@"))
10 (should (equal ert-Buf-mark-char "\^?"))
13 (defun auto-fill ()
14 "Wrapper to do auto fill."
15 (let ((fc fill-column))
16 (rst-mode)
17 (setq fill-column fc)
18 (auto-fill-mode 1)
19 (funcall auto-fill-function)))
21 (ert-deftest auto-fill ()
22 "Tests for auto fill."
23 (let ((rst-indent-width 2)
24 (rst-indent-field 2)
25 (rst-indent-literal-normal 3)
26 (rst-indent-literal-minimized 2)
27 (rst-indent-comment 3)
28 (fill-column 20))
29 (should (ert-equal-buffer
30 (auto-fill)
32 * This is a test with a fill column of 20\^@"
34 * This is a test
35 with a fill column
36 of 20\^@"
38 (should (ert-equal-buffer
39 (auto-fill)
41 * This is a test
42 with a fill column of 20\^@"
44 * This is a test
45 with a fill column
46 of 20\^@"
48 (should (ert-equal-buffer
49 (auto-fill)
51 :Field: Does this work for fields?\^@"
53 :Field: Does this
54 work for
55 fields?\^@"
57 (should (ert-equal-buffer
58 (auto-fill)
60 :Field: Does this
61 work for fields?\^@"
63 :Field: Does this
64 work for
65 fields?\^@"
67 (should (ert-equal-buffer
68 (auto-fill)
70 .. dir:: Yes, quite fine\^@"
72 .. dir:: Yes, quite
73 fine\^@"
75 (should (ert-equal-buffer
76 (auto-fill)
78 .. dir:: Yes, quite fine\^@
79 :f: Field"
81 .. dir:: Yes, quite
82 fine\^@
83 :f: Field"
85 (should (ert-equal-buffer
86 (auto-fill)
88 .. |s| r:: Dir ectives had problems\^@"
90 .. |s| r:: Dir
91 ectives
92 had
93 problems\^@"
95 (should (ert-equal-buffer
96 (auto-fill)
98 .. |s| r:: Dir
99 ectives
100 had problems\^@"
102 .. |s| r:: Dir
103 ectives
105 problems\^@"
107 (should (ert-equal-buffer
108 (auto-fill)
110 .. [CIT] X cit is citations are also filled\^@"
112 .. [CIT] X cit is
113 citations
114 are also
115 filled\^@"
117 (should (ert-equal-buffer
118 (auto-fill)
120 .. [CIT] X cit is
121 citations
122 are also filled\^@"
124 .. [CIT] X cit is
125 citations
126 are also
127 filled\^@"
129 (should (ert-equal-buffer
130 (auto-fill)
132 .. Comments should also fill nicely\^@"
134 .. Comments should
135 also fill nicely\^@"
137 (should (ert-equal-buffer
138 (auto-fill)
140 Normal text should also fill as expected\^@"
142 Normal text should
143 also fill as
144 expected\^@"
146 (should (ert-equal-buffer
147 (auto-fill)
149 Normal text should also fill as expected\^@"
151 Normal text should
152 also fill as
153 expected\^@"
155 (should (ert-equal-buffer
156 (auto-fill)
158 Normal text should also fill \^@as expected"
160 Normal text should
161 also fill \^@as expected"
165 (defun explicit-fill ()
166 "Wrapper for `fill-paragraph'."
167 (let ((fc fill-column))
168 (rst-mode)
169 (setq fill-column fc)
170 (fill-paragraph)
171 (untabify (point-min) (point-max))))
173 (ert-deftest fill-paragraph ()
174 "Tests for `fill-paragraph'."
175 (let ((rst-indent-width 2)
176 (rst-indent-field 2)
177 (rst-indent-literal-normal 3)
178 (rst-indent-literal-minimized 2)
179 (rst-indent-comment 3)
180 (fill-column 20))
181 (should (ert-equal-buffer
182 (explicit-fill)
184 * This is a test with a fill column of 20\^@
187 * This is a test
188 with a fill column
189 of 20\^@
192 (should (ert-equal-buffer
193 (explicit-fill)
195 * This is a test \^@with a fill column
196 of 20
199 * This is a test
200 \^@with a fill column
201 of 20
204 (should (ert-equal-buffer
205 (explicit-fill)
207 :Field: Does this work for fields?\^@
210 :Field: Does this
211 work for
212 fields?\^@
215 (should (ert-equal-buffer
216 (explicit-fill)
218 :Field: Does this work\^@ for
219 fields?
222 :Field: Does this
223 work\^@ for
224 fields?
227 (should (ert-equal-buffer
228 (explicit-fill)
230 .. dir:: Yes, quite fine\^@
233 .. dir:: Yes, quite
234 fine\^@
237 (should (ert-equal-buffer
238 (explicit-fill)
240 \^@.. dir:: Yes, quite
241 fine
244 \^@.. dir:: Yes, quite
245 fine
248 (should (ert-equal-buffer
249 (explicit-fill)
251 .. dir:: Yes, quite fine\^@
252 :f: Field
255 .. dir:: Yes, quite
256 fine\^@
257 :f: Field
260 (should (ert-equal-buffer
261 (explicit-fill)
263 .. [CIT] X cit is citations are also filled\^@
266 .. [CIT] X cit is
267 citations
268 are also
269 filled\^@
272 (should (ert-equal-buffer
273 (explicit-fill)
275 .. [CIT] X cit is
276 citations are also filled\^@
279 .. [CIT] X cit is
280 citations are
281 also filled\^@
284 (should (ert-equal-buffer
285 (explicit-fill)
287 .. [CIT] X cit is
288 citations are also filled\^@
291 .. [CIT] X cit is
292 citations are
293 also filled\^@
296 (should (ert-equal-buffer
297 (explicit-fill)
299 .. |s| r:: Dir ectives had problems\^@
302 .. |s| r:: Dir
303 ectives
305 problems\^@
308 (should (ert-equal-buffer
309 (explicit-fill)
311 \^@.. |s| r:: Dir ectives had problems
314 \^@.. |s| r:: Dir
315 ectives
317 problems
320 (should (ert-equal-buffer
321 (explicit-fill)
323 .. |s| r:: Dir
324 ectives had problems\^@
327 .. |s| r:: Dir
328 ectives had
329 problems\^@
332 (should (ert-equal-buffer
333 (explicit-fill)
335 Normal \^@text should also fill as expected
338 Normal \^@text should
339 also fill as
340 expected
343 (should (ert-equal-buffer
344 (explicit-fill)
346 \^@Normal text should also fill as expected
349 \^@Normal text should
350 also fill as
351 expected
354 (should (ert-equal-buffer
355 (explicit-fill)
357 Normal text should also fill as expected\^@
360 Normal text should
361 also fill as
362 expected\^@
365 (should (ert-equal-buffer
366 (explicit-fill)
368 Normal text should also fill as expected
370 Normal text should also fill as expected\^@
373 Normal text should also fill as expected
375 Normal text should
376 also fill as
377 expected\^@
380 (should (ert-equal-buffer
381 (explicit-fill)
383 \^@Normal text should
384 also fill as
385 expected
388 \^@Normal text should
389 also fill as
390 expected
395 (ert-deftest fill-paragraph-fixme ()
396 "Tests for `fill-paragraph'."
397 :expected-result :failed
398 (let ((rst-indent-width 2)
399 (rst-indent-field 2)
400 (rst-indent-literal-normal 3)
401 (rst-indent-literal-minimized 2)
402 (rst-indent-comment 3)
403 (fill-column 20))
404 (should (ert-equal-buffer
405 (explicit-fill)
407 \^@Normal text should
408 also fill as
409 expected
412 \^@Normal text should
413 also fill as
414 expected
419 (defun explicit-fill-region ()
420 "Wrapper for `fill-region'."
421 (let ((fc fill-column))
422 (rst-mode)
423 (setq fill-column fc)
424 (call-interactively 'fill-region)
425 (untabify (point-min) (point-max))))
427 (ert-deftest fill-region ()
428 "Tests for `fill-region'."
429 (let ((rst-indent-width 2)
430 (rst-indent-field 2)
431 (rst-indent-literal-normal 3)
432 (rst-indent-literal-minimized 2)
433 (rst-indent-comment 3)
434 (fill-column 20))
435 (should (ert-equal-buffer
436 (explicit-fill-region)
437 "\^@
438 * This is a test with a fill column of 20
440 * This is a test with a fill column
441 of 20
443 :Field: Does this work for fields?
445 :Field: Does this work for
446 fields?
448 .. dir:: Yes, quite fine
450 .. dir:: Yes, quite
451 fine
453 .. dir:: Yes, quite fine
454 :f: Field for a directive
456 .. [CIT] X cit is citations are also filled
458 .. |s| r:: Dir ectives had problems
460 .. |s| r:: Dir ectives had problems
462 Normal text should also fill as expected
464 Normal text should also fill as expected
465 \^?"
466 "\^@
467 * This is a test
468 with a fill column
469 of 20
471 * This is a test
472 with a fill column
473 of 20
475 :Field: Does this
476 work for
477 fields?
479 :Field: Does this
480 work for
481 fields?
483 .. dir:: Yes, quite
484 fine
486 .. dir:: Yes, quite
487 fine
489 .. dir:: Yes, quite
490 fine
491 :f: Field for a
492 directive
494 .. [CIT] X cit is
495 citations
496 are also
497 filled
499 .. |s| r:: Dir
500 ectives
502 problems
504 .. |s| r:: Dir
505 ectives
507 problems
509 Normal text should
510 also fill as
511 expected
513 Normal text should
514 also fill as
515 expected
516 \^?"
518 (should (ert-equal-buffer
519 (explicit-fill-region)
520 "\^@
521 * This is a test with a fill column of 20
522 * This is a test with a fill column
523 of 20
524 :Field: Does this work for fields?
525 :Field: Does this work for
526 fields?
527 .. dir:: Yes, quite fine
528 .. dir:: Yes, quite
529 fine
530 .. dir:: Yes, quite fine
531 :f: Field for a directive
532 .. [CIT] X cit is citations are also filled
533 .. |s| r:: Dir ectives had problems
534 .. |s| r:: Dir ectives had problems
536 Normal text should also fill as expected
538 Normal text should also fill as expected
539 \^?"
540 "\^@
541 * This is a test
542 with a fill column
543 of 20
544 * This is a test
545 with a fill column
546 of 20
547 :Field: Does this
548 work for
549 fields?
550 :Field: Does this
551 work for
552 fields?
553 .. dir:: Yes, quite
554 fine
555 .. dir:: Yes, quite
556 fine
557 .. dir:: Yes, quite
558 fine
559 :f: Field for a
560 directive
561 .. [CIT] X cit is
562 citations
563 are also
564 filled
565 .. |s| r:: Dir
566 ectives
568 problems
569 .. |s| r:: Dir
570 ectives
572 problems
574 Normal text should
575 also fill as
576 expected
578 Normal text should
579 also fill as
580 expected
581 \^?"