Add support for `imenu` and `which-func-mode`. Remember setting
[docutils/kirr.git] / docutils / tools / editors / emacs / tests / items.el
blobe86af1d4386158356bc7c1e658227475ec6e5823
1 ;; Tests for operations on list items
3 (add-to-list 'load-path ".")
4 (load "init" nil t)
5 (init-rst-ert t)
7 (ert-deftest items-asserts ()
8 "Check some assertions."
9 (should (equal ert-Buf-point-char "\^@"))
10 (should (equal ert-Buf-mark-char "\^?"))
13 (ert-deftest rst-convert-bullets-to-enumeration ()
14 "Tests `rst-convert-bullets-to-enumeration'."
15 (should (ert-equal-buffer
16 (rst-convert-bullets-to-enumeration)
17 "\^@Normal paragraph.
19 * A bullet
21 * Another bullet
23 Another normal paragraph.
25 \^?"
26 "\^@Normal paragraph.
28 1. A bullet
30 2. Another bullet
32 Another normal paragraph.
34 \^?" t))
35 (should (ert-equal-buffer
36 (rst-convert-bullets-to-enumeration)
37 "Normal paragraph.
39 \^?* A bullet
41 * Another bullet
43 \^@Another normal paragraph.
46 "Normal paragraph.
48 \^?1. A bullet
50 2. Another bullet
52 \^@Another normal paragraph.
54 " t))
55 (should (ert-equal-buffer
56 (rst-convert-bullets-to-enumeration)
57 "Normal paragraph.
59 \^?* A bullet
61 * Another bullet
63 1. A bullet
65 2. Another bullet
67 \^@Another normal paragraph.
71 "Normal paragraph.
73 \^?1. A bullet
75 2. Another bullet
77 3. A bullet
79 4. Another bullet
81 \^@Another normal paragraph.
83 " t))
86 (ert-deftest rst-convert-bullets-to-enumeration-BUGS ()
87 "Exposes bugs in `rst-convert-bullets-to-enumeration'."
88 :expected-result :failed ;; These are bugs
89 (should (ert-equal-buffer
90 (rst-convert-bullets-to-enumeration)
91 "\^@Normal paragraph.
93 * A bullet
95 * Another bullet
97 * A bullet
99 * Another bullet
101 Another normal paragraph.
103 \^?"
104 "\^@Normal paragraph.
106 1. A bullet
108 2. Another bullet
110 * A bullet
112 * Another bullet
114 Another normal paragraph.
116 \^?" t))
119 (ert-deftest rst-insert-list-continue ()
120 "Tests `rst-insert-list' when continuing a list."
121 (should (ert-equal-buffer
122 (rst-insert-list)
123 "* Some text\^@\n"
124 "* Some text
125 * \^@\n"))
126 (should (ert-equal-buffer
127 (rst-insert-list)
128 "* Some \^@text\n"
129 "* Some text
130 * \^@\n"))
131 (should (ert-equal-buffer
132 (rst-insert-list)
133 "* \^@Some text\n"
134 "* Some text
135 * \^@\n"))
136 (should (ert-equal-buffer
137 (rst-insert-list)
138 "* Some text
139 - A deeper hyphen bullet\^@\n"
140 "* Some text
141 - A deeper hyphen bullet
142 - \^@\n"))
143 (should (ert-equal-buffer
144 (rst-insert-list)
145 "* Some text
146 - \^@Some text\n"
147 "* Some text
148 - Some text
149 - \^@\n"))
150 (should (ert-equal-buffer
151 (rst-insert-list)
152 "1. Some text\^@\n"
153 "1. Some text
154 2. \^@\n"))
155 (should (ert-equal-buffer
156 (rst-insert-list)
157 "2. Some text\^@\n"
158 "2. Some text
159 3. \^@\n"))
160 (should (ert-equal-buffer
161 (rst-insert-list)
162 "a) Some text\^@\n"
163 "a) Some text
164 b) \^@\n"))
165 (should (ert-equal-buffer
166 (rst-insert-list)
167 "(A) Some text\^@\n"
168 "(A) Some text
169 \(B) \^@\n"))
170 (should (ert-equal-buffer
171 (rst-insert-list)
172 "(I) Some text\^@\n"
173 "(I) Some text
174 \(J) \^@\n"))
175 (should (ert-equal-buffer
176 (rst-insert-list)
177 "(I) Some text\^@\n"
178 "(I) Some text
179 \(J) \^@\n"))
180 (should (ert-equal-buffer
181 (rst-insert-list)
182 "(h) Some text
183 \(i) Some text\^@\n"
184 "(h) Some text
185 \(i) Some text
186 \(j) \^@\n"))
187 (should (ert-equal-buffer
188 (rst-insert-list t)
189 "(i) Some text\^@\n"
190 "(i) Some text
191 \(ii) \^@\n"))
192 (should (ert-equal-buffer
193 (rst-insert-list)
194 "(iv) Some text
195 \(v) Some text\^@\n"
196 "(iv) Some text
197 \(v) Some text
198 \(vi) \^@\n"))
201 (ert-deftest rst-insert-list-continue-BUGS ()
202 "Exposes bugs in `rst-insert-list-continue'."
203 :expected-result :failed ;; These are bugs
204 (should (ert-equal-buffer
205 (rst-insert-list)
206 "(iv) Some text
208 \(v) Some text\^@\n"
209 "(iv) Some text
211 \(v) Some text
212 \(vi) \^@\n")))
214 (ert-deftest rst-insert-list-new ()
215 "Tests `rst-insert-list' when inserting a new list."
216 (should (ert-equal-buffer
217 (rst-insert-list)
218 "\^@\n"
219 "* \^@\n" '("*")))
220 (should (ert-equal-buffer
221 (rst-insert-list)
222 "\^@\n"
223 "- \^@\n" '("-")))
224 (should (ert-equal-buffer
225 (rst-insert-list)
226 "\^@\n"
227 "#. \^@\n" '("#.")))
228 (should (ert-equal-buffer
229 (rst-insert-list)
230 "\^@\n"
231 "5) \^@\n" '("1)" 5)))
232 (should (ert-equal-buffer
233 (rst-insert-list)
234 "\^@\n"
235 "(i) \^@\n" '("(i)" "")))
236 (should (ert-equal-buffer
237 (rst-insert-list)
238 "\^@\n"
239 "IV. \^@\n" '("I." 4)))
240 (should (ert-equal-buffer
241 (rst-insert-list)
242 "Some line\^@\n"
243 "Some line
245 IV. \^@\n" '("I." 4)))
246 (should (ert-equal-buffer
247 (rst-insert-list)
248 "Some line
249 \^@\n"
250 "Some line
252 IV. \^@\n" '("I." 4)))
253 (should (ert-equal-buffer
254 (rst-insert-list)
255 "Some line
257 \^@\n"
258 "Some line
260 IV. \^@\n" '("I." 4)))