summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/cperl-mode-tests.el
diff options
context:
space:
mode:
authorMauro Aranda <maurooaranda@gmail.com>2022-09-20 11:18:45 -0300
committerLars Ingebrigtsen <larsi@gnus.org>2022-09-20 21:11:40 +0200
commit1231a601ebe1fd9fe454c504dbeb9267440242e7 (patch)
tree6c97f9c12ff15e9952e6820c3e120709e1b8ffd5 /test/lisp/progmodes/cperl-mode-tests.el
parentd506d91b1fa98b3868437e4d3638f606b4bd20a0 (diff)
downloademacs-1231a601ebe1fd9fe454c504dbeb9267440242e7.tar.gz
emacs-1231a601ebe1fd9fe454c504dbeb9267440242e7.tar.bz2
emacs-1231a601ebe1fd9fe454c504dbeb9267440242e7.zip
Recognize the backslash operator in perl-mode
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): Add new rule to detect a backslash operator. (Bug#11996) * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-11996): New test. * test/lisp/progmodes/cperl-mode-resources/cperl-bug-11996.pl: New file.
Diffstat (limited to 'test/lisp/progmodes/cperl-mode-tests.el')
-rw-r--r--test/lisp/progmodes/cperl-mode-tests.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el
index 66039d6fc7f..1bb206e7040 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -788,6 +788,36 @@ under timeout control."
(should (string-match
"poop ('foo', \n 'bar')" (buffer-string))))))
+(ert-deftest cperl-test-bug-11996 ()
+ "Verify that we give the right syntax property to a backslash operator."
+ (with-temp-buffer
+ (insert-file-contents (ert-resource-file "cperl-bug-11996.pl"))
+ (funcall cperl-test-mode)
+ (font-lock-ensure)
+ (goto-char (point-min))
+ (re-search-forward "\\(\\\\(\\)")
+ (save-excursion
+ (goto-char (match-beginning 1))
+ (should (equal (syntax-after (point)) (string-to-syntax ".")))
+ ;; `forward-sexp' shouldn't complain.
+ (forward-sexp)
+ (should (char-equal (char-after) ?\;)))
+ (re-search-forward "\\(\\\\\"\\)")
+ (save-excursion
+ (goto-char (match-beginning 1))
+ (should (equal (syntax-after (point)) (string-to-syntax "\\")))
+ (should (equal (get-text-property (point) 'face) 'font-lock-string-face)))
+ (re-search-forward "\\(\\\\\"\\)")
+ (save-excursion
+ (goto-char (match-beginning 1))
+ (should (equal (syntax-after (point)) (string-to-syntax "\\"))))
+ (re-search-forward "\\(\\\\\"\\)")
+ (save-excursion
+ (goto-char (match-beginning 1))
+ (should (equal (syntax-after (point)) (string-to-syntax ".")))
+ (should (equal (get-text-property (1+ (point)) 'face)
+ 'font-lock-string-face)))))
+
(ert-deftest cperl-test-bug-14343 ()
"Verify that inserting text into a HERE-doc string with Elisp
does not break fontification."