[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b92b3ae 15/22: allow testing for specific errors and add t
From: |
Dmitry Gutov |
Subject: |
[elpa] master b92b3ae 15/22: allow testing for specific errors and add test for object property |
Date: |
Tue, 19 Feb 2019 06:06:47 -0500 (EST) |
branch: master
commit b92b3aeb77f9014ede4ca2c36a34437a6c04cac3
Author: Jason Bell <address@hidden>
Commit: Jason Bell <address@hidden>
allow testing for specific errors and add test for object property
---
js2-mode.el | 3 ++-
tests/navigation.el | 25 ++++++++++++++++++++-----
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 5058020..8543c73 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -12747,7 +12747,8 @@ it marks the next defun after the ones already marked."
(push (or (and names (pop names))
(unless (and (js2-object-prop-node-p parent)
(eq node (js2-object-prop-node-left parent)))
- node)) names)
+ node)
+ (error "Node is not a supported jump node")) names)
(setq node-init (js2-search-scope node names))
;; todo: display list of results in buffer
diff --git a/tests/navigation.el b/tests/navigation.el
index 73737ba..a8ec0cd 100644
--- a/tests/navigation.el
+++ b/tests/navigation.el
@@ -22,15 +22,20 @@
(require 'ert)
(require 'js2-mode)
-(cl-defun js2-navigation-helper (buffer-content &optional expected-point
(point-offset 1))
+(cl-defun js2-navigation-helper (buffer-content &optional expected-point
(point-offset 1) expected-error-msg)
(with-temp-buffer
(insert buffer-content)
- (let ((start-point (or (- (point) point-offset))))
+ (let ((start-point (or (- (point) point-offset)))
+ actual-error-msg)
(js2-mode)
(goto-char start-point)
- (ignore-errors (js2-jump-to-definition))
+ (if expected-error-msg
+ (setq actual-error-msg
+ (cadr (should-error (js2-jump-to-definition) :type 'error)))
+ (js2-jump-to-definition))
(print (format "%d %d" (point) start-point))
- (should (= (point) (or expected-point start-point))))))
+ (should (= (point) (or expected-point start-point)))
+ (should (string= actual-error-msg expected-error-msg)))))
(ert-deftest js2-jump-to-var ()
(js2-navigation-helper "var soup = 2; soup" 5))
@@ -45,7 +50,8 @@
(js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"};
aObject.prop1" 16))
(ert-deftest js2-no-jump-to-object-property ()
- (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"};
anotherObject.prop1"))
+ (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"};
anotherObject.prop1"
+ 61 1 "No jump location found"))
(ert-deftest js2-jump-to-nested-property ()
(js2-navigation-helper "var aObject = {prop1: {prop2: { prop3: 4}}};
aObject.prop1.prop2.prop3" 33))
@@ -59,6 +65,15 @@
(ert-deftest js2-jump-to-property-object-property ()
(js2-navigation-helper "aObject.value = {prop:1};aObject.value.prop" 18))
+(ert-deftest js2-jump-to-function-definition-inside-object-value ()
+ (js2-navigation-helper
+ "function aFunction(p1, p2) {return p1+p2}; module.exports =
{aFunction:aFunction};" 1 6))
+
+(ert-deftest js2-no-jump-to-function-definition-object-property ()
+ (js2-navigation-helper
+ "function aFunction(p1, p2) {return p1+p2}; module.exports =
{aFunction:aFunction};"
+ 67 16 "Node is not a supported jump node"))
+
;; forward-sexp
- [elpa] master 2ed3cc0 17/22: Merge pull request #501 from thorrr/obj-literal-fix, (continued)
- [elpa] master 2ed3cc0 17/22: Merge pull request #501 from thorrr/obj-literal-fix, Dmitry Gutov, 2019/02/19
- [elpa] master 58006df 20/22: Release new version, Dmitry Gutov, 2019/02/19
- [elpa] master 381545b 08/22: Make js2-additional-externs safe as a local variable, Dmitry Gutov, 2019/02/19
- [elpa] master ed955e7 21/22: Update NEWS, Dmitry Gutov, 2019/02/19
- [elpa] master 4125b49a 04/22: Merge pull request #487 from lelit/classify-imported, Dmitry Gutov, 2019/02/19
- [elpa] master 1b0e174 12/22: Don't record js2-xml-ref-node's in js2-recorder-identifiers, Dmitry Gutov, 2019/02/19
- [elpa] master 5165f4d 19/22: Merge pull request #507 from piotr-yuxuan/patch-1, Dmitry Gutov, 2019/02/19
- [elpa] master 4de0e2d 05/22: Don't warn about trailing commas by default, Dmitry Gutov, 2019/02/19
- [elpa] master f863e08 18/22: Update README.md, Dmitry Gutov, 2019/02/19
- [elpa] master d76b4df 09/22: Merge pull request #492 from felipeochoa/additional-externs-safe-local, Dmitry Gutov, 2019/02/19
- [elpa] master b92b3ae 15/22: allow testing for specific errors and add test for object property,
Dmitry Gutov <=
- [elpa] master 76b7f45 16/22: fix bug jumping to function def in shorthand property:value literal, Dmitry Gutov, 2019/02/19
- [elpa] master 19be337 11/22: Merge pull request #496 from wyuenho/bug495, Dmitry Gutov, 2019/02/19
- [elpa] master c5cc951 22/22: Merge commit 'ed955e7f1608cfd2d2713129d65f5fd734842ae4' from js2-mode, Dmitry Gutov, 2019/02/19