Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix eager-hyper.t tests so that they're actually meaningful
  • Loading branch information
Mouq committed Mar 11, 2015
1 parent a9895b9 commit 1cbaf96
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions S03-metaops/eager-hyper.t
Expand Up @@ -9,24 +9,23 @@ plan 8;
# Laziness test
{
my $counter = 0;
my @test = gather { for 1 .. 5 { $counter++; take $_ } };
my @test := gather { for 1 .. 5 { $counter++; take $_ } };
is(@test[0], 1, 'iterator works as expected');
#?rakudo todo "Array assignment is not lazy -- is this test wrong?"
is($counter, 1, 'iterator was lazy and only ran the block once');
}

# "Counting the elements in the array will also force eager completion."
{
my $counter = 0;
my @test = gather { for 1 .. 5 { $counter++; take $_ } };
my @test := gather { for 1 .. 5 { $counter++; take $_ } };
is(@test.elems, 5, 'iterator has expected length');
is($counter, 5, 'iterator was lazy and only ran the block once');
}

# Eager
{
my $counter = 0;
my @test = eager gather { for 1 .. 5 { $counter++; take $_ } };
my @test := eager gather { for 1 .. 5 { $counter++; take $_ } };
is(@test[0], 1, 'iterator works as expected');
is($counter, 5, 'iterator was eager and calculated all the values');
}
Expand All @@ -36,7 +35,7 @@ plan 8;
#?rakudo skip 'hyper prefix NYI'
{
my $counter = 0;
my @test = hyper gather { for 1 .. 5 { $counter++; take $_; } };
my @test := hyper gather { for 1 .. 5 { $counter++; take $_; } };
is(sort @test, <1 2 3 4 5>, 'hyper returned all the values in some order');
is($counter, 5, 'iterator was hyper and calculated all the values');
}
Expand Down

0 comments on commit 1cbaf96

Please sign in to comment.