Skip to content

Commit

Permalink
Merge pull request #120 from titsuki/add-from-loop-test
Browse files Browse the repository at this point in the history
Add from-loop tests
  • Loading branch information
titsuki committed May 16, 2016
2 parents 6fceefc + 6b89cb8 commit 76794a4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion S32-list/seq.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 28;
plan 35;

my @result = 1,2,3;

Expand Down Expand Up @@ -126,3 +126,19 @@ is-deeply @searches[0].Array, @expected-searches, 'seq => array works 3';
throws-like { roundtripped.list }, X::Seq::Consumed,
'.perl on an iterated sequence faithfully reproduces such a sequence';
}
{
my $a = Seq.from-loop({ 1 });
isa-ok $a, Seq, 'from-loop(&body) returns a Seq';
ok $a.is-lazy, 'the Seq object is lazy';
$a = Seq.from-loop({ 1 }, { state $count = 0; $count++ < 10 });
isa-ok $a, Seq, 'from-loop(&body, &condition) returns a Seq';
is $a, (1) xx 10, 'from-loop(&body, &condition) terminates calling &body if &condition returns False';
my $count = 0;
$a = Seq.from-loop({ 1 }, { $count < 10 }, { $count++ });
isa-ok $a, Seq, 'from-loop(&body, &condition, &afterward) returns a Seq';
is $a, (1) xx 10, 'from-loop(&body, &condition, &afterward) terminates calling &body if &condition returns False';
is $count, 10, '&afterward is called after each call to &body.';
}

0 comments on commit 76794a4

Please sign in to comment.