unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob 4148db036c1f1147363346041a0af9db48c6e5d7 2276 bytes (raw)
name: test/lisp/progmodes/cperl-mode/cperl-fontification-tests.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
;;; cperl-fontification-tests.el --- Test fontification in cperl-mode -*- lexical-binding: t -*-

;; Copyright (C) 2020-2020 ...to be decided ...

;; Author: Harald Jörg <haj@posteo.de>
;; Maintainer: Harald Jörg
;; Keywords:       internal
;; Human-Keywords: internal
;; Homepage: https://github.com/HaraldJoerg/cperl-mode

;;; Commentary:

;; This is a collection of Tests for the fontification of CPerl-mode.
;; The primary target is to verify that the refactoring we're doing
;; right now (May 2020 - ...) doesn't change any behavior, or does the
;; right thing in cases where new fontification rules are enabled.

;; Run these tests interactively:
;; (ert-run-tests-interactively '(tag :fontification))

(defun cperl-test-face (text regexp)
  "Returns the face of the first character matched by REGEXP in TEXT."
  (interactive)
  (with-temp-buffer
    (let ((cperl-hairy nil)
	  (cperl-font-lock nil)) ;; Does this matter?
      (insert text)
      (cperl-mode)
      (font-lock-fontify-buffer)
      (goto-char (point-min))
      (re-search-forward regexp)
      (message "%s" (match-string 0))
      (get-text-property (match-beginning 0) 'face))))

(ert-deftest jrockway-issue-45 ()
  "Verify that '/' is a division after ++ or --, not a regexp.
Reported in https://github.com/jrockway/cperl-mode/issues/45.
If seen as regular expression, then the slash is displayed using
font-lock-constant-face.  If seen as a division, then it doesn't
have a face property."
  :tags '(:fontification)
  ;; The next two Perl expressions have divisions.  Perl "punctuation"
  ;; operators don't get a face.  The comment at the end of line
  ;; prevents cperl-mode from tripping over "End of ‘/ ... /’
  ;; string/RE not found" if it gets it wrong
  (let ((code "{ $a++ / $b } # /"))
    (should (equal (cperl-test-face code "/" ) nil)))
  (let ((code "{ $a-- / $b } # /"))
    (should (equal (cperl-test-face code "/" ) nil)))
  ;; The next two Perl expressions have regular expressions.  The
  ;; delimiter of a RE is fontified with font-lock-constant-face.
  (let ((code "{ $a+ / $b } # /"))
    (should (equal (cperl-test-face code "/" ) font-lock-constant-face)))
  (let ((code "{ $a- / $b } # /"))
    (should (equal (cperl-test-face code "/" ) font-lock-constant-face))))

debug log:

solving 4148db036c ...
found 4148db036c in https://yhetil.org/emacs-bugs/da546d18-f862-ba5f-aa0d-22e8fa8e9581@posteo.de/

applying [1/1] https://yhetil.org/emacs-bugs/da546d18-f862-ba5f-aa0d-22e8fa8e9581@posteo.de/
diff --git a/test/lisp/progmodes/cperl-mode/cperl-fontification-tests.el b/test/lisp/progmodes/cperl-mode/cperl-fontification-tests.el
new file mode 100644
index 0000000000..4148db036c

Checking patch test/lisp/progmodes/cperl-mode/cperl-fontification-tests.el...
Applied patch test/lisp/progmodes/cperl-mode/cperl-fontification-tests.el cleanly.

index at:
100644 4148db036c1f1147363346041a0af9db48c6e5d7	test/lisp/progmodes/cperl-mode/cperl-fontification-tests.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).