<commit_before>*** Settings ***
Suite Setup       Without return value
Suite Teardown    Nested keywords with return

*** Test Cases ***

Without return value
    ${ret}=    Without Return Value
    Should Be Equal    ${ret}    ${NONE}
    ${r1}    ${r2}    @{r3}=    Without Return Value
    Should Be Equal    ${r1}    ${NONE}
    Should Be Equal    ${r2}    ${NONE}
    Should Be Empty    ${r3}

With single return value
    ${ret}=    With Single Return Value
    Should Be Equal    ${ret}    something to return

With multiple return values
    ${r1}    ${r2}    ${r3}=     With Multiple Return Values
    Should Be Equal     ${r1}     something
    Should Be Equal     ${r2}     to
    Should Be Equal     ${r3}     return

With variable
    ${ret}=    With variable    foo
    Should Be Equal    ${ret}    foo

With list variable
    ${ret}=    With list variable    1    2    3
    Should Be True    ${ret} == ['0', '1', '2', '3']

Escaping
    ${ret}=    With variable    \${not var}
    Should Be Equal    ${ret}    \${not var}
    ${ret}=    With variable    c:\\temp
    Should Be Equal    ${ret}    c:\\temp

In nested keyword
    ${ret}=    Nested keywords with return
    Should Be Equal    ${ret}    should be returned

Inside for loop in keyword
    ${ret}=    With for loop
    Should Be Equal    ${ret}     return foo

Keyword teardown is run
    ${ret}=    With teardown    ${TEST NAME}
    Should Be Equal    ${ret}     something else to return
    Should Be Equal    ${test var}    ${TEST NAME}

In a keyword inside keyword teardown
    With return in keyword inside teardown

Fails if used directly in keyword teardown
    [Documentation]    FAIL    Keyword teardown failed:
    ...                        Invalid 'Return From Keyword' usage.
    Returning directly from keyword teardown fails
    Fail    Should have failed before this

Fails if used outside keywords
    [Documentation]    FAIL    Invalid 'Return From Keyword' usage.\n\n
    ...    Also teardown failed:\nInvalid 'Return From Keyword' usage.
    Return From Keyword    ${non existent variable}
    [Teardown]    Return From Keyword

Fails if used outside keywords inside for loop
    [Documentation]    FAIL    Invalid 'Return From Keyword' usage.
    :FOR    ${var}    IN    1    2    3
    \    Return From Keyword

With continuable failure
    [Documentation]    FAIL    continuable error
    ${ret}=    With continuable failure
    Should Be Equal    ${ret}    this should be returned

With continuable failure in for loop
    [Documentation]    FAIL    continuable error
    ${ret}=    With continuable failure in for loop
    Should Be Equal    ${ret}    something to return

Return From Keyword If
    ${ret}=    With Return From Keyword If
    Should Be Equal    ${ret}    something to return

Return From Keyword If does not evaluate bogus arguments if condition is untrue
    [Documentation]    FAIL Replacing variables from keyword return value failed: Non-existing variable '\${non existent 2}'.
    Return From Keyword If with non-existing variables in arguments


*** Keywords ***

Without Return Value
    Return From Keyword
    Fail    Should have returned before this
    [Return]    Should not ${evaluate}

With Single Return Value
    Return From Keyword    something to return
    Fail    Should have returned before this
    [Return]     Should not ${evaluate}

With Multiple Return Values
    Return From Keyword     something     to      return
    Fail    Should have returned before this
    [Return]     Should    not    ${evaluate}

With variable
    [Arguments]    ${arg}
    Return From Keyword    ${arg}
    Fail     Should have returned before this
    [Return]     Should not ${evaluate}

With list variable
    [Arguments]    @{list}
    Return From Keyword    0    @{list}
    Fail     Should have returned before this
    [Return]     Should not ${evaluate}

Nested keywords with return
    Without Return Value
    ${ret}=    With Single Return Value
    Should Be Equal    ${ret}    something to return
    [Return]    should be returned

With for loop
    :FOR    ${var}    IN    foo    bar    baz
    \       Return From Keyword    return ${var}
    \       Fail    Should have returned before this
    [Return]     Should not ${evaluate}

With teardown
    [Arguments]    ${arg}<commit_msg>Added test for multiple Return From Keyword values of different type<commit_after>*** Settings ***
Suite Setup       Without return value
Suite Teardown    Nested keywords with return

*** Test Cases ***

