mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
New package, `faceup'
`faceup' is a framework for regression testing of font-lock keywords in ert. It is based on a human-readable markup language. (Bug#16063 and bug#28311). * lisp/emacs-lisp/faceup.el: * test/lisp/emacs-lisp/faceup-tests/faceup-test-basics.el: * test/lisp/emacs-lisp/faceup-tests/faceup-test-files.el: * test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el: * test/lisp/emacs-lisp/faceup-resources/faceup-test-this-file-directory.el: * test/lisp/emacs-lisp/faceup-resources/files/test1.txt: * test/lisp/emacs-lisp/faceup-resources/files/test1.txt.faceup: New files.
This commit is contained in:
parent
bc9300ac5e
commit
a0e5a02125
7 changed files with 1671 additions and 0 deletions
76
test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el
Normal file
76
test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
;;; faceup-test-mode.el --- Dummy major mode for testing `faceup'.
|
||||
|
||||
;; Copyright (C) 2014-2017 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Anders Lindgren
|
||||
;; Keywords: languages, faces
|
||||
|
||||
;; 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Dummy major-mode for testing `faceup', a regression test system for
|
||||
;; font-lock keywords (syntax highlighting rules for Emacs).
|
||||
;;
|
||||
;; This mode use `syntax-propertize' to set the `syntax-table'
|
||||
;; property on "<" and ">" in "<TEXT>" to make them act like
|
||||
;; parentheses.
|
||||
;;
|
||||
;; This mode also sets the `help-echo' property on the text WARNING,
|
||||
;; the effect is that Emacs displays a tooltip when you move your
|
||||
;; mouse on to the text.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defvar faceup-test-mode-syntax-table
|
||||
(make-syntax-table)
|
||||
"Syntax table for `faceup-test-mode'.")
|
||||
|
||||
(defvar faceup-test-font-lock-keywords
|
||||
'(("\\_<WARNING\\_>"
|
||||
(0 (progn
|
||||
(add-text-properties (match-beginning 0)
|
||||
(match-end 0)
|
||||
'(help-echo "Baloon tip: Fly smoothly!"))
|
||||
font-lock-warning-face))))
|
||||
"Highlight rules for `faceup-test-mode'.")
|
||||
|
||||
(defun faceup-test-syntax-propertize (start end)
|
||||
(goto-char start)
|
||||
(funcall
|
||||
(syntax-propertize-rules
|
||||
("\\(<\\)\\([^<>\n]*\\)\\(>\\)"
|
||||
(1 "() ")
|
||||
(3 ")( ")))
|
||||
start end))
|
||||
|
||||
(defmacro faceup-test-define-prog-mode (mode name &rest args)
|
||||
"Define a major mode for a programming language.
|
||||
If `prog-mode' is defined, inherit from it."
|
||||
(declare (indent defun))
|
||||
`(define-derived-mode
|
||||
,mode ,(and (fboundp 'prog-mode) 'prog-mode)
|
||||
,name ,@args))
|
||||
|
||||
(faceup-test-define-prog-mode faceup-test-mode "faceup-test"
|
||||
"Dummy major mode for testing `faceup', a test system for font-lock."
|
||||
(set (make-local-variable 'syntax-propertize-function)
|
||||
#'faceup-test-syntax-propertize)
|
||||
(setq font-lock-defaults '(faceup-test-font-lock-keywords nil)))
|
||||
|
||||
(provide 'faceup-test-mode)
|
||||
|
||||
;;; faceup-test-mode.el ends here
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
;;; faceup-test-this-file-directory.el --- Support file for faceup tests
|
||||
|
||||
;; Copyright (C) 2014-2017 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Anders Lindgren
|
||||
;; Keywords: languages, faces
|
||||
|
||||
;; 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Support file for `faceup-test-basics.el'. This file is used to test
|
||||
;; `faceup-this-file-directory' in various contexts.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defvar faceup-test-this-file-directory (faceup-this-file-directory))
|
||||
|
||||
;;; faceup-test-this-file-directory.el ends here
|
||||
15
test/lisp/emacs-lisp/faceup-resources/files/test1.txt
Normal file
15
test/lisp/emacs-lisp/faceup-resources/files/test1.txt
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
This is a test of `faceup', a regression test system for font-lock
|
||||
keywords. It should use major mode `faceup-test-mode'.
|
||||
|
||||
WARNING: The first word on this line should use
|
||||
`font-lock-warning-face', and a tooltip should be displayed if the
|
||||
mouse pointer is moved over it.
|
||||
|
||||
In this mode "<" and ">" are parentheses, but only when on the same
|
||||
line without any other "<" and ">" characters between them.
|
||||
<OK> <NOT <OK> >
|
||||
<
|
||||
NOT OK
|
||||
>
|
||||
|
||||
test1.txt ends here.
|
||||
15
test/lisp/emacs-lisp/faceup-resources/files/test1.txt.faceup
Normal file
15
test/lisp/emacs-lisp/faceup-resources/files/test1.txt.faceup
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
This is a test of `faceup', a regression test system for font-lock
|
||||
keywords. It should use major mode `faceup-test-mode'.
|
||||
|
||||
«(help-echo):"Baloon tip: Fly smoothly!":«w:WARNING»»: The first word on this line should use
|
||||
`font-lock-warning-face', and a tooltip should be displayed if the
|
||||
mouse pointer is moved over it.
|
||||
|
||||
In this mode «s:"«(syntax-table):(4 . 41):<»"» and «s:"«(syntax-table):(5 . 40):>»"» are parentheses, but only when on the same
|
||||
line without any other «s:"«(syntax-table):(4 . 41):<»"» and «s:"«(syntax-table):(5 . 40):>»"» characters between them.
|
||||
«(syntax-table):(4 . 41):<»OK«(syntax-table):(5 . 40):>» <NOT «(syntax-table):(4 . 41):<»OK«(syntax-table):(5 . 40):>» >
|
||||
<
|
||||
NOT OK
|
||||
>
|
||||
|
||||
test1.txt ends here.
|
||||
Loading…
Add table
Add a link
Reference in a new issue