aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHarald Jörg2023-07-01 21:37:29 +0200
committerHarald Jörg2023-07-01 21:40:46 +0200
commitce8e6cea4213ce08d04507632546dfe02cc7410b (patch)
treeb8850b4ca5b22ec85476e0e4af0d5203d9f70bf2 /test
parent75278855f4ac0c4514c0e343cd0248ef5c814ff4 (diff)
downloademacs-ce8e6cea4213ce08d04507632546dfe02cc7410b.tar.gz
emacs-ce8e6cea4213ce08d04507632546dfe02cc7410b.zip
cperl-mode.el: Support Perl 5.38 syntax for subroutine signatures
* lisp/progmodes/cperl-mode.el (defconst): New rx sequence describing a signature with initialization. (cperl-init-faces): integrate the new rx sequence into the font-lock-defaults init routine (Bug#64190) (Bug#64364). * test/lisp/progmodes/cperl-mode-resources/cperl-bug-64364.pl: Add test data for a signature with initialization (tests indentation). * test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl: Add test data for a signature with initialization (tests fontification).
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/cperl-mode-resources/cperl-bug-64364.pl29
-rw-r--r--test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl10
2 files changed, 38 insertions, 1 deletions
diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-bug-64364.pl b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-64364.pl
index af188cbedac..62ef6982f38 100644
--- a/test/lisp/progmodes/cperl-mode-resources/cperl-bug-64364.pl
+++ b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-64364.pl
@@ -24,3 +24,32 @@ package P {
24 } 24 }
25} 25}
26# -------- Bug#64364: end ------- 26# -------- Bug#64364: end -------
27
28# Now do this with multiline initializers
29# -------- signature with init: input -------
30package P {
31sub way { ...; }
32# perl 5.38 or newer
33sub bus
34:lvalue
35($sig,
36$na //= 42,
37@ture)
38{
39...;
40}
41}
42# -------- signature with init: expected output -------
43package P {
44 sub way { ...; }
45 # perl 5.38 or newer
46 sub bus
47 :lvalue
48 ($sig,
49 $na //= 42,
50 @ture)
51 {
52 ...;
53 }
54}
55# -------- signature with init: end -------
diff --git a/test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl b/test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl
index 6ed5c0dfc41..1f898250252 100644
--- a/test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl
+++ b/test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl
@@ -34,9 +34,17 @@ sub sub_4 :prototype($$$) ($foo,$bar,$baz) { ...; }
34# A signature with a trailing comma (weird, but legal) 34# A signature with a trailing comma (weird, but legal)
35sub sub_5 ($foo,$bar,) { ...; } 35sub sub_5 ($foo,$bar,) { ...; }
36 36
37# Perl 5.38-style initializer
38sub sub_6
39 ($foo,
40 $bar //= "baz")
41{
42}
43
44
37# Part 2: Same constructs for anonymous subs 45# Part 2: Same constructs for anonymous subs
38# A plain named subroutine without any optional stuff 46# A plain named subroutine without any optional stuff
39my $subref_0 = sub { ...; } 47my $subref_0 = sub { ...; };
40 48
41# A prototype and a trivial subroutine attribute 49# A prototype and a trivial subroutine attribute
42{ 50{