* lisp/progmodes/perl-mode.el (perl--syntax-exp-intro-regexp): Bug#42168
* test/lisp/progmodes/cperl-mode-tests.el: Adjust for `perl-mode`. (cperl-test-ppss): Rename from `cperl-test-face` and change return value. (cperl-mode-test-bug-42168): Test the `syntax-ppss` state rather than the font-lock faces, so it works for both `perl-mode` and `cperl-mode`.
This commit is contained in:
parent
5c39f6f116
commit
7a7847d7ad
2 changed files with 16 additions and 13 deletions
|
@ -214,7 +214,9 @@
|
|||
(defconst perl--syntax-exp-intro-regexp
|
||||
(concat "\\(?:\\(?:^\\|[^$@&%[:word:]]\\)"
|
||||
(regexp-opt perl--syntax-exp-intro-keywords)
|
||||
"\\|[-?:.,;|&+*=!~({[]\\|\\(^\\)\\)[ \t\n]*")))
|
||||
"\\|[?:.,;|&*=!~({[]"
|
||||
"\\|[^-+][-+]" ;Bug#42168: `+' is intro but `++' isn't!
|
||||
"\\|\\(^\\)\\)[ \t\n]*")))
|
||||
|
||||
(defun perl-syntax-propertize-function (start end)
|
||||
(let ((case-fold-search nil))
|
||||
|
|
|
@ -16,16 +16,17 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(defun cperl-test-face (text regexp)
|
||||
"Returns the face of the first character matched by REGEXP in TEXT."
|
||||
(defvar cperl-test-mode #'cperl-mode)
|
||||
|
||||
(defun cperl-test-ppss (text regexp)
|
||||
"Return the `syntax-ppss' of the first character matched by REGEXP in TEXT."
|
||||
(interactive)
|
||||
(with-temp-buffer
|
||||
(insert text)
|
||||
(cperl-mode)
|
||||
(font-lock-ensure (point-min) (point-max))
|
||||
(goto-char (point-min))
|
||||
(re-search-forward regexp)
|
||||
(get-text-property (match-beginning 0) 'face)))
|
||||
(insert text)
|
||||
(funcall cperl-test-mode)
|
||||
(goto-char (point-min))
|
||||
(re-search-forward regexp)
|
||||
(syntax-ppss)))
|
||||
|
||||
(ert-deftest cperl-mode-test-bug-42168 ()
|
||||
"Verify that '/' is a division after ++ or --, not a regexp.
|
||||
|
@ -37,14 +38,14 @@ have a face property."
|
|||
;; 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)))
|
||||
(should (equal (nth 8 (cperl-test-ppss code "/")) nil)))
|
||||
(let ((code "{ $a-- / $b }"))
|
||||
(should (equal (cperl-test-face code "/" ) nil)))
|
||||
(should (equal (nth 8 (cperl-test-ppss 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)))
|
||||
(should (equal (nth 8 (cperl-test-ppss code "/")) 7)))
|
||||
(let ((code "{ $a- / $b } # /"))
|
||||
(should (equal (cperl-test-face code "/" ) font-lock-constant-face))))
|
||||
(should (equal (nth 8 (cperl-test-ppss code "/")) 7))))
|
||||
|
||||
;;; cperl-mode-tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue