[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/forth-mode 89b9904ceb 119/153: Add some tests for font-loc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/forth-mode 89b9904ceb 119/153: Add some tests for font-lock faces |
Date: |
Sat, 29 Jan 2022 08:02:24 -0500 (EST) |
branch: elpa/forth-mode
commit 89b9904cebb48e5bca5e999561cab0515dec8dee
Author: Helmut Eller <eller.helmut@gmail.com>
Commit: Helmut Eller <eller.helmut@gmail.com>
Add some tests for font-lock faces
* tests.el (forth-parsing-words-font-lock): Add some tests.
(forth-backslash-comment-font-lock): Adjust a little as there are
now more keywords and more correct handling of words that are at
the end-of-buffer.
(forth-assert-face): Test 'face of 'font-lock-face. We probably
don't care about how it's implemented as long as it looks the
same.
(forth-strip-|-and-→, forth-strip-|-and-¹²): Use remove
instead of delete. That's slightly nicer.
* forth-syntax.el (forth-syntax--state-normal): Call parser
functions directly so that words that are at the end-of-buffer can
be font-locked.
---
forth-syntax.el | 14 +++++++++-----
test/tests.el | 32 +++++++++++++++++++++++---------
2 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/forth-syntax.el b/forth-syntax.el
index 9992404522..3ea857aa5e 100644
--- a/forth-syntax.el
+++ b/forth-syntax.el
@@ -223,10 +223,13 @@ SYNTAX must be a valid argument for `string-to-syntax'."
#'forth-syntax--state-eob)
(t
(forth-syntax--set-word-syntax start (point))
- (setq forth-syntax--current-word-start start)
- (let ((word (buffer-substring-no-properties start (point))))
- (or (forth-syntax--lookup word)
- #'forth-syntax--state-normal))))))
+ (let* ((word (buffer-substring-no-properties start (point)))
+ (parser (forth-syntax--lookup word)))
+ (cond (parser
+ (setq forth-syntax--current-word-start start)
+ (funcall parser))
+ (t
+ #'forth-syntax--state-normal)))))))
;;; Guess initial state
@@ -262,9 +265,10 @@ SYNTAX must be a valid argument for `string-to-syntax'."
(remove-text-properties start end '(font-lock-face))
(let* ((guess (forth-syntax--guess-state start))
(state (cdr guess)))
- ;;(message "forth-syntax-propertize: %s %s %s" start end guess)
+ (message "forth-syntax-propertize: %s %s %s" start end guess)
(goto-char (car guess))
(while (< (point) end)
+ (message "forth-syntax-propertize2: %s %s" (point) state)
(let ((start (point)))
(setq state (funcall state))
(cl-assert (< start (point))))))))
diff --git a/test/tests.el b/test/tests.el
index 0dfbdb3c19..9b20953fe3 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -34,13 +34,13 @@
(defun forth-strip-|-and-→ (string)
(let* ((s2 (forth-strip-| string))
(pos (1+ (string-match "→" s2))))
- (list (delete ?→ s2) pos)))
+ (list (remove ?→ s2) pos)))
(defun forth-strip-|-and-¹² (string)
(let* ((s2 (forth-strip-| string))
- (start (1+ (string-match "¹" (delete ?² s2))))
- (end (1+ (string-match "²" (delete ?¹ s2)))))
- (list (delete ?² (delete ?¹ s2))
+ (start (1+ (string-match "¹" (remove ?² s2))))
+ (end (1+ (string-match "²" (remove ?¹ s2)))))
+ (list (remove ?² (remove ?¹ s2))
start end)))
(defun forth-assert-face (content face)
@@ -48,7 +48,8 @@
(destructuring-bind (content pos) (forth-strip-|-and-→ content)
(forth-with-temp-buffer content
(font-lock-ensure)
- (should (eq face (get-text-property pos 'face)))))))
+ (should (eq face (or (get-text-property pos 'face)
+ (get-text-property pos 'font-lock-face))))))))
(defun forth-should-indent (expected &optional content)
"Assert that CONTENT turns into EXPECTED after the buffer is re-indented.
@@ -102,9 +103,9 @@ The whitespace before and including \"|\" on each line is
removed."
→x y )" font-lock-comment-face))
(ert-deftest forth-backslash-comment-font-lock ()
- (forth-assert-face "→\\" nil)
+ (forth-assert-face "→\\" font-lock-comment-delimiter-face)
(forth-assert-face "→\\ " font-lock-comment-delimiter-face)
- (forth-assert-face " →\\" nil)
+ (forth-assert-face " →\\" font-lock-comment-delimiter-face)
(forth-assert-face "\t→\\ " font-lock-comment-delimiter-face)
(forth-assert-face " →\\\t" font-lock-comment-delimiter-face)
(forth-assert-face " →\\\n" font-lock-comment-delimiter-face)
@@ -126,7 +127,7 @@ The whitespace before and including \"|\" on each line is
removed."
(forth-assert-face "abort→\" ab\"" font-lock-string-face)
(forth-assert-face ".→\" ab\"" font-lock-string-face)
(forth-assert-face "c→\" ab\"" font-lock-string-face)
- (forth-assert-face "[char] \" →of" nil)
+ (forth-assert-face "[char] \" →swap" nil)
(forth-assert-face "frob\" →ab\" " nil)
(forth-assert-face "s\" →a \n b " font-lock-string-face)
(forth-assert-face "s\" a \n →b " nil)
@@ -143,7 +144,20 @@ The whitespace before and including \"|\" on each line is
removed."
(ert-deftest forth-parsing-words-font-lock ()
(forth-assert-face "postpone ( →x " nil)
- (forth-assert-face "' s\" →x "nil))
+ (forth-assert-face "' s\" →x "nil)
+ (forth-assert-face "case [char] ' →of exit endof " font-lock-keyword-face)
+ (forth-assert-face "→postpone postpone" font-lock-keyword-face)
+ (forth-assert-face "postpone →postpone" nil)
+ (forth-assert-face "→literal" font-lock-keyword-face)
+ (forth-assert-face "postpone →literal" nil)
+ (forth-assert-face "[ 48 ] →literal" font-lock-keyword-face)
+ (forth-assert-face "→: frob ;" font-lock-keyword-face)
+ (forth-assert-face ": →frob ;" font-lock-function-name-face)
+ (forth-assert-face "constant →foo" font-lock-function-name-face)
+ (forth-assert-face "create →foo" font-lock-function-name-face)
+ (forth-assert-face "value →foo" font-lock-function-name-face)
+ (forth-assert-face "variable →foo" font-lock-function-name-face)
+ (forth-assert-face "synonym →foo bar" font-lock-function-name-face))
(ert-deftest forth-indent-colon-definition ()
(forth-should-indent
- [nongnu] elpa/forth-mode 3047dfa37a 008/153: Run a subprocess Forth for interaction., (continued)
- [nongnu] elpa/forth-mode 3047dfa37a 008/153: Run a subprocess Forth for interaction., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 6ab334684b 010/153: Send a string to an interactive Forth session., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b6b1f049b0 017/153: Restart an interactive Forth session., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 7c75c452e9 022/153: Correct autoload cookie format, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode e4ed4a8acf 050/153: Test with both Emacs 23 and 24., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode cc267b4b85 043/153: Symbol completion. Candidates come from a running Forth., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 50adf0d552 024/153: Remove byte-compile warnings., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 85ce58e93e 020/153: Correct package header format, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode d972e9fc7a 019/153: Escape some character constants., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode d09313f19c 035/153: Add forth-eval-region., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 89b9904ceb 119/153: Add some tests for font-lock faces,
ELPA Syncer <=
- [nongnu] elpa/forth-mode d47662b187 037/153: Add some installation and usage instrutions., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1cb3071930 117/153: Move the font-locking for defining words to forth-syntax.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 21033fc700 031/153: Improve sending commands to an interactive Forth session., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1c05a009a3 080/153: Fix warning about speedbar-add-supported-extension., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode ef60dcd180 036/153: If forth-executable is nil, query user for file name., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b29a929b78 028/153: Add provide forms., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 992bfb64b4 103/153: Fix warning about font-lock-fontify-buffer non-interactive use., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode efa1f0a336 046/153: Build Emacs Lisp files., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 1bc27cd6b6 115/153: Support paragraph filling in comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 4868a0ff03 051/153: Fix for imenu integration., ELPA Syncer, 2022/01/29