Skip to content

Commit

Permalink
[t/spec] more signature introspection
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.pugscode.org/pugs@28684 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
moritz committed Oct 9, 2009
1 parent 2d1d8c6 commit be253a0
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion S06-signature/introspection.t
Expand Up @@ -5,7 +5,7 @@ plan *;
# L<S06/Signature Introspection>

{
my sub a($x, Int $y?, :$z) { };
sub a($x, Int $y?, :$z) { };
isa_ok &a.signature.params, List, '.params is a List';
my @l = &a.signature.params;
ok ?(all(@l) ~~ Parameter), 'And all items are Paramters';
Expand All @@ -21,7 +21,41 @@ plan *;
is ~(@l>>.slurpy), '0 0 0', '... none slurpy';
is ~(@l>>.optional), '0 1 1', '... some optional';
is ~(@l>>.invocant), '0 0 0', '... none invocant';
is ~(@l>>.named), '0 0 1', '... one named';
}

{
sub b(:x($a)! is rw, :$y is ref, :$z is copy) { };
my @l = &b.signature.params;
#?rakudo todo 'is ref'
is ~(@l>>.readonly), '0 0 0', '(second sig) none are all read-only';
is ~(@l>>.rw), '1 0 0', '... one rw';
#?rakudo todo 'is ref'
is ~(@l>>.ref), '0 1 0', '... one ref';
is ~(@l>>.copy), '0 0 1', '... one copy';
is ~(@l>>.slurpy), '0 0 0', '... none slurpy';
is ~(@l>>.optional), '0 1 1', '... some optional';
is ~(@l>>.invocant), '0 0 0', '... none invocant';
is ~(@l>>.named), '1 1 1', '... one named';

is ~@l[0].named_names, 'x', 'named_names work';
is ~@l[0].name, '$a', '.name works for renamed params';
}

{
sub d(*@pos, *%named) { };
my @l = &d.signature.params;
is ~(@l>>.named), '0 1', '.named for slurpies';
is ~(@l>>.slurpy), '1 1', '.slurpy';
is ~(@l>>.name), '@pos %named', '.name for slurpies';
}


#?rakudo skip 'multi-level renamed parameters'
{
sub d(:x(:y(:z($a)))) { };
is ~&d.signature.params.[0].named_names.sort, 'x y z', 'multi named_names';
is ~&d.signature.params.[0].name, '$a', '... and .name still works';
}


Expand Down

0 comments on commit be253a0

Please sign in to comment.