summaryrefslogtreecommitdiff
path: root/test/lisp/ansi-color-tests.el
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2021-09-22 18:37:52 -0700
committerLars Ingebrigtsen <larsi@gnus.org>2021-09-23 22:57:53 +0200
commitceb9da3b7125fbdf0da04a3b158ac1e792c87f4f (patch)
treef91d3765040ae169efbb6bf1e0001dc1e4ae1a5f /test/lisp/ansi-color-tests.el
parent55083d90a30628d9eaa5b94196291ca15098aed0 (diff)
downloademacs-ceb9da3b7125fbdf0da04a3b158ac1e792c87f4f.tar.gz
emacs-ceb9da3b7125fbdf0da04a3b158ac1e792c87f4f.tar.bz2
emacs-ceb9da3b7125fbdf0da04a3b158ac1e792c87f4f.zip
Add support for "bright" ANSI colors in ansi-color
* lisp/ansi-color.el (ansi-color-bold, ansi-color-faint, ansi-color-italic) (ansi-color-underline, ansi-color-slow-blink, ansi-color-fast-blink) (ansi-color-inverse, ansi-color-red, ansi-color-green, ansi-color-yellow) (ansi-color-blue, ansi-color-magenta, ansi-color-cyan, ansi-color-white) (ansi-color-bright-red, ansi-color-bright-green, ansi-color-bright-yellow) (ansi-color-bright-blue, ansi-color-bright-magenta, ansi-color-bright-cyan) (ansi-color-bright-white): New faces. (ansi-color-basic-faces-vector, ansi-color-normal-colors-vector) (ansi-color-bright-colors-vector): New constants. (ansi-color-faces-vector, ansi-color-names-vector): Make obsolete. (ansi-color-bold-is-bright): New defcustom. (ansi-color--find-face): Sort ANSI codes and check 'ansi-color-bold-is-bright'. (ansi-color-apply-sequence): Support bright ANSI colors. (ansi-color-make-color-map, ansi-color-map, ansi-color-map-update): Make obsolete. (ansi-color-get-face-1): Add BRIGHT parameter. * lisp/man.el (Man-ansi-color-basic-faces-vector): New variable. (Man-ansi-color-map): Make obsolete. (Man-fontify-manpage): Use 'Man-ansi-color-basic-faces-vector' here. * test/lisp/ansi-color-tests.el (ansi-color-apply-on-region-bold-is-bright-test): New function.
Diffstat (limited to 'test/lisp/ansi-color-tests.el')
-rw-r--r--test/lisp/ansi-color-tests.el55
1 files changed, 48 insertions, 7 deletions
diff --git a/test/lisp/ansi-color-tests.el b/test/lisp/ansi-color-tests.el
index 107dc8e400b..df674dfc7f0 100644
--- a/test/lisp/ansi-color-tests.el
+++ b/test/lisp/ansi-color-tests.el
@@ -25,17 +25,58 @@
;;; Code:
(require 'ansi-color)
+(eval-when-compile (require 'cl-lib))
-(defvar test-strings '(("\e[33mHello World\e[0m" . "Hello World")
- ("\e[1m\e[3m\e[5mbold italics blink\e[0m" . "bold italics blink")))
+(defvar yellow (face-foreground 'ansi-color-yellow nil 'default))
+(defvar bright-yellow (face-foreground 'ansi-color-bright-yellow nil 'default))
+
+(defvar test-strings
+ `(("Hello World" "Hello World")
+ ("\e[33mHello World\e[0m" "Hello World"
+ (:foreground ,yellow))
+ ("\e[43mHello World\e[0m" "Hello World"
+ (:background ,yellow))
+ ("\e[93mHello World\e[0m" "Hello World"
+ (:foreground ,bright-yellow))
+ ("\e[103mHello World\e[0m" "Hello World"
+ (:background ,bright-yellow))
+ ("\e[1;33mHello World\e[0m" "Hello World"
+ (ansi-color-bold (:foreground ,yellow))
+ (ansi-color-bold (:foreground ,bright-yellow)))
+ ("\e[33;1mHello World\e[0m" "Hello World"
+ (ansi-color-bold (:foreground ,yellow))
+ (ansi-color-bold (:foreground ,bright-yellow)))
+ ("\e[1m\e[33mHello World\e[0m" "Hello World"
+ (ansi-color-bold (:foreground ,yellow))
+ (ansi-color-bold (:foreground ,bright-yellow)))
+ ("\e[33m\e[1mHello World\e[0m" "Hello World"
+ (ansi-color-bold (:foreground ,yellow))
+ (ansi-color-bold (:foreground ,bright-yellow)))
+ ("\e[1m\e[3m\e[5mbold italics blink\e[0m" "bold italics blink"
+ (ansi-color-bold ansi-color-italic ansi-color-slow-blink))
+ ("\e[10munrecognized\e[0m" "unrecognized")))
(ert-deftest ansi-color-apply-on-region-test ()
- (dolist (pair test-strings)
- (with-temp-buffer
- (insert (car pair))
+ (pcase-dolist (`(,input ,text ,face) test-strings)
+ (with-temp-buffer
+ (insert input)
+ (ansi-color-apply-on-region (point-min) (point-max))
+ (should (equal (buffer-string) text))
+ (should (equal (get-char-property (point-min) 'face) face))
+ (when face
+ (should (not (equal (overlays-at (point-min)) nil)))))))
+
+(ert-deftest ansi-color-apply-on-region-bold-is-bright-test ()
+ (pcase-dolist (`(,input ,text ,normal-face ,bright-face) test-strings)
+ (with-temp-buffer
+ (let ((ansi-color-bold-is-bright t)
+ (face (or bright-face normal-face)))
+ (insert input)
(ansi-color-apply-on-region (point-min) (point-max))
- (should (equal (buffer-string) (cdr pair)))
- (should (not (equal (overlays-at (point-min)) nil))))))
+ (should (equal (buffer-string) text))
+ (should (equal (get-char-property (point-min) 'face) face))
+ (when face
+ (should (not (equal (overlays-at (point-min)) nil))))))))
(ert-deftest ansi-color-apply-on-region-preserving-test ()
(dolist (pair test-strings)