<commit_before>use v6;
use Test;

# L<S29/Context/"=item sleep">


plan 11;


#?pugs todo
{
    diag "Sleeping for 3s";
    my $start = time;
    my $sleep_says = sleep 3;
    my $diff = time - $start;

    ok( $sleep_says >= 2 , 'Sleep says it slept at least 2 seconds');
    ok( $sleep_says <= 10 , '... and no more than 10');

    ok( $diff >= 2 , 'We actually slept at least 2 seconds');
    ok( $diff <= 10 , '... and no more than 10');
} #4

#?pugs   todo "not yet implemented"
#?niecza todo "not yet implemented"
{
    is interval( 1.5 ), 0, "first call doesn't wait";
    my $start = time.Num;
    ok 0 <= interval(2.5) < 1.5, "first sleep";
    ok 0 <= interval(5  ) < 2.5, "second sleep";
    ok 0 <= interval(0  ) < 5  , "third sleep";
    is interval(3), 0, "fourth sleep";
    ok 0 <= interval(0  ) < 3  , "fifth sleep";
    ok 12 <= time.Num - $start <= 15, "some overall time";
} #7

# vim: ft=perl6<commit_msg>Add test for sleep with negative values<commit_after>use v6;
use Test;

# L<S29/Context/"=item sleep">

plan 12;

#?pugs todo
{
    diag "Sleeping for 3s";
    my $start = time;
    my $sleep_says = sleep 3;
    my $diff = time - $start;

    ok( $sleep_says >= 2 , 'Sleep says it slept at least 2 seconds');
    ok( $sleep_says <= 10 , '... and no more than 10');

    ok( $diff >= 2 , 'We actually slept at least 2 seconds');
    ok( $diff <= 10 , '... and no more than 10');
} #4

#?pugs   todo "not yet implemented"
#?niecza todo "not yet implemented"
{
    is interval( 1.5 ), 0, "first call doesn't wait";
    my $start = time.Num;
    ok 0 <= interval(2.5) < 1.5, "first sleep";
    ok 0 <= interval(5  ) < 2.5, "second sleep";
    ok 0 <= interval(0  ) < 5  , "third sleep";
    is interval(3), 0, "fourth sleep";
    ok 0 <= interval(0  ) < 3  , "fifth sleep";
    ok 12 <= time.Num - $start <= 15, "some overall time";
} #7

#?pugs   todo "not yet implemented"
{
    dies_ok( { sleep(-1) }, "cannot go back in time" );
} #1

# vim: ft=perl6
{'fraction_non_alphanumeric': 0.1700404858299595, 'fraction_numerical': 0.04757085020242915, 'mean_word_length': 2.6275229357798167, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 9, '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': '3783254', 'n_tokens_mistral': 815, 'n_tokens_neox': 734, 'n_words': 267}