Skip to content

Commit

Permalink
Test lazy for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Oct 20, 2017
1 parent 4a6da2c commit 3659ede
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion S04-statements/for.t
Expand Up @@ -4,7 +4,7 @@ use MONKEY-TYPING;

use Test;

plan 104;
plan 107;

=begin description
Expand Down Expand Up @@ -755,4 +755,13 @@ subtest 'next with label works inside list comprehended for loops' => {
is $i, 2, 'for statement sinks its content';
}

{
my $loops = 0;
my @values = lazy for ^10 { $loops++; $_ }
is $loops, 0, 'Lazy for loop does not execution until asked for values';
is @values[^5], (0, 1, 2, 3, 4),
'Lazy for loop produces correct values on demand';
is $loops, 5, 'Lazy for loop does no more work than required';
}

# vim: ft=perl6

0 comments on commit 3659ede

Please sign in to comment.