Debian Codegraph @

tools/editors/emacs/tests/indent.el

raw
1 ;; Tests for functions around indentation -*- lexical-binding: t -*-
2
3 (add-to-list 'load-path ".")
4 (load "init" nil t)
5 (init-rst-ert t)
6
7 (ert-deftest indent-asserts ()
8 "Check some assertions."
9 (should (equal ert-Buf-point-char "\^@"))
10 (should (equal ert-Buf-mark-char "\^?"))
11 )
12
13 (defun indent-for-tab (&optional count)
14 "Wrapper to call `indent-for-tab-command' COUNT times defaulting to 1."
15 (setq count (or count 1))
16 (rst-mode)
17 (dotimes (i count)
18 (indent-for-tab-command)))
19
20 (ert-deftest indent-for-tab-command ()
21 "Tests for `indent-for-tab-command'."
22 (let ((rst-indent-width 2)
23 (rst-indent-field 2)
24 (rst-indent-literal-normal 3)
25 (rst-indent-literal-minimized 2)
26 (rst-indent-comment 3))
27 (should (ert-equal-buffer
28 '(indent-for-tab)
29 "\^@"
30 t
31 ))
32 (should (ert-equal-buffer
33 '(indent-for-tab)
34 "
35 * a
36 \^@"
37 "
38 * a
39 \^@"
40 ))
41 (should (ert-equal-buffer
42 '(indent-for-tab)
43 "
44 * a
45 \^@"
46 "
47 * a
48 \^@"
49 ))
50 (should (ert-equal-buffer
51 '(indent-for-tab)
52 "
53 * a
54
55 * b\^@"
56 "
57 * a
58
59 * b\^@"
60 ))
61 (should (ert-equal-buffer
62 '(indent-for-tab)
63 "
64 * a
65
66 * b\^@"
67 "
68 * a
69
70 * b\^@"
71 ))
72 (should (ert-equal-buffer
73 '(indent-for-tab)
74 "
75 * a
76
77 \^@* b"
78 "
79 * a
80
81 \^@* b"
82 ))
83 (should (ert-equal-buffer
84 '(indent-for-tab)
85 "
86 * a
87
88 \^@* b"
89 "
90 * a
91
92 \^@* b"
93 ))
94 (should (ert-equal-buffer
95 '(indent-for-tab)
96 "
97 * a
98 * b
99 XV. c
100 * d
101 * e
102 \^@"
103 "
104 * a
105 * b
106 XV. c
107 * d
108 * e
109 \^@"
110 ))
111 (should (ert-equal-buffer
112 '(indent-for-tab)
113 "
114 * a
115 * b
116 XV. c
117 * d
118 * e
119 \^@"
120 "
121 * a
122 * b
123 XV. c
124 * d
125 * e
126 \^@"
127 ))
128 (should (ert-equal-buffer
129 '(indent-for-tab)
130 "
131 * a
132 * b
133 XV. c
134 * d
135 * e\^@"
136 "
137 * a
138 * b
139 XV. c
140 * d
141 * e\^@"
142 ))
143 (should (ert-equal-buffer
144 '(indent-for-tab)
145 "
146 * a
147 * b
148 XV. c
149 * d
150 * e\^@"
151 "
152 * a
153 * b
154 XV. c
155 * d
156 * e\^@"
157 ))
158 (should (ert-equal-buffer
159 '(indent-for-tab)
160 "
161 * a
162 * b
163 XV. c
164 * d
165 * e\^@"
166 "
167 * a
168 * b
169 XV. c
170 * d
171 * e\^@"
172 ))
173 (should (ert-equal-buffer
174 '(indent-for-tab)
175 "
176 * a
177 * b
178 XV. c
179 * d
180 * e\^@"
181 "
182 * a
183 * b
184 XV. c
185 * d
186 * e\^@"
187 ))
188 (should (ert-equal-buffer
189 '(indent-for-tab)
190 "
191 .. [CIT]
192
193 citation
194
195 .. |sub| dir:: Same
196
197 * a
198
199 * b
200
201 :f: val::
202 \^@"
203 "
204 .. [CIT]
205
206 citation
207
208 .. |sub| dir:: Same
209
210 * a
211
212 * b
213
214 :f: val::
215 \^@"
216 ))
217 (should (ert-equal-buffer
218 '(indent-for-tab)
219 "
220 .. [CIT]
221
222 citation
223
224 .. |sub| dir:: Same
225
226 * a
227
228 * b
229
230 :f: val::
231 \^@"
232 "
233 .. [CIT]
234
235 citation
236
237 .. |sub| dir:: Same
238
239 * a
240
241 * b
242
243 :f: val::
244 \^@"
245 ))
246 (should (ert-equal-buffer
247 '(indent-for-tab)
248 "
249 .. [CIT]
250
251 citation
252
253 .. |sub| dir:: Same
254
255 * a
256
257 * b
258
259 :f: val::
260 \^@"
261 "
262 .. [CIT]
263
264 citation
265
266 .. |sub| dir:: Same
267
268 * a
269
270 * b
271
272 :f: val::
273 \^@"
274 ))
275 (should (ert-equal-buffer
276 '(indent-for-tab)
277 "
278 .. [CIT]
279
280 citation
281
282 .. |sub| dir:: Same
283
284 * a
285
286 * b
287
288 :f: val::
289 \^@"
290 "
291 .. [CIT]
292
293 citation
294
295 .. |sub| dir:: Same
296
297 * a
298
299 * b
300
301 :f: val::
302 \^@"
303 ))
304 (should (ert-equal-buffer
305 '(indent-for-tab)
306 "
307 .. [CIT]
308
309 citation
310
311 .. |sub| dir:: Same
312
313 * a
314
315 * b
316
317 :f: val::
318 \^@"
319 "
320 .. [CIT]
321
322 citation
323
324 .. |sub| dir:: Same
325
326 * a
327
328 * b
329
330 :f: val::
331 \^@"
332 ))
333 (should (ert-equal-buffer
334 '(indent-for-tab)
335 "
336 .. [CIT]
337
338 citation
339
340 .. |sub| dir:: Same
341
342 * a
343
344 * b
345
346 :f: val::
347 \^@"
348 "
349 .. [CIT]
350
351 citation
352
353 .. |sub| dir:: Same
354
355 * a
356
357 * b
358
359 :f: val::
360 \^@"
361 ))
362 (should (ert-equal-buffer
363 '(indent-for-tab)
364 "
365 .. [CIT]
366
367 citation
368
369 .. |sub| dir:: Same
370
371 * a
372
373 * b
374
375 :f: val::
376 \^@"
377 "
378 .. [CIT]
379
380 citation
381
382 .. |sub| dir:: Same
383
384 * a
385
386 * b
387
388 :f: val::
389 \^@"
390 ))
391 (should (ert-equal-buffer
392 '(indent-for-tab)
393 "
394 .. [CIT]
395
396 citation
397
398 .. |sub| dir:: Same
399
400 * a
401
402 * b
403
404 :f: val::
405 \^@"
406 "
407 .. [CIT]
408
409 citation
410
411 .. |sub| dir:: Same
412
413 * a
414
415 * b
416
417 :f: val::
418 \^@"
419 ))
420 (should (ert-equal-buffer
421 '(indent-for-tab)
422 "
423 .. [CIT]
424
425 citation
426
427 .. |sub| dir:: Same
428
429 * a
430
431 * b
432
433 :f: val::
434 \^@"
435 "
436 .. [CIT]
437
438 citation
439
440 .. |sub| dir:: Same
441
442 * a
443
444 * b
445
446 :f: val::
447 \^@"
448 ))
449 ))
450
451 (ert-deftest indent-for-tab-command-BUGS ()
452 "Exposes bugs for `indent-for-tab-command'."
453 :expected-result :failed ;; These are bugs
454 (let ((rst-indent-width 2)
455 (rst-indent-field 2)
456 (rst-indent-literal-normal 3)
457 (rst-indent-literal-minimized 2)
458 (rst-indent-comment 3))
459 ;; Bug https://sourceforge.net/p/docutils/bugs/299/
460 (should (ert-equal-buffer
461 '(indent-for-tab)
462 "
463 Lorem ipsum dolor sit amet, consectetur adipisicing elit
464 :other:`something` sed do eiusmod tempor incididunt ut
465 \^@"
466 "
467 Lorem ipsum dolor sit amet, consectetur adipisicing elit
468 :other:`something` sed do eiusmod tempor incididunt ut
469 \^@"
470 ))))