raz / test / editors / colours.el

27 lines · 1.3 KiB · raw · history · last change ba7f6657

1;; Checks each token of Colours.expect has the face it should.
2(let ((wants (split-string (with-temp-buffer
3 (insert-file-contents "test/editors/Colours.expect")
4 (buffer-string))
5 "\n" t)))
6 (find-file "test/editors/Colours.raz")
7 (font-lock-ensure)
8 (dolist (want wants)
9 (let* ((w (split-string want))
10 (face (save-excursion
11 (goto-char (point-min))
12 (forward-line (1- (string-to-number (nth 0 w))))
13 (forward-char (1- (string-to-number (nth 1 w))))
14 (get-text-property (point) 'face)))
15 (face (if (listp face) (car face) face))
16 (kind (pcase face
17 ((or 'font-lock-comment-face 'font-lock-comment-delimiter-face) "comment")
18 ('font-lock-keyword-face "keyword")
19 ('font-lock-string-face "string")
20 ('font-lock-type-face "type")
21 ('font-lock-builtin-face "builtin")
22 ('font-lock-constant-face "constant"))))
23 ;; numbers and constants share a face
24 (unless (or (equal kind (nth 2 w))
25 (and (equal kind "constant") (equal (nth 2 w) "number")))
26 (message "%s: %s" want face)
27 (kill-emacs 3)))))