diff --git a/test/data/proj2-elisp/fake2.el b/test/data/proj2-elisp/fake2.el new file mode 100644 index 0000000..4c325d7 --- /dev/null +++ b/test/data/proj2-elisp/fake2.el @@ -0,0 +1,15 @@ +;; a totally fake file for tests + +(defun when-var-is-in-sig (my-arg2) + (let* ((my-arg 22)) + (if (> my-arg2 my-arg) + "" + (something-else my-arg2)))) + +(defun when-var-is-in-let () + (let* ((my-arg 11) + (my-arg2 22)) + (if (> my-arg2 my-arg) + "" + (when-var-is-in-sig my-arg2)))) +;; end of file diff --git a/test/dumb-jump-test.el b/test/dumb-jump-test.el index 0ce4bc5..3492e51 100644 --- a/test/dumb-jump-test.el +++ b/test/dumb-jump-test.el @@ -175,6 +175,34 @@ (should (string= (plist-get result :path) go-js-file)))) (dumb-jump-go))))) +(ert-deftest dumb-jump-go-var-let-test () + (let ((el-file (f-join test-data-dir-elisp "fake2.el"))) + (with-current-buffer (find-file-noselect el-file t) + (goto-char (point-min)) + (forward-line 13) + (forward-char 33) + (noflet ((dumb-jump-handle-results (a b c d e) + (should (= (length a) 2)) + (funcall this-fn a b c d e)) + (dumb-jump-result-follow (result) + (should (string= (plist-get result :path) el-file)) + (should (= (plist-get result :line) 11)))) + (dumb-jump-go))))) + +(ert-deftest dumb-jump-go-var-arg-test () + (let ((el-file (f-join test-data-dir-elisp "fake2.el"))) + (with-current-buffer (find-file-noselect el-file t) + (goto-char (point-min)) + (forward-line 4) + (forward-char 12) + (noflet ((dumb-jump-handle-results (a b c d e) + (should (= (length a) 2)) + (funcall this-fn a b c d e)) + (dumb-jump-result-follow (result) + (should (string= (plist-get result :path) el-file)) + (should (= (plist-get result :line) 3)))) + (dumb-jump-go))))) + (ert-deftest dumb-jump-back-test () (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js")) (go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js")))