summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/cperl-mode-tests.el
diff options
context:
space:
mode:
authorHarald Jörg <haj@posteo.de>2020-10-30 13:23:52 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2020-10-30 13:24:01 +0100
commit101a3b78309dff5a7466094a893c5582093a6533 (patch)
treee4c7556082177ae614543603f413e0a88c646477 /test/lisp/progmodes/cperl-mode-tests.el
parentb295174210465c4285729c67ec014e0f5b53f741 (diff)
downloademacs-101a3b78309dff5a7466094a893c5582093a6533.tar.gz
Suppress a misleading message when closing a paren in a regex
* lisp/progmodes/cperl-mode.el (cperl-forward-re): Suppress an error message about "End of string/RE not found" when we are at the end of a narrowed buffer where the end of a RE is temporarily unavailable (Bug#37127). * test/lisp/progmodes/cperl-mode-tests.el (cperl-bug37127): Add a test to verify that the message is suppressed when inappropriate, but appears when the RE *is* incomplete.
Diffstat (limited to 'test/lisp/progmodes/cperl-mode-tests.el')
-rw-r--r--test/lisp/progmodes/cperl-mode-tests.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el
index 9b486ae2e2c..75010f7d0f3 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -220,4 +220,33 @@ point in the distant past, and is still broken in perl-mode. "
(should (equal (nth 3 (syntax-ppss)) nil))
(should (equal (nth 4 (syntax-ppss)) t))))))
+(ert-deftest cperl-bug37127 ()
+ "Verify that closing a paren in a regex goes without a message.
+Also check that the message is issued if the regex terminator is
+missing."
+ (let (collected-messages)
+ ;; Part one: Regex is ok, no messages
+ (ert-with-message-capture collected-messages
+ (with-temp-buffer
+ (insert "$_ =~ /(./;")
+ (cperl-mode)
+ (goto-char (point-min))
+ (search-forward ".")
+ (let ((last-command-event ?\)))
+ (cperl-electric-rparen 1)
+ (cperl-find-pods-heres (point-min) (point-max) t)))
+ (should (string-equal collected-messages "")))
+ ;; part two: Regex terminator missing -> message
+ (ert-with-message-capture collected-messages
+ (with-temp-buffer
+ (insert "$_ =~ /(..;")
+ (goto-char (point-min))
+ (cperl-mode)
+ (search-forward ".")
+ (let ((last-command-event ?\)))
+ (cperl-electric-rparen 1)
+ (cperl-find-pods-heres (point-min) (point-max) t)))
+ (should (string-match "^End of .* string/RE"
+ collected-messages)))))
+
;;; cperl-mode-tests.el ends here