summaryrefslogtreecommitdiff
path: root/rust-mode-tests.el
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-01-17 11:24:25 -0500
committerGitHub <noreply@github.com>2017-01-17 11:24:25 -0500
commit0de149a9ad04f652cd7a59a9ef67be8a7d86ba76 (patch)
treee3a9b007a561f7a5d5bf2b64f2a45d16fe5d45bd /rust-mode-tests.el
parent8039d1265a79ff229ca9466a4244bdf21a6c2a89 (diff)
parentb8126e4f647ed6a4f79e623752b0b0821f42890e (diff)
downloadrust-mode-0de149a9ad04f652cd7a59a9ef67be8a7d86ba76.tar.gz
Merge pull request #190 from mrBliss/imenu-extern
Recognize "extern" imenu items
Diffstat (limited to 'rust-mode-tests.el')
-rw-r--r--rust-mode-tests.el40
1 files changed, 40 insertions, 0 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 2585237..7b29ee1 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -3,6 +3,7 @@
(require 'rust-mode)
(require 'ert)
(require 'cl)
+(require 'imenu)
(setq rust-test-fill-column 32)
@@ -2614,6 +2615,45 @@ Fontification needs to include this whole string or none of it.
(rust--after-revert-hook)
(should (equal initial-point (point))))))
+(defun test-imenu (code expected-items)
+ (with-temp-buffer
+ (rust-mode)
+ (insert code)
+ (let ((actual-items
+ ;; Replace ("item" . #<marker at ? in ?.rs) with "item"
+ (mapcar (lambda (class)
+ (cons (car class)
+ (mapcar #'car (cdr class))))
+ (imenu--generic-function rust-imenu-generic-expression))))
+ (should (equal expected-items actual-items)))))
+
+(ert-deftest rust-test-imenu-extern-unsafe-fn ()
+ (test-imenu
+ "
+fn one() {
+}
+
+unsafe fn two() {
+}
+
+extern \"C\" fn three() {
+}
+
+pub extern fn four() {
+
+}
+
+extern \"rust-intrinsic\" fn five() {
+
+}
+"
+ '(("Fn"
+ "one"
+ "two"
+ "three"
+ "four"
+ "five"))))
+
;; If electric-pair-mode is available, load it and run the tests that use it. If not,
;; no error--the tests will be skipped.
(require 'elec-pair nil t)