def test_env_define_set(self): parent = types.Environment() env = types.Environment(parent=parent) a = types.Symbol("a") parent.define(a, 3) env.set_(a, 5) self.assertEqual(parent[a], 5) self.assertEqual(env[a], 5)
def test_deep_recursive(self): """Deep enough so that constants don't fit in 1 byte. Not deep enough to overflow Python stack. """ n = 300 expr = 0 plus = types.Symbol("+") for _ in range(n): expr = interop.scheme_list([plus, 1, expr]) env = types.Environment(bindings={plus: base.plus}) result = eval.eval(expr, env=env) self.assertEqual(result, n)
def test_env_set_error(self): env = types.Environment() a = types.Symbol("a") with self.assertRaises(exceptions.IdentifierNotBoundError): env.set_(a, 5)
def test_env_define(self): env = types.Environment() a = types.Symbol("a") env.define(a, 5) self.assertEqual(env[a], 5)