Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GLR/non-fatal adjustments to some tests.
GLRify parts of tests which are not relevant to tested feature.
In some cases the test still fails, but now for right reasons.
Place code inside try statements which was causing whole-file aborts.
Add an XXX GLR note to write specific tests for a known issue.
  • Loading branch information
skids committed Aug 23, 2015
1 parent d507a7d commit ee49119
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 22 deletions.
10 changes: 5 additions & 5 deletions S06-multi/subsignature.t
Expand Up @@ -5,7 +5,7 @@ use Test;
plan 97;

# Lots of the same tests from this directory run again with
# the parameters in a sibsignature.
# the parameters in a subsignature.

# from by-trait.t
# RT 66588
Expand Down Expand Up @@ -413,14 +413,14 @@ is with_cap(1,2,3,4,5,6), 21, 'captures in multi sigs work';

#RT #114886 - order of declaration matters
{
proto sub fizzbuzz($) {*};
multi sub fizzbuzz(|c(Int $ where * %% 15)) { 'FizzBuzz' };
multi sub fizzbuzz(|c(Int $ where * %% 5)) { 'Buzz' };
multi sub fizzbuzz(|c(Int $ where * %% 3)) { 'Fizz' };
multi sub fizzbuzz(|c(Int $number)) { $number };
is
(1,3,5,15).map(&fizzbuzz).join(" "),
<1 Fizz Buzz FizzBuzz>,
"ordered multi subs";
my $a;
try $a = (1,3,5,15).map(&fizzbuzz).join(" ");
is $a, <1 Fizz Buzz FizzBuzz>, "ordered multi subs";
}

# RT #68528
Expand Down
8 changes: 4 additions & 4 deletions S06-multi/syntax.t
Expand Up @@ -149,14 +149,14 @@ is with_cap(1,2,3,4,5,6), 21, 'captures in multi sigs work';

#RT #114886 - order of declaration matters
{
proto sub fizzbuzz($) {*};
multi sub fizzbuzz(Int $ where * %% 15) { 'FizzBuzz' };
multi sub fizzbuzz(Int $ where * %% 5) { 'Buzz' };
multi sub fizzbuzz(Int $ where * %% 3) { 'Fizz' };
multi sub fizzbuzz(Int $number) { $number };
is
(1,3,5,15).map(&fizzbuzz).join(" "),
<1 Fizz Buzz FizzBuzz>,
"ordered multi subs";
my $a;
try $a = (1,3,5,15).map(&fizzbuzz).join(" ");
is $a, <1 Fizz Buzz FizzBuzz>, "ordered multi subs";
}

# RT #68528
Expand Down
2 changes: 1 addition & 1 deletion S06-other/pairs-as-lvalues.t
Expand Up @@ -19,7 +19,7 @@ eval-dies-ok 'my $var; (key => $var) = "value"';

{
my ($t, $m);
:(:type($t), :motivation($m)) := (type => 'geek', motivation => '-Ofun');
try :(:type($t), :motivation($m)) := (type => 'geek', motivation => '-Ofun');
is $t, 'geek', 'bound to the first pair';
is $m, '-Ofun', 'bound to the second pair';
}
Expand Down
2 changes: 1 addition & 1 deletion S06-signature/positional.t
Expand Up @@ -24,7 +24,7 @@ is my_third( 4, 5, 6), 6, '($, $, $x) works as a signature';
sub f(@a, $i) {
$i ~ "[{map { f($_, $i + 1) }, @a}]"
};
is f([[], [[]], []], 0), "0[1[] 1[2[]] 1[]]",
is f([[], [[],], []], 0), "0[1[] 1[2[]] 1[]]",
'recusion and parameter binding work out fine';
}

Expand Down
10 changes: 6 additions & 4 deletions S06-signature/unpack-array.t
Expand Up @@ -41,15 +41,17 @@ is blat( 2, [2,3,4] ), "2-3-4", 'unpack named array with named pieces';
my @my-array = 4,2,3,4;

sub fsort-only([$p?,*@r]) {
return fsort-only(@r.grep( {$_ <= $p} )),$p,fsort-only(@r.grep( {$_ > $p} )) if $p || @r;
return flat fsort-only(@r.grep( {$_ <= $p} )),$p,fsort-only(@r.grep( {$_ > $p} )) if $p || @r;
}
multi fsort-multi([$p?,*@r]) {
return fsort-multi(@r.grep( {$_ <= $p} )),$p,fsort-multi(@r.grep( {$_ > $p} )) if $p || @r;
return flat fsort-multi(@r.grep( {$_ <= $p} )),$p,fsort-multi(@r.grep( {$_ > $p} )) if $p || @r;
}

#?niecza 2 todo "https://github.com/sorear/niecza/issues/180"
is fsort-only(@my-array).join(' '), '2 3 4 4', 'array unpacking and only-subs';
is fsort-multi(@my-array).join(' '), '2 3 4 4', 'array unpacking and only-multi';
my $a = try fsort-only(@my-array).join(' ');
is $a, '2 3 4 4', 'array unpacking and only-subs';
my $b = try fsort-multi(@my-array).join(' ');
is $b, '2 3 4 4', 'array unpacking and only-multi';
}

for [1,2],[3,4] -> $a [$x, $y] {
Expand Down
16 changes: 9 additions & 7 deletions S09-autovivification/autoincrement.t
Expand Up @@ -13,35 +13,37 @@ plan 7;

{
my $foo = [0];
$foo[0]++;
try $foo[0]++;
is $foo[0], 1, 'lvalue $var[] works';
}

{
my $foo = [[0]];
$foo[0][0]++;
my $foo = [[0],];
try $foo[0][0]++;
is $foo[0][0], 1, 'lvalue $var[][] works';
}

{
my @foo = [0];
@foo[0][0]++;
try @foo[0][0]++;
is @foo[0][0], 1, 'lvalue @var[][] works';
}

{
is ++[[0]][0][0], 1, 'lvalue [[]][][] works';
my $a;
try $a := ++[[0]][0][0];
is $a, 1, 'lvalue [[]][][] works';
}

{
my $foo = {a => [0]};
$foo<a>[0]++;
try $foo<a>[0]++;
is $foo<a>[0], 1, 'lvalue $var<>[] works';
}

{
my %foo = (a => [0]);
%foo<a>[0]++;
try %foo<a>[0]++;
is %foo<a>[0], 1, 'lvalue %var<>[] works';
}

Expand Down
2 changes: 2 additions & 0 deletions S32-list/map.t
Expand Up @@ -74,6 +74,8 @@ my @list = (1 .. 5);

# map with n-ary functions
{
# XXX GLR find hang-proof a way to test that map of
# 0-arity and Inf-arity (proto-less multi) does not hang.
is ~(1,2,3,4).map({ $^a + $^b }), "3 7", "map() works with 2-ary functions";
#?niecza skip 'No value for parameter $b in ANON'
#?rakudo skip "Too few positionals passed; expected 3 arguments but got 1; RT #125146"
Expand Down

0 comments on commit ee49119

Please sign in to comment.