<commit_before>import pytest

from thinglang.execution.errors import UnknownVariable, RedeclaredVariable
from thinglang import run


def test_stack_resolution_in_block():
    assert run("""
thing Program
    setup
        number i = 0
        Output.write("outside before, i =", i)
        if true
            Output.write("inside before, i =", i)
            i = 10
            Output.write("inside after, i =", i)

        Output.write("outside after, i =", i)

    """).output == """
outside before, i = 0
inside before, i = 0
inside after, i = 10
outside after, i = 10""".strip()


def test_stack_resolution_error_during_access_after_nested_deceleration():
    with pytest.raises(UnknownVariable):
        run("""
thing Program
    setup

        if true
            number i = 10
            Output.write("inside after, i =", i)

        Output.write("outside after, i =", i)

    """)

<commit_msg>Renamed UnknownVariable error to UnresolvedReference<commit_after>import pytest

from thinglang.execution.errors import UnresolvedReference, RedeclaredVariable
from thinglang import run


def test_stack_resolution_in_block():
    assert run("""
thing Program
    setup
        number i = 0
        Output.write("outside before, i =", i)
        if true
            Output.write("inside before, i =", i)
            i = 10
            Output.write("inside after, i =", i)

        Output.write("outside after, i =", i)

    """).output == """
outside before, i = 0
inside before, i = 0
inside after, i = 10
outside after, i = 10""".strip()


def test_stack_resolution_error_during_access_after_nested_deceleration():
    with pytest.raises(UnresolvedReference):
        run("""
thing Program
    setup

        if true
            number i = 10
            Output.write("inside after, i =", i)

        Output.write("outside after, i =", i)

    """)


{'fraction_non_alphanumeric': 0.11105121293800539, 'fraction_numerical': 0.011859838274932614, 'mean_word_length': 2.576107899807322, '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': '4638225', 'n_tokens_mistral': 600, 'n_tokens_neox': 531, 'n_words': 162}