diff options
| author | Harald Jörg | 2023-07-01 21:37:29 +0200 |
|---|---|---|
| committer | Harald Jörg | 2023-07-01 21:40:46 +0200 |
| commit | ce8e6cea4213ce08d04507632546dfe02cc7410b (patch) | |
| tree | b8850b4ca5b22ec85476e0e4af0d5203d9f70bf2 /test | |
| parent | 75278855f4ac0c4514c0e343cd0248ef5c814ff4 (diff) | |
| download | emacs-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.pl | 29 | ||||
| -rw-r--r-- | test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl | 10 |
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 ------- | ||
| 30 | package P { | ||
| 31 | sub way { ...; } | ||
| 32 | # perl 5.38 or newer | ||
| 33 | sub bus | ||
| 34 | :lvalue | ||
| 35 | ($sig, | ||
| 36 | $na //= 42, | ||
| 37 | @ture) | ||
| 38 | { | ||
| 39 | ...; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | # -------- signature with init: expected output ------- | ||
| 43 | package 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) |
| 35 | sub sub_5 ($foo,$bar,) { ...; } | 35 | sub sub_5 ($foo,$bar,) { ...; } |
| 36 | 36 | ||
| 37 | # Perl 5.38-style initializer | ||
| 38 | sub 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 |
| 39 | my $subref_0 = sub { ...; } | 47 | my $subref_0 = sub { ...; }; |
| 40 | 48 | ||
| 41 | # A prototype and a trivial subroutine attribute | 49 | # A prototype and a trivial subroutine attribute |
| 42 | { | 50 | { |