Without return value
    ${ret}=    Without Return Value
    Should Be Equal    ${ret}    ${NONE}
    ${r1}    ${r2}    @{r3}=    Without Return Value
    Should Be Equal    ${r1}    ${NONE}
    Should Be Equal    ${r2}    ${NONE}
    Should Be Empty    ${r3}

With single return value
    ${ret}=    With Single Return Value
    Should Be Equal    ${ret}    something to return

With multiple return values
    ${r1}    ${r2}    ${r3}    ${r4}=     With Multiple Return Values
    Should Be Equal     ${r1}     something
    Should Be Equal     ${r2}     ${true}
    Should Be Equal     ${r3}     100
    Should Be Equal     ${r4}     \\

With variable
    ${ret}=    With variable    foo
    Should Be Equal    ${ret}    foo

With list variable
    ${ret}=    With list variable    1    2    3
    Should Be True    ${ret} == ['0', '1', '2', '3']

Escaping
    ${ret}=    With variable    \${not var}
    Should Be Equal    ${ret}    \${not var}
    ${ret}=    With variable    c:\\temp
    Should Be Equal    ${ret}    c:\\temp

In nested keyword
    ${ret}=    Nested keywords with return
    Should Be Equal    ${ret}    should be returned

Inside for loop in keyword
    ${ret}=    With for loop
    Should Be Equal    ${ret}     return foo

Keyword teardown is run
    ${ret}=    With teardown    ${TEST NAME}
    Should Be Equal    ${ret}     something else to return
    Should Be Equal    ${test var}    ${TEST NAME}

In a keyword inside keyword teardown
    With return in keyword inside teardown

Fails if used directly in keyword teardown
    [Documentation]    FAIL    Keyword teardown failed:
    ...                        Invalid 'Return From Keyword' usage.
    Returning directly from keyword teardown fails
    Fail    Should have failed before this

Fails if used outside keywords
    [Documentation]    FAIL    Invalid 'Return From Keyword' usage.\n\n
    ...    Also teardown failed:\nInvalid 'Return From Keyword' usage.
    Return From Keyword    ${non existent variable}
    [Teardown]    Return From Keyword

Fails if used outside keywords inside for loop
    [Documentation]    FAIL    Invalid 'Return From Keyword' usage.
    :FOR    ${var}    IN    1    2    3
    \    Return From Keyword

With continuable failure
    [Documentation]    FAIL    continuable error
    ${ret}=    With continuable failure
    Should Be Equal    ${ret}    this should be returned

With continuable failure in for loop
    [Documentation]    FAIL    continuable error
    ${ret}=    With continuable failure in for loop
    Should Be Equal    ${ret}    something to return

Return From Keyword If
    ${ret}=    With Return From Keyword If
    Should Be Equal    ${ret}    something to return

Return From Keyword If does not evaluate bogus arguments if condition is untrue
    [Documentation]    FAIL Replacing variables from keyword return value failed: Non-existing variable '\${non existent 2}'.
    Return From Keyword If with non-existing variables in arguments


*** Keywords ***

Without Return Value
    Return From Keyword
    Fail    Should have returned before this
    [Return]    Should not ${evaluate}

With Single Return Value
    Return From Keyword    something to return
    Fail    Should have returned before this
    [Return]     Should not ${evaluate}

With Multiple Return Values
    Return From Keyword     something     ${true}     100    \\
    Fail    Should have returned before this
    [Return]     Should    not    ${evaluate}

With variable
    [Arguments]    ${arg}
    Return From Keyword    ${arg}
    Fail     Should have returned before this
    [Return]     Should not ${evaluate}

With list variable
    [Arguments]    @{list}
    Return From Keyword    0    @{list}
    Fail     Should have returned before this
    [Return]     Should not ${evaluate}

Nested keywords with return
    Without Return Value
    ${ret}=    With Single Return Value
    Should Be Equal    ${ret}    something to return
    [Return]    should be returned

With for loop
    :FOR    ${var}    IN    foo    bar    baz
    \       Return From Keyword    return ${var}
    \       Fail    Should have returned before this
    [Return]     Should not ${evaluate}

With teardown
    [Arguments]    ${arg}
{'fraction_non_alphanumeric': 0.07353277003882165, 'fraction_numerical': 0.0063941539164192734, 'mean_word_length': 2.3065307663269157, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2485769', 'n_tokens_mistral': 2446, 'n_tokens_neox': 2345, 'n_words': 1072}