1 ;;; tests/navigation.el --- Some tests for js2-mode.
3 ;; Copyright (C) 2009, 2011-2013 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 (cl-defun js2-navigation-helper (buffer-content expected-point &optional (point-offset 1))
27 (insert buffer-content)
29 (goto-char (or (- (point) point-offset)))
30 (js2-jump-to-definition)
31 (should (= (point) expected-point))))
33 (ert-deftest js2-jump-to-var ()
34 (js2-navigation-helper "var soup = 2; soup" 5))
36 (ert-deftest js2-jump-to-function ()
37 (js2-navigation-helper "function aFunction() {}; aFunction" 1))
39 (ert-deftest js2-jump-to-function-parameters ()
40 (js2-navigation-helper "var p1 = 4; function aFunction(p1, p2) {p1};" 32 4))
42 (ert-deftest js2-jump-to-object-property ()
43 (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"}; aObject.prop1" 16))