[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/js2-mode 394b85e 51/61: Add node creation and basic syn
From: |
Dmitry Gutov |
Subject: |
[elpa] externals/js2-mode 394b85e 51/61: Add node creation and basic syntax tests |
Date: |
Sun, 20 Dec 2020 12:20:10 -0500 (EST) |
branch: externals/js2-mode
commit 394b85e0eb5b0a474c49c8ae24eff8ba912466d7
Author: babenhauserheide <arne.babenhauserheide@disy.net>
Commit: babenhauserheide <arne.babenhauserheide@disy.net>
Add node creation and basic syntax tests
---
js2-mode.el | 19 ++++++++++++++-----
tests/parser.el | 19 +++++++++++++++++++
2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 304303e..341f01b 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -6096,10 +6096,10 @@ its relevant fields and puts it into `js2-ti-tokens'."
(?,
(throw 'return js2-COMMA))
(??
- (if (js2-match-char ?.)
- (throw 'return js2-OPTIONAL-CHAINING)
- (if (js2-match-char ??)
- (throw 'return js2-NULLISH-COALESCING)
+ (if (js2-match-char ??)
+ (throw 'return js2-NULLISH-COALESCING)
+ (if (js2-match-char ?.)
+ (throw 'return js2-OPTIONAL-CHAINING)
(throw 'return js2-HOOK))))
(?:
(if (js2-match-char ?:)
@@ -9938,7 +9938,7 @@ If NODE is non-nil, it is the AST node associated with
the symbol."
(defun js2-parse-cond-expr ()
(let ((pos (js2-current-token-beg))
- (pn (js2-parse-or-expr))
+ (pn (js2-parse-nullish-coalescing-expr))
test-expr
if-true
if-false
@@ -10023,6 +10023,15 @@ FIXME: The latter option is unused?"
'js2-parse-eq-expr)))
pn))
+
+(defun js2-parse-nullish-coalescing-expr ()
+ (let ((pn (js2-parse-or-expr)))
+ (when (js2-match-token js2-NULLISH-COALESCING)
+ (setq pn (js2-make-binary js2-NULLISH-COALESCING
+ pn
+ 'js2-parse-nullish-coalescing-expr)))
+ pn))
+
(defconst js2-parse-eq-ops
(list js2-EQ js2-NE js2-SHEQ js2-SHNE))
diff --git a/tests/parser.el b/tests/parser.el
index d890549..094ca29 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -17,6 +17,10 @@
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+;;; Commentary:
+
+;; run tests with M-x ert-run-tests-interactively
+
;;; Code:
(require 'ert)
@@ -1012,6 +1016,21 @@ the test."
(should node)
(should (string= (js2-node-text node) "99"))))
+;; nullish coalescing, via https://github.com/tc39/proposal-nullish-coalescing
+(js2-deftest nullish-coalescing-operator-null-variable
+ "var a = null; a ?? b;"
+ (js2-mode--and-parse)
+ (let ((node (js2-find-node js2-mode-ast 'js2-name-node-p)))
+ (should node)
+ (should (string= (js2-node-text node) "b"))))
+
+(js2-deftest nullish-coalescing-operator-null-value
+ "null ?? b;"
+ (js2-mode--and-parse)
+ (let ((node (js2-find-node js2-mode-ast 'js2-name-node-p)))
+ (should node)
+ (should (string= (js2-node-text node) "b"))))
+
(js2-deftest unary-void-node-start
"var c = void 0"
(js2-mode--and-parse)
- [elpa] externals/js2-mode ffb7099 58/61: Merge pull request #563 from KevinBoyette/update-readme, (continued)
- [elpa] externals/js2-mode ffb7099 58/61: Merge pull request #563 from KevinBoyette/update-readme, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 90e1434 48/61: Merge pull request #558 from phst/edebug, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode eb3be7e 54/61: Fix misplaced paren, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode c1763ab 52/61: add failing tests, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 0f627a4 57/61: Update README.md, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 6740d34 50/61: fix tokencount + structure, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode f956476 60/61: Release new version, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode f7816bd 59/61: Support logical assignment operators, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 40aab27 56/61: Update NEWS, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode b21e117 36/61: Add WindowOrWorkerGlobalScope symbols to js2-browser-externs, Dmitry Gutov, 2020/12/20
- [elpa] externals/js2-mode 394b85e 51/61: Add node creation and basic syntax tests,
Dmitry Gutov <=
- [elpa] externals/js2-mode 29979e5 61/61: Merge branch 'externals/js2-mode' of git+ssh://git.sv.gnu.org/srv/git/emacs/elpa, Dmitry Gutov, 2020/12/20