unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob 030bdbe3dbf08353133a36a0fab8a0e29d7fe048 1775 bytes (raw)
name: test/lisp/progmodes/cperl-mode-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
 
;;; cperl-mode-tests --- Test for cperl-mode -*- lexical-binding: t -*-

;; Copyright (C) 2020 Free Software Foundation, Inc.

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

;;; Commentary:

;; This is a collection of tests for the fontification of CPerl-mode.

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

;;; Code:

(defun cperl-test-face (text regexp)
  "Returns the face of the first character matched by REGEXP in TEXT."
  (interactive)
  (with-temp-buffer
      (insert text)
      (cperl-mode)
      (font-lock-fontify-buffer)
      (goto-char (point-min))
      (re-search-forward regexp)
      (get-text-property (match-beginning 0) 'face)))

(ert-deftest cperl-mode-test-bug-42168 ()
  "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.
  (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 030bdbe3db ...
found 030bdbe3db in https://yhetil.org/emacs-bugs/d4507d95-f852-8aa0-500a-a9ef614c6a1e@posteo.de/

applying [1/1] https://yhetil.org/emacs-bugs/d4507d95-f852-8aa0-500a-a9ef614c6a1e@posteo.de/
diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el
new file mode 100644
index 0000000000..030bdbe3db

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

index at:
100644 030bdbe3dbf08353133a36a0fab8a0e29d7fe048	test/lisp/progmodes/cperl-mode-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).