<commit_before>use v6;

use Test;

plan 8;

# L<S02/Lists/To force non-lazy list flattening, use the eager list operator>

# Ranges should be the easiest way to get an Iterator for testing eager
{
    my $range = 1 .. 5;
    is(=$range, 1, 'non-eager range iteration');
    ok($range eqv 2 .. 5, 'rest of range is intact');
    my @rest = eager =$range;
    is(@rest, <2 3 4 5>, 'all of range was returned in the correct order');
    ok(!$range, 'range is empty');
}

# L<S02/Lists/A variant of eager is the hyper list operator>
{
    my $range = 1 .. 5;
    is(=$range, 1, 'non-hyper range iteration');
    ok($range eqv 2 .. 5, 'rest of range is intact');
    my @rest = hyper =$range;
    is(sort @rest, <2 3 4 5>, 'all of range was returned in some order');
    ok(!$range, 'range is empty');
}<commit_msg>[gsoc_spectest] fixed eager_hyper.t to use gather/take as suggested by moritz++ (removed 2 tests; only 6 tests in this file now)<commit_after>use v6;

use Test;

plan 6;

# L<S02/Lists/To force non-lazy list flattening, use the eager list operator>

# Laziness test
{
    my $counter = 0;
    my @test = gather { for 1 .. 5 { take $_; $couter++ } };
    is(@test[0], 1, 'iterator works as expected');
    is($counter, 1, 'iterator was lazy and only ran the block once');
}

# Eager
{
    my $counter = 0;
    my @test = eager gather { for 1 .. 5 { take $_; $couter++ } };
    is(@test[0], 1, 'iterator works as expected');
    is($counter, 5, 'iterator was eager and calculated all the values');
}

# L<S02/Lists/A variant of eager is the hyper list operator>
# Hyper
{
    my $counter = 0;
    my @test = hyper gather { for 1 .. 5 { take $_; $couter++ } };
    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');
}
{'fraction_non_alphanumeric': 0.141602634467618, 'fraction_numerical': 0.029088913282107574, 'mean_word_length': 3.115124153498871, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857684', 'n_tokens_mistral': 661, 'n_tokens_neox': 609, 'n_words': 259}