diff --git a/Units/simple-function-parameters.d/args.ctags b/Units/simple-function-parameters.d/args.ctags new file mode 100644 index 0000000000..ed8b96634f --- /dev/null +++ b/Units/simple-function-parameters.d/args.ctags @@ -0,0 +1,2 @@ +--sort=no +--fields=+lK diff --git a/Units/simple-function-parameters.d/expected.tags b/Units/simple-function-parameters.d/expected.tags new file mode 100644 index 0000000000..860028155a --- /dev/null +++ b/Units/simple-function-parameters.d/expected.tags @@ -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 diff --git a/Units/simple-function-parameters.d/input.pl b/Units/simple-function-parameters.d/input.pl new file mode 100644 index 0000000000..66ce04475f --- /dev/null +++ b/Units/simple-function-parameters.d/input.pl @@ -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(); + } +}