]> git.eshelyaron.com Git - emacs.git/commitdiff
; cperl-mode.el: Add a test for Bug#74245
authorPeter Oliver <git@mavit.org.uk>
Thu, 7 Nov 2024 19:22:21 +0000 (19:22 +0000)
committerEshel Yaron <me@eshelyaron.com>
Sat, 18 Jan 2025 21:59:35 +0000 (22:59 +0100)
* test/lisp/progmodes/cperl-mode-resources/cperl-bug-74245.pl: New test data.

* test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-74245): Verify
that a bare \"$\" can appear at the end of a subroutine signature.

(cherry picked from commit 1fd7957bc72b766ef8d2ddfc4858f714ee0814c0)

test/lisp/progmodes/cperl-mode-resources/cperl-bug-74245.pl [new file with mode: 0644]
test/lisp/progmodes/cperl-mode-tests.el

diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-bug-74245.pl b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-74245.pl
new file mode 100644 (file)
index 0000000..44d1e49
--- /dev/null
@@ -0,0 +1,16 @@
+# This resource file can be run with cperl--run-testcases from
+# cperl-tests.el and works with both perl-mode and cperl-mode.
+
+# -------- signature where last parameter is ignored: input -------
+package P {
+use v5.36;
+sub ignore ($first, $) {}
+ignore(qw(first second));
+}
+# -------- signature where last parameter is ignored: expected output -------
+package P {
+  use v5.36;
+  sub ignore ($first, $) {}
+  ignore(qw(first second));
+}
+# -------- signature where last parameter is ignored: end -------
index dfa1f91e00a1f1d9b0fca738c9a54639ae21fad9..af20c397b23f6343fedcfbcddcdfadb99ef9ea24 100644 (file)
@@ -1589,6 +1589,15 @@ and the slash, then we have a division."
     (should (equal (nth 8 (cperl-test-ppss code "/")) 9)))
   )
 
+(ert-deftest cperl-test-bug-74245 ()
+  "Verify that a bare \"$\" can appear at the end of a subroutine signature.
+It must not be mistaken for \"$)\"."
+  (cperl--run-test-cases
+   (ert-resource-file "cperl-bug-74245.pl")
+   (while (null (eobp))
+     (cperl-indent-command)
+     (forward-line 1))))
+
 (ert-deftest test-indentation ()
   (ert-test-erts-file (ert-resource-file "cperl-indents.erts")))