Skip to content

Commit

Permalink
Merge 1c6cb51 into 9b35dd3
Browse files Browse the repository at this point in the history
  • Loading branch information
masatake authored Feb 4, 2021
2 parents 9b35dd3 + 1c6cb51 commit 3583da6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Units/simple-function-parameters.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+lK
6 changes: 6 additions & 0 deletions Units/simple-function-parameters.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
foo input.pl /^fun foo($x, $y, $z = 5) {$/;" fun language:FunctionParameters
bar input.pl /^method bar($label, $n) {$/;" method language:FunctionParameters
create_point input.pl /^fun create_point(:$x, :$y, :$color) {$/;" fun language:FunctionParameters
Derived input.pl /^package Derived {$/;" package language:Perl
Derived input.pl /^package Derived {$/;" class language:Moose
go_big input.pl /^ has 'go_big' => ($/;" attribute language:Moose class:Derived
40 changes: 40 additions & 0 deletions Units/simple-function-parameters.d/input.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Taken from https://metacpan.org/pod/Function::Parameters
use Function::Parameters;

# plain function
fun foo($x, $y, $z = 5) {
return $x + $y + $z;
}
print foo(1, 2), "\n"; # 8

# method with implicit $self
method bar($label, $n) {
return "$label: " . ($n * $self->scale);
}

# named arguments: order doesn't matter in the call
fun create_point(:$x, :$y, :$color) {
print "creating a $color point at ($x, $y)\n";
}
create_point(
color => "red",
x => 10,
y => 5,
);

package Derived {
use Function::Parameters qw(:std :modifiers);
use Moo;

extends 'Base';

has 'go_big' => (
is => 'ro',
);

# "around" method with implicit $orig and $self
around size() {
return $self->$orig() * 2 if $self->go_big;
return $self->$orig();
}
}

0 comments on commit 3583da6

Please sign in to comment.