Skip to content

Commit

Permalink
Update signature introspection test for current spec, remove all but …
Browse files Browse the repository at this point in the history
…one Rakudo fudge.
  • Loading branch information
jnthn committed Jan 12, 2012
1 parent 22d53ea commit 31dd22f
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions S06-signature/introspection.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ sub j(*@i) {
sub a($x, Int $y?, :$z) { }; #OK not used
ok &a.signature.params ~~ Positional, '.params does Positional';
my @l = &a.signature.params;
#?rakudo todo 'types or autothreading'
ok ?(all(@l) ~~ Parameter), 'And all items are Parameters';
ok ?(all(@l >>~~>> Parameter)), 'And all items are Parameters';
is +@l, 3, 'we have three of them';
is ~(@l>>.name), '$x $y $z', 'can get the names with sigils';
ok @l[0].type === Any, 'Could get first type';
Expand All @@ -22,22 +21,19 @@ sub j(*@i) {
is j(@l>>.readonly), '1 1 1', 'they are all read-only';
is j(@l>>.rw), '0 0 0', '... none rw';
is j(@l>>.copy), '0 0 0', '... none copy';
is j(@l>>.ref), '0 0 0', '... none ref';
is j(@l>>.parcel), '0 0 0', '... none ref';
is j(@l>>.slurpy), '0 0 0', '... none slurpy';
is j(@l>>.optional), '0 1 1', '... some optional';
is j(@l>>.invocant), '0 0 0', '... none invocant';
is j(@l>>.named), '0 0 1', '... one named';
}

#?rakudo skip 'is ref'
{
sub b(:x($a)! is rw, :$y is ref, :$z is copy) { }; #OK not used
sub b(:x($a)! is rw, :$y is parcel, :$z is copy) { }; #OK not used
my @l = &b.signature.params;
#?rakudo todo 'is ref'
is j(@l>>.readonly), '0 0 0', '(second sig) none are all read-only';
is j(@l>>.rw), '1 0 0', '... one rw';
#?rakudo todo 'is ref'
is j(@l>>.ref), '0 1 0', '... one ref';
is j(@l>>.parcel), '0 1 0', '... one parcel';
is j(@l>>.copy), '0 0 1', '... one copy';
is j(@l>>.slurpy), '0 0 0', '... none slurpy';
is j(@l>>.optional), '0 1 1', '... some optional';
Expand Down Expand Up @@ -66,23 +62,21 @@ sub j(*@i) {
{
sub e($x = 3; $y = { 2 + $x }) { }; #OK not used
my @l = &e.signature.params>>.default;
#?rakudo todo 'types or autothreading'
ok ?( all(@l) ~~ Code ), '.default returns closure';
ok ?( all(@l >>~~>> Code) ), '.default returns closure';
is @l[0].(), 3, 'first closure works';
# XXX The following test is very, very dubious...
#?rakudo skip 'default closure when no call made fails lexical lookup with NPMCA'
is @l[1].().(), 5, 'closure as default value captured outer default value';
}

{
sub f(Int $x where { $_ % 2 == 0 }) { }; #OK not used
my $p = &f.signature.params[0];
#?rakudo todo 'constraints'
ok 4 ~~ $p.constraints, '.constraints (+)';
ok 5 !~~ $p.constraints, '.constraints (-)';
ok 5 ~~ (-> $x { }).signature.params[0].constraints,
'.constraints on unconstraint param should still smartmatch truely';
sub g(Any $x where Int) { }; #OK not used
#?rakudo todo 'constraints'
ok 3 ~~ &g.signature.params[0].constraints,
'smartmach against non-closure constraint (+)';
ok !(3.5 ~~ &g.signature.params[0].constraints),
Expand Down Expand Up @@ -115,9 +109,8 @@ sub j(*@i) {
ok :(|$x).params[0].capture, 'prefix | makes .capture true';
ok :(|$x).perl ~~ / '|' /, 'prefix | appears in .perl output';

#?rakudo 2 skip 'parcel binding'
ok :(\|$x).params[0].parcel, 'prefix \| makes .parcel true';
ok :(\|$x).perl ~~ / '\|' /, 'prefix \| appears in .perl output';
ok :(\$x).params[0].parcel, 'prefix \\ makes .parcel true';
ok :(\$x).perl ~~ / '\\' /, 'prefix \\ appears in .perl output';
}

# RT #69492
Expand Down

0 comments on commit 31dd22f

Please sign in to comment.