[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5a99c23 20/38: Add tests for jsdoc highlighting
From: |
Dmitry Gutov |
Subject: |
[elpa] master 5a99c23 20/38: Add tests for jsdoc highlighting |
Date: |
Wed, 28 Feb 2018 20:12:11 -0500 (EST) |
branch: master
commit 5a99c2348b7fd6978efc869260f45a9b9af123e6
Author: felipe <address@hidden>
Commit: felipe <address@hidden>
Add tests for jsdoc highlighting
---
tests/jsdoc.el | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/tests/jsdoc.el b/tests/jsdoc.el
new file mode 100644
index 0000000..cf499ed
--- /dev/null
+++ b/tests/jsdoc.el
@@ -0,0 +1,81 @@
+;;; tests/jsdoc.el --- Tests for js2-mode highlighting of jsdoc comments.
+
+;; Copyright (C) 2009, 2011-2017 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'ert-x)
+(require 'js2-mode)
+
+(defun js2-get-font-lock-face-props (beg end)
+ "Return a list of three-tuples (START END FONT-LOCK-FACE).
+BEG and END are the current buffer boundaries to use."
+ (unless (get-char-property beg 'font-lock-face)
+ (setq beg (next-single-char-property-change beg 'font-lock-face nil end)))
+ (let (fontification change)
+ (while (< beg end)
+ (setq change (next-single-char-property-change beg 'font-lock-face nil
end))
+ (push (list beg change (get-char-property beg 'font-lock-face))
fontification)
+ (setq beg (if (get-char-property change 'font-lock-face)
+ change
+ (next-single-char-property-change change 'font-lock-face nil
end))))
+ (nreverse fontification)))
+
+(defmacro js2-jsdoc-deftest (name comment-text fontification)
+ (declare (indent defun))
+ (let ((test-name (intern (format "js2-jsdoc-%s" name))))
+ `(ert-deftest ,test-name ()
+ (ert-with-test-buffer (:name ',test-name)
+ (insert ,comment-text)
+ (js2-mode)
+ (js2-reparse)
+ (should (equal (js2-get-font-lock-face-props (point-min) (point-max))
+ ,fontification))))))
+
+(js2-jsdoc-deftest param
+ "/**\n * @prop {string} p - The property\n */"
+ '((1 8 font-lock-doc-face)
+ (8 13 js2-jsdoc-tag)
+ (13 15 font-lock-doc-face)
+ (15 21 js2-jsdoc-type)
+ (21 23 font-lock-doc-face)
+ (23 24 js2-jsdoc-value)
+ (24 43 font-lock-doc-face)))
+
+(js2-jsdoc-deftest typed
+ "/**\n * @implements {Interface}\n */"
+ '((1 8 font-lock-doc-face)
+ (8 19 js2-jsdoc-tag)
+ (19 21 font-lock-doc-face)
+ (21 30 js2-jsdoc-type)
+ (30 35 font-lock-doc-face)))
+
+(js2-jsdoc-deftest arg
+ "/**\n * @name TheName \n */"
+ '((1 8 font-lock-doc-face)
+ (8 13 js2-jsdoc-tag)
+ (13 14 font-lock-doc-face)
+ (14 21 js2-jsdoc-value)
+ (21 26 font-lock-doc-face)))
+
+(js2-jsdoc-deftest empty
+ "/**\n * @class \n */"
+ '((1 8 font-lock-doc-face)
+ (8 14 js2-jsdoc-tag)
+ (14 19 font-lock-doc-face)))
- [elpa] master 5cb52a7 11/38: Merge pull request #454 from olessavluk/trailing-comma, (continued)
- [elpa] master 5cb52a7 11/38: Merge pull request #454 from olessavluk/trailing-comma, Dmitry Gutov, 2018/02/28
- [elpa] master a27c9cb 17/38: Fix length of shorthand object property nodes (e.g. `{foo, bar}`), Dmitry Gutov, 2018/02/28
- [elpa] master 29d295a 31/38: Merge pull request #476 from lelit/avoid-dynbind, Dmitry Gutov, 2018/02/28
- [elpa] master a495394 34/38: Do not overwrite POS, Dmitry Gutov, 2018/02/28
- [elpa] master 4e032e6 24/38: Merge pull request #467 from felipeochoa/jsdoc-single-line, Dmitry Gutov, 2018/02/28
- [elpa] master 33c7169 32/38: Port over fix for https://debbugs.gnu.org/23391, Dmitry Gutov, 2018/02/28
- [elpa] master 38e4257 37/38: Release new version, Dmitry Gutov, 2018/02/28
- [elpa] master 8488723 29/38: Merge pull request #466 from mishoo/master, Dmitry Gutov, 2018/02/28
- [elpa] master dfaa145 12/38: Add separate object property access face., Dmitry Gutov, 2018/02/28
- [elpa] master 700c024 23/38: Merge pull request #468 from felipeochoa/jsdoc-type, Dmitry Gutov, 2018/02/28
- [elpa] master 5a99c23 20/38: Add tests for jsdoc highlighting,
Dmitry Gutov <=
- [elpa] master a104d62 21/38: [feat] add support for single-line jsdoc highlighting, Dmitry Gutov, 2018/02/28
- [elpa] master 40885b6 36/38: Clarify where to report indentation bugs [ci skip], Dmitry Gutov, 2018/02/28
- [elpa] master a015ec7 33/38: Switch to lexical binding, Dmitry Gutov, 2018/02/28
- [elpa] master d72ed20 35/38: Fix the breakage, Dmitry Gutov, 2018/02/28
- [elpa] master 8d846b0 14/38: Set the correct node pos for unary nodes, Dmitry Gutov, 2018/02/28
- [elpa] master 9088d60 18/38: Drop (constructor nil) on structs where a constructor is defined, Dmitry Gutov, 2018/02/28
- [elpa] master a6c39c2 38/38: Merge commit '38e425785d5ea4600c3642f6500062ecedf694a4' from js2-mode, Dmitry Gutov, 2018/02/28