<commit_before>IN: concurrency.flags.tests
USING: tools.test concurrency.flags concurrency.combinators
kernel threads locals ;

:: flag-test-1 ( -- )
    [let | f [ <flag> ] |
        [ f raise-flag ] "Flag test" spawn drop
        f lower-flag
        f flag-value?
    ] ;

[ f ] [ flag-test-1 ] unit-test

:: flag-test-2 ( -- )
    [let | f [ <flag> ] |
        [ 1000 sleep f raise-flag ] "Flag test" spawn drop
        f lower-flag
        f flag-value?
    ] ;

[ f ] [ flag-test-2 ] unit-test

:: flag-test-3 ( -- )
    [let | f [ <flag> ] |
        f raise-flag
        f flag-value?
    ] ;

[ t ] [ flag-test-3 ] unit-test

:: flag-test-4 ( -- )
    [let | f [ <flag> ] |
        [ f raise-flag ] "Flag test" spawn drop
        f wait-for-flag
        f flag-value?
    ] ;

[ t ] [ flag-test-4 ] unit-test

:: flag-test-5 ( -- )
    [let | f [ <flag> ] |
        [ 1000 sleep f raise-flag ] "Flag test" spawn drop
        f wait-for-flag
        f flag-value?
    ] ;

[ t ] [ flag-test-5 ] unit-test

[ ] [
    { 1 2 } <flag>
    [ [ 1000 sleep raise-flag ] curry "Flag test" spawn drop ]
    [ [ wait-for-flag drop ] curry parallel-each ] bi
] unit-test<commit_msg>Fix flags unit tests<commit_after>IN: concurrency.flags.tests
USING: tools.test concurrency.flags concurrency.combinators
kernel threads locals accessors ;

:: flag-test-1 ( -- )
    [let | f [ <flag> ] |
        [ f raise-flag ] "Flag test" spawn drop
        f lower-flag
        f value>>
    ] ;

[ f ] [ flag-test-1 ] unit-test

:: flag-test-2 ( -- )
    [let | f [ <flag> ] |
        [ 1000 sleep f raise-flag ] "Flag test" spawn drop
        f lower-flag
        f value>>
    ] ;

[ f ] [ flag-test-2 ] unit-test

:: flag-test-3 ( -- )
    [let | f [ <flag> ] |
        f raise-flag
        f value>>
    ] ;

[ t ] [ flag-test-3 ] unit-test

:: flag-test-4 ( -- )
    [let | f [ <flag> ] |
        [ f raise-flag ] "Flag test" spawn drop
        f wait-for-flag
        f value>>
    ] ;

[ t ] [ flag-test-4 ] unit-test

:: flag-test-5 ( -- )
    [let | f [ <flag> ] |
        [ 1000 sleep f raise-flag ] "Flag test" spawn drop
        f wait-for-flag
        f value>>
    ] ;

[ t ] [ flag-test-5 ] unit-test

[ ] [
    { 1 2 } <flag>
    [ [ 1000 sleep raise-flag ] curry "Flag test" spawn drop ]
    [ [ wait-for-flag drop ] curry parallel-each ] bi
] unit-test
{'fraction_non_alphanumeric': 0.1623459413514662, 'fraction_numerical': 0.020399490012749683, 'mean_word_length': 1.6933638443935928, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '812597', 'n_tokens_mistral': 890, 'n_tokens_neox': 855, 'n_words': 221}