Beispiel #1
0
def test_redefine_variables_illegal():
    """TEST 4.7: Variables can only be defined once.

    Setting a variable in an environment where it is already defined should result
    in an appropriate error.
    """

    env = Environment({"foo": 1})
    with assert_raises_regexp(DiyLangError, "already defined"):
        env.set("foo", 2)
Beispiel #2
0
def test_redefine_variables_illegal():
    """Variables can only be defined once.

    Setting a variable in an environment where it is already defined should result
    in an appropriate error.
    """

    env = Environment({"foo": 1})
    with assert_raises_regexp(DiyLangError, "already defined"):
        env.set("foo", 2)
Beispiel #3
0
def test_set_changes_environment_in_place():
    """TEST 4.6: When calling `set` the environment should be updated"""

    env = Environment()
    env.set("foo", 2)
    assert_equals(2, env.lookup("foo"))
Beispiel #4
0
def test_set_changes_environment_in_place():
    """When calling `set` the environment should be updated"""

    env = Environment()
    env.set("foo", 2)
    assert_equals(2, env.lookup("foo"))