Skip to content

Commit

Permalink
lolly-proof uses of (;)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimToady committed Aug 18, 2014
1 parent 565ce74 commit e1e9543
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 36 deletions.
4 changes: 2 additions & 2 deletions S02-types/parcel.t
Expand Up @@ -30,8 +30,8 @@ is ?(1,2,3), True, 'non-empty Parcel is True';

lives_ok { <5 7 8>[] }, 'can zen slice a Parcel';

# RT #115282
is (;).elems, 0, '(;) parses, and is empty';
# WAS: RT #115282, modified for lolly brannch
is $(;).elems, 0, '$(;) parses, and is empty';

# .rotate
{
Expand Down
9 changes: 1 addition & 8 deletions S03-feeds/basic.t
Expand Up @@ -13,7 +13,7 @@ Tests for the feed operators
=end pod

plan 25;
plan 24;

{
my @a = (1, 2);
Expand Down Expand Up @@ -114,13 +114,6 @@ plan 25;
is(@(*), <a b c d 0 1 2 3>, 'two feeds to whatever as array');
}

# stacked feeds
#?rakudo todo '* feeds'
{
('a' .. 'd'; 0 .. 3) ==> my @data;
is(@(@data), <a b c d 0 1 2 3>, 'two stacked feeds');
}

# feed and Inf
#?nieza skip "unhandled exception
{
Expand Down
10 changes: 5 additions & 5 deletions S04-blocks-and-statements/let.t
Expand Up @@ -11,7 +11,7 @@ plan 12;
{
my $a = 42;
{
is((let $a = 23; $a), 23, "let() changed the variable (1)");
is($(let $a = 23; $a), 23, "let() changed the variable (1)");
1;
}
is $a, 23, "let() should not restore the variable, as our block exited succesfully (1)";
Expand All @@ -22,7 +22,7 @@ plan 12;
{
my $a = 42;
{
is((let $a = 23; $a), 23, "let() changed the variable (1)");
is($(let $a = 23; $a), 23, "let() changed the variable (1)");
Mu;
}
is $a, 42, "let() should restore the variable, as our block failed";
Expand All @@ -34,7 +34,7 @@ plan 12;
my $a = 42;
my $get_a = { $a };
{
is((let $a = 23; $a), 23, "let() changed the variable (2-1)");
is($(let $a = 23; $a), 23, "let() changed the variable (2-1)");
is $get_a(), 23, "let() changed the variable (2-2)";
1;
}
Expand All @@ -46,7 +46,7 @@ plan 12;
{
my $a = 42;
try {
is((let $a = 23; $a), 23, "let() changed the variable in a try block");
is($(let $a = 23; $a), 23, "let() changed the variable in a try block");
die 57;
};
#?rakudo.jvm todo 'let restore on exception, RT #121647'
Expand All @@ -56,7 +56,7 @@ plan 12;
{
my @array = (0, 1, 2);
{
is((let @array[1] = 42; @array[1]), 42, "let() changed our array element");
is($(let @array[1] = 42; @array[1]), 42, "let() changed our array element");
Mu;
}
is @array[1], 1, "let() restored our array element";
Expand Down
12 changes: 6 additions & 6 deletions S04-blocks-and-statements/temp.t
Expand Up @@ -8,7 +8,7 @@ plan 36;
{
my $a = 42;
{
is((temp $a = 23; $a), 23, "temp() changed the variable (1)");
is($(temp $a = 23; $a), 23, "temp() changed the variable (1)");
}
is $a, 42, "temp() restored the variable (1)";
}
Expand All @@ -19,7 +19,7 @@ plan 36;
my $a = 42;
my $get_a = { $a };
{
is((temp $a = 23; $a), 23, "temp() changed the variable (2-1)");
is($(temp $a = 23; $a), 23, "temp() changed the variable (2-1)");
is $get_a(), 23, "temp() changed the variable (2-2)";
}
is $a, 42, "temp() restored the variable (2)";
Expand All @@ -30,14 +30,14 @@ plan 36;
my $a = 42;
my $get_a = { $a };
{
ok((temp $a = 23; $a =:= $get_a()), "temp() shouldn't change the variable containers");
ok($(temp $a = 23; $a =:= $get_a()), "temp() shouldn't change the variable containers");
}
}

{
our $pkgvar = 42;
{
is((temp $pkgvar = 'not 42'; $pkgvar), 'not 42', "temp() changed the package variable (3-1)");
is($(temp $pkgvar = 'not 42'; $pkgvar), 'not 42', "temp() changed the package variable (3-1)");
}
is $pkgvar, 42, "temp() restored the package variable (3-2)";
}
Expand All @@ -47,7 +47,7 @@ plan 36;
{
my $a = 42;
try {
is((temp $a = 23; $a), 23, "temp() changed the variable in a try block");
is($(temp $a = 23; $a), 23, "temp() changed the variable in a try block");
die 57;
};
is $a, 42, "temp() restored the variable, the block was exited using an exception";
Expand Down Expand Up @@ -156,7 +156,7 @@ EVAL('

#?rakudo todo 'TEMP phasers NYI'
{
is((temp $a; $was_in_own_temp_handler), 1, ".TEMP method was executed on temporization");
is($(temp $a; $was_in_own_temp_handler), 1, ".TEMP method was executed on temporization");
}
#?rakudo todo 'TEMP phasers NYI'
is $was_in_own_temp_handler, 2, ".TEMP method was executed on restoration";
Expand Down
6 changes: 3 additions & 3 deletions S04-statements/terminator.t
Expand Up @@ -37,11 +37,11 @@ eval_dies_ok('my $x = ', 'incomplete expression');

my $z = [];
EVAL q'
$z = [ do { 1 }
+ 2 ];
$z = do { 1 }
+ 2;
';

is($z[0], 2, 'auto-curly applies inside array composer');
is($z, 1, 'auto-curly applies inside array composer');
}

eval_dies_ok "42 if 23\nis 50; 1",
Expand Down
2 changes: 1 addition & 1 deletion S06-operator-overloading/sub.t
Expand Up @@ -176,7 +176,7 @@ Testing operator overloading subroutines
#?niecza todo
{
my proto infix:<;> ($a, $b) { $a + $b }
is (3 ; 2), 5 # XXX correct?
is $(3 ; 2), 5 # XXX correct?
}
# [NOTE]
Expand Down
10 changes: 6 additions & 4 deletions integration/99problems-01-to-10.t
Expand Up @@ -193,10 +193,12 @@ plan 22;
sub group2 (*@array is copy) {
gather while @array {
take [
my $h = @array[0];
gather while @array and $h eq @array[0] {
take shift @array;
}
gather {
my $h = @array[0];
while @array and $h eq @array[0] {
take shift @array;
}
}
];
}
}
Expand Down
10 changes: 5 additions & 5 deletions integration/advent2009-day05.t
Expand Up @@ -21,15 +21,15 @@ ok ([<=] @a), 'All elements of list are numerically sorted';
nok ([<=] @b), 'Not all elements of list are numerically sorted';
is ([min] @a, @b), 2, 'Find the smallest element of two lists';
is (@a »+« @b), [18, 18, 18, 18], 'Hyper operator - pairwise addition';
is (@a_copy = @a; @a_copy»++; @a_copy), [3, 5, 7, 9], 'Hyper operator - increment all elements in a list';
is $(@a_copy = @a; @a_copy»++; @a_copy), [3, 5, 7, 9], 'Hyper operator - increment all elements in a list';
is (@a »min« @b), [2, 4, 6, 8], 'Hyper operator - finding minimum elements';
is (@a »*» 3.5), [7, 14, 21, 28], 'Hyper operator - multiply each element by 3.5';
is (@a »*» $a »+» $b), [10, 18, 26, 34], 'Hyper operator - multiple each element by $a and add $b';
is (1 «/« @a;), [1/2, 1/4, 1/6, 1/8], 'Hyper operator - invert all elements';
is 1 «/« @a, [1/2, 1/4, 1/6, 1/8], 'Hyper operator - invert all elements';
is ((@a »~» ', ') »~« @b), ["2, 16", "4, 14", "6, 12", "8, 10"], 'Hyper operator - concat @a and @b';
is ([+] ( @b »**» 2)), 696, 'Hyper operator - sum of squares';
is ($a1 = $a; $a1 += 5;), ($a2 = $a; $a2 = $a2 + 5), 'In-place += operator is a meta form of + with = suffix';
is ($a1 = $a; $a1 //= 7;), ($a2 = $a; $a2 = $a2 // 7), 'In-place //= operator is a meta form of // with = suffix';
is ($a1 = $a; $a1 min= $b;), ($a2 = $a; $a2 = $a2 min $b), 'In-place min= operator is a meta form of min with = suffix';
is $($a1 = $a; $a1 += 5;), $($a2 = $a; $a2 = $a2 + 5), 'In-place += operator is a meta form of + with = suffix';
is $($a1 = $a; $a1 //= 7;), $($a2 = $a; $a2 = $a2 // 7), 'In-place //= operator is a meta form of // with = suffix';
is $($a1 = $a; $a1 min= $b;), $($a2 = $a; $a2 = $a2 min $b), 'In-place min= operator is a meta form of min with = suffix';

done;
4 changes: 2 additions & 2 deletions integration/advent2009-day06.t
Expand Up @@ -21,13 +21,13 @@ throws_like {@a >>+<< @b}, X::HyperOp::NonDWIM,
is (@a >>+>> 2), [3, 4, 5, 6], 'Single scalars extend to the right';
is (3 <<+<< @a), [4, 5, 6, 7], 'Single scalars extend to the left';
is (~<<@a), ["1", "2", "3", "4"], 'Hyperoperator with prefix operator';
is (@a-copy = @a; @a-copy>>++; @a-copy), [2, 3, 4, 5], 'Hyperoperator with postfix operator';
is $(@a-copy = @a; @a-copy>>++; @a-copy), [2, 3, 4, 5], 'Hyperoperator with postfix operator';
for @pi Z @pi-sin -> $elem, $elem-sin {
is_approx $elem.sin, $elem-sin, 'Hyperoperator used to call .sin on each list element';
}
is ((-1, 0, 3, 42)>>.Str), ["-1", "0", "3", "42"], 'Hyperoperator used to call .Str on each list element';

#?niecza todo
{
is (@a-copy = @a; @a-copy >>/=>> 2; @a-copy), [1/2, 2/2, 3/2, 4/2], 'In-place operators work';
is $(@a-copy = @a; @a-copy >>/=>> 4; @a-copy), [1/2, 2/2, 3/2, 4/2], 'In-place operators work';
}

0 comments on commit e1e9543

Please sign in to comment.