|
176 | 176 | (equal expected (match-string 1))))) |
177 | 177 | (kill-buffer buffer)))) |
178 | 178 |
|
179 | | -(defmacro def-imenutest (testname filename index &rest body) |
180 | | - `(ert-deftest ,testname () |
181 | | - (let* ((find-file-hook nil) ;; avoid vc-mode file-hooks when opening! |
182 | | - (buffer (find-file-read-only ,filename)) |
183 | | - (,index (csharp--imenu-create-index-function))) |
184 | | - ,@body |
185 | | - (kill-buffer buffer)))) |
186 | | - |
187 | 179 | (defun imenu-get-item (index haystack) |
188 | 180 | (let ((result)) |
189 | 181 | (dolist (item index) |
|
196 | 188 | (setq result (imenu-get-item value haystack))))))) |
197 | 189 | result)) |
198 | 190 |
|
| 191 | +(defmacro def-imenutest (testname filename &rest items) |
| 192 | + `(ert-deftest ,testname () |
| 193 | + (let* ((find-file-hook nil) ;; avoid vc-mode file-hooks when opening! |
| 194 | + (buffer (find-file-read-only ,filename)) |
| 195 | + (index (csharp--imenu-create-index-function))) |
| 196 | + (dolist (item ',items) |
| 197 | + (should (imenu-get-item index item))) |
| 198 | + (kill-buffer buffer)))) |
| 199 | + |
199 | 200 | (def-imenutest imenu-parsing-supports-generic-parameters |
200 | | - "./test-files/imenu-generics-test.cs" imenu-index |
201 | | - (dolist (item '("NoGeneric(" "OneGeneric<T>(" "TwoGeneric<T1,T2>(")) |
202 | | - (should (imenu-get-item imenu-index (concat "(method) " item))))) |
| 201 | + "./test-files/imenu-generics-test.cs" |
| 202 | + "(method) NoGeneric(" "(method) OneGeneric<T>(" "(method) TwoGeneric<T1,T2>(") |
203 | 203 |
|
204 | 204 | (def-imenutest imenu-parsing-supports-comments |
205 | | - "./test-files/imenu-comment-test.cs" imenu-index |
206 | | - (dolist (item '("HasNoComment(" "HasComment(" "CommentedToo(")) |
207 | | - (should (imenu-get-item imenu-index (concat "(method) " item))))) |
| 205 | + "./test-files/imenu-comment-test.cs" |
| 206 | + "(method) HasNoComment(" "(method) HasComment(" "(method) CommentedToo(") |
208 | 207 |
|
209 | 208 | (def-imenutest imenu-parsing-supports-explicit-interface-properties |
210 | | - "./test-files/imenu-interface-property-test.cs" imenu-index |
211 | | - (should (imenu-get-item imenu-index "(prop) IImenuTest.InterfaceString"))) |
| 209 | + "./test-files/imenu-interface-property-test.cs" |
| 210 | + "(prop) IImenuTest.InterfaceString") |
212 | 211 |
|
213 | 212 | (def-imenutest imenu-parsing-supports-explicit-interface-methods |
214 | | - "./test-files/imenu-interface-property-test.cs" imenu-index |
215 | | - (should (imenu-get-item imenu-index "(method) IImenuTest.MethodName"))) |
| 213 | + "./test-files/imenu-interface-property-test.cs" |
| 214 | + "(method) IImenuTest.MethodName") |
216 | 215 |
|
217 | 216 | (def-imenutest imenu-parsing-provides-types-with-namespace-names |
218 | | - "./test-files/imenu-namespace-test.cs" imenu-index |
219 | | - (should (imenu-get-item imenu-index "class ImenuTest.ImenuTestClass")) |
220 | | - (should (imenu-get-item imenu-index "interface ImenuTest.ImenuTestInterface")) |
221 | | - (should (imenu-get-item imenu-index "enum ImenuTest.ImenuTestEnum"))) |
| 217 | + "./test-files/imenu-namespace-test.cs" |
| 218 | + "class ImenuTest.ImenuTestClass" |
| 219 | + "interface ImenuTest.ImenuTestInterface" |
| 220 | + "enum ImenuTest.ImenuTestEnum") |
222 | 221 |
|
223 | 222 | (def-imenutest imenu-parsing-supports-fields-keywords |
224 | | - "./test-files/imenu-field-keyword-test.cs" imenu-index |
225 | | - (should (imenu-get-item imenu-index "(field) TestBool")) |
226 | | - (should (imenu-get-item imenu-index "(field) CommentedField")) |
227 | | - (should (imenu-get-item imenu-index "(field) _MultiLineComment")) |
228 | | - (should (imenu-get-item imenu-index "(field) VolatileTest"))) |
| 223 | + "./test-files/imenu-field-keyword-test.cs" |
| 224 | + "(field) TestBool" |
| 225 | + "(field) CommentedField" |
| 226 | + "(field) _MultiLineComment" |
| 227 | + "(field) VolatileTest") |
229 | 228 |
|
230 | 229 | (def-imenutest imenu-parsing-supports-method-keywords |
231 | | - "./test-files/imenu-method-test.cs" imenu-index |
232 | | - (should (imenu-get-item imenu-index "(method) GetTickCount64(")) |
233 | | - (should (imenu-get-item imenu-index "(method) OpenWebServiceAsync(")) |
234 | | - (should (imenu-get-item imenu-index "(method) ToString(")) |
235 | | - (should (imenu-get-item imenu-index "(method) AbstractMethod(")) |
236 | | - (should (imenu-get-item imenu-index "(method) UnsafeCopy("))) |
237 | | - |
| 230 | + "./test-files/imenu-method-test.cs" |
| 231 | + "(method) GetTickCount64(" |
| 232 | + "(method) OpenWebServiceAsync(" |
| 233 | + "(method) ToString(" |
| 234 | + "(method) AbstractMethod(" |
| 235 | + "(method) UnsafeCopy(") |
238 | 236 |
|
239 | 237 | (ert-deftest imenu-indexing-resolves-correct-container () |
240 | 238 | (let* ((testcase-no-namespace '( ("class Global" . 10) |
|
0 commit comments