summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2024-10-08 22:38:54 +0200
committerUlrich Müller <ulm@gentoo.org>2024-10-08 22:38:54 +0200
commit9e719318d1841d36e35f76e58775ef2a44a81c37 (patch)
tree4fdf2dc277fd081f7c9209ed44be5a549269021a /test/ebuild-mode-tests.el
parentUpdate documentation (diff)
downloadebuild-mode-9e719318d1841d36e35f76e58775ef2a44a81c37.tar.gz
ebuild-mode-9e719318d1841d36e35f76e58775ef2a44a81c37.tar.bz2
ebuild-mode-9e719318d1841d36e35f76e58775ef2a44a81c37.zip
New test for font-lock keywords
* ebuild-mode.el (ebuild-mode-collect-and-split): Preserve order. (ebuild-mode-font-lock-keywords): Add docstring. * test/ebuild-mode-tests.el (ebuild-mode-test-collect-and-split): Update. (ebuild-mode-test-font-lock-keywords): New test. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'test/ebuild-mode-tests.el')
-rw-r--r--test/ebuild-mode-tests.el47
1 files changed, 33 insertions, 14 deletions
diff --git a/test/ebuild-mode-tests.el b/test/ebuild-mode-tests.el
index ac5674d..e3e39a7 100644
--- a/test/ebuild-mode-tests.el
+++ b/test/ebuild-mode-tests.el
@@ -66,6 +66,39 @@
(ebuild-mode-time-string "%Y-%m-%d %H:%M:%S")
"2024-08-10 00:00:00"))))
+(ert-deftest ebuild-mode-test-collect-and-split ()
+ (let* ((alist '(((a b) z) ((c d) z) ((e) z) ((f) z) ((g h) z)
+ ((i j) y x) ((k) y x) ((l)) ((m) z) ((n o) y x) ((p))
+ ((q r s t u v) w)))
+ (alist-copy (copy-tree alist)))
+ (should (equal (ebuild-mode-collect-and-split alist)
+ '(((a b c d e f g h m) z) ((i j k n o) y x) ((l p))
+ ((q r s t u v) w))))
+ (should (equal (ebuild-mode-collect-and-split alist 4)
+ '(((a b c d) z) ((e f g h) z) ((i j k) y x) ((l p))
+ ((m) z) ((n o) y x) ((q r s t) w) ((u v) w))))
+ ;; was it non-destructive?
+ (should (equal alist alist-copy))))
+
+(ert-deftest ebuild-mode-test-font-lock-keywords ()
+ (let ((case-fold-search nil)
+ (find-kw (lambda (key)
+ (catch 'found
+ (dolist (e ebuild-mode-font-lock-keywords)
+ (if (string-match (car e) key)
+ (throw 'found (cdr e))))))))
+ ;; Verify that all regexps are below the 32 KiB limit.
+ ;; Our regexps are ASCII only, so don't bother with string-bytes
+ ;; (GNU Emacs), string-char-byte-conversion-info (XEmacs 21.5),
+ ;; or other horrid incompatibilities.
+ (should (< (apply #'max (mapcar (lambda (e) (length (car e)))
+ ebuild-mode-font-lock-keywords))
+ 32768))
+ (should (equal (funcall find-kw "doins") 'font-lock-builtin-face))
+ (should (equal (funcall find-kw "elisp-compile") 'font-lock-type-face))
+ (should (equal (funcall find-kw "# @ECLASS") '(1 font-lock-type-face t)))
+ (should-not (funcall find-kw "@ECLASS"))))
+
(ert-deftest ebuild-mode-test-font-lock ()
(with-temp-buffer
(ebuild-mode-test-run-silently
@@ -86,20 +119,6 @@
(search-forward "install")
(should-not (get-text-property (match-beginning 0) 'face))))
-(ert-deftest ebuild-mode-test-collect-and-split ()
- (let* ((alist '(((a b) z) ((c d) z) ((e) z) ((f) z) ((g h) z)
- ((i j) y x) ((k) y x) ((l)) ((m) z) ((n o) y x) ((p))
- ((q r s t u v) w)))
- (alist-copy (copy-tree alist)))
- (should (equal (ebuild-mode-collect-and-split alist)
- '(((q r s t u v) w) ((l p)) ((i j k n o) y x)
- ((a b c d e f g h m) z))))
- (should (equal (ebuild-mode-collect-and-split alist 4)
- '(((q r) w) ((s t u v) w) ((n o) y x) ((m) z) ((l p))
- ((i j k) y x) ((e f g h) z) ((a b c d) z))))
- ;; was it non-destructive?
- (should (equal alist alist-copy))))
-
(ert-deftest ebuild-mode-test-update-copyright ()
(let ((ebuild-mode-update-copyright t))
(ebuild-mode-test-run-with-fixed-time