Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GLRify and defatalize tests. Make new test for one removed GLRism.
  • Loading branch information
skids committed Aug 26, 2015
1 parent c94cd06 commit c7bf5f5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
4 changes: 2 additions & 2 deletions S04-statement-modifiers/unless.t
Expand Up @@ -22,7 +22,7 @@ plan 8;
{
my $answer = 1;
my @x = 41, (42 unless $answer), 43;
my @y = 41, (!$answer ?? 42 !! ()), 43;
my @y = 41, (!$answer ?? 42 !! Slip.new()), 43;
my @z = 41, 43;
is @y, @z, "sanity check";
#?niecza todo "empty list as element not flattened - https://github.com/sorear/niecza/issues/180"
Expand All @@ -32,7 +32,7 @@ plan 8;
{
my $answer = 0;
my @x = 41, (42 unless $answer), 43;
my @y = 41, (!$answer ?? 42 !! ()), 43;
my @y = 41, (!$answer ?? 42 !! Slip.new()), 43;
my @z = 41, 42, 43;
is @y, @z, "sanity check";
is @x, @y, "unless expr on false cond";
Expand Down
11 changes: 7 additions & 4 deletions S04-statement-modifiers/with.t
Expand Up @@ -125,9 +125,12 @@ plan 34;

{
my $answer = Failure.new;
my @x = 41, (42 with $answer), 43;
my @y = 41, ($answer andthen 42), 43;
my @x;
try @x = 41, (42 with $answer), 43;
my @y;
try @y = 41, ($answer andthen 42), 43;
my @z = 41, 43;

is @y, @z, "sanity check";
#?niecza todo "empty list as element not flattened - https://github.com/sorear/niecza/issues/180"
is @x, @y, "with expr on false cond";
Expand Down Expand Up @@ -187,7 +190,7 @@ plan 34;

{
my @x;
(push @x, .abs with 12 div $_) for 0..4;
try (push @x, .abs with 12 div $_) for 0..4;
is @x, (12,6,4,3), 'with/for list comprehension works with parens';
}

Expand All @@ -200,7 +203,7 @@ plan 34;

{
my @x;
(push @x, .WHAT.gist without 12 div $_) for 0..4;
try (push @x, .WHAT.gist without 12 div $_) for 0..4;
is @x, '(Failure)', 'without/for list comprehension works with parens';
}

Expand Down
7 changes: 4 additions & 3 deletions S04-statement-modifiers/without.t
Expand Up @@ -34,8 +34,9 @@ plan 8;

{
my $answer = Failure.new;
my @x = 41, (42 without $answer), 43;
my @y = 41, (!$answer ?? 42 !! ()), 43;
my @x;
try @x = 41, (42 without $answer), 43;
my @y = 41, (!$answer ?? 42 !! Slip.new()), 43;
my @z = 41, 42, 43;
is @y, @z, "sanity check";
is @x, @y, "without expr on false cond";
Expand All @@ -49,7 +50,7 @@ plan 8;

{
my $a = 'oops';
{ $a = $^x } without Failure.new;
try ({ $a = $^x } without Failure.new);
is $a.WHAT, Failure, 'Statement-modifier without runs block with placeholder';
}

Expand Down
24 changes: 23 additions & 1 deletion S04-statements/for_with_only_one_item.t
Expand Up @@ -6,7 +6,7 @@ use Test;

# Test primarily aimed at PIL2JS

plan 9;
plan 12;

# sanity tests
{
Expand Down Expand Up @@ -75,6 +75,28 @@ plan 9;
is $count, 1, 'for $arrayref {...} executes the loop body only once';
}

# for with only one item, is rw
{
my $a = 42;

for ($a,) -> $v is rw { $v++ }
is $a, 43, "for on (a_single_var,) -> is rw";
}

{
my $a = 42;

try for ($a) -> $v is rw { $v++ }
is $a, 43, "for on (a_single_var) -> is rw";
}

{
my $a = 42;

try for $a -> $v is rw { $v++ }
is $a, 43, "for on a_single_var -> is rw";
}

# RT #73400
{
my $capture = \[1,2,3];
Expand Down

0 comments on commit c7bf5f5

Please sign in to comment